diff --git a/.vscodeignore b/.vscodeignore index cf390ed6..80d238bd 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,6 +1,7 @@ .vscode-test/** .vscode/** .github/** +docs/** typings/** out/test/** out/packages/** diff --git a/CHANGELOG.md b/CHANGELOG.md index 7915c8a9..095f6f6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ ## Unreleased -- Updated PSRule options schema to v0.4.0. [#9](https://github.com/BernieWhite/PSRule-vscode/issues/9) -- Fixed CI badge not displaying in VSCode extension tab [#8](https://github.com/BernieWhite/PSRule-vscode/issues/8) +- Updated PSRule options schema to v0.5.0. [#12](https://github.com/BernieWhite/PSRule-vscode/issues/12) +- Fixed CI badge not displaying in VSCode extension tab. [#8](https://github.com/BernieWhite/PSRule-vscode/issues/8) +- Fixed syntax highlighting for keywords that are included in comments. [#10](https://github.com/BernieWhite/PSRule-vscode/issues/10) ## v0.1.0 diff --git a/docs/example.Rule.ps1 b/docs/example.Rule.ps1 new file mode 100644 index 00000000..2c1ed5f0 --- /dev/null +++ b/docs/example.Rule.ps1 @@ -0,0 +1,14 @@ +# +# Example validation rules +# + +# Description: Redis Cache should only accept secure connections +Rule 'redis.NonSslPort' -If { ResourceType 'Microsoft.Cache/Redis' } { + $TargetObject.properties.enableNonSslPort -eq $False +} + +# Description: Redis Cache should reject TLS versions older then 1.2 +Rule 'redis.MinTLS' -If { ResourceType 'Microsoft.Cache/Redis' } { + # Check that TLS is within range + Within 'properties.minimumTlsVersion' '1.2' +} diff --git a/docs/ps-rule.yaml b/docs/ps-rule.yaml new file mode 100644 index 00000000..50b556b1 --- /dev/null +++ b/docs/ps-rule.yaml @@ -0,0 +1,4 @@ + +execution: + languageMode: FullLanguage + diff --git a/package-lock.json b/package-lock.json index 1a518d81..8bca63b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,10 +4,30 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, "@types/node": { - "version": "8.10.45", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.45.tgz", - "integrity": "sha512-tGVTbA+i3qfXsLbq9rEq/hezaHY55QxQLeXQL2ejNgFAxxrgu8eMmYIOsRcl7hN1uTLVsKOOYacV/rcJM3sfgQ==", + "version": "11.13.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.8.tgz", + "integrity": "sha512-szA3x/3miL90ZJxUCzx9haNbK5/zmPieGraZEe4WI+3srN0eGLiT22NXeMHmyhNEopn+IrxqMc7wdVwvPl8meg==", "dev": true }, "agent-base": { @@ -31,18 +51,6 @@ "uri-js": "^4.2.2" } }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -85,32 +93,6 @@ "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", "dev": true }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - }, - "dependencies": { - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - } - } - }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -498,15 +480,6 @@ "har-schema": "^2.0.0" } }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -593,9 +566,9 @@ "dev": true }, "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, "js-yaml": { @@ -969,9 +942,9 @@ "dev": true }, "resolve": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", - "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", + "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1042,21 +1015,6 @@ "safe-buffer": "~5.1.0" } }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, "tmp": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.29.tgz", @@ -1091,23 +1049,24 @@ "dev": true }, "tslint": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz", - "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.16.0.tgz", + "integrity": "sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA==", "dev": true, "requires": { - "babel-code-frame": "^6.22.0", + "@babel/code-frame": "^7.0.0", "builtin-modules": "^1.1.1", "chalk": "^2.3.0", "commander": "^2.12.1", "diff": "^3.2.0", "glob": "^7.1.1", - "js-yaml": "^3.7.0", + "js-yaml": "^3.13.0", "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", "resolve": "^1.3.2", "semver": "^5.3.0", "tslib": "^1.8.0", - "tsutils": "^2.27.2" + "tsutils": "^2.29.0" } }, "tsutils": { @@ -1159,9 +1118,9 @@ } }, "typescript": { - "version": "3.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.4.tgz", - "integrity": "sha512-xt5RsIRCEaf6+j9AyOBgvVuAec0i92rgCaS3S+UVf5Z/vF2Hvtsw08wtUTJqp4djwznoAgjSxeCcU4r+CcDBJA==", + "version": "3.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", + "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", "dev": true }, "uc.micro": { @@ -1225,9 +1184,9 @@ } }, "vsce": { - "version": "1.57.1", - "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.57.1.tgz", - "integrity": "sha512-fqrUSJZY67pznkk95eeiqgPnT5/BudqtzIyAvsm521TREd772yXzCTWb3IuDx98mJvxIT2GyoBXEgMCeNvkF/A==", + "version": "1.59.0", + "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.59.0.tgz", + "integrity": "sha512-tkB97885k5ce25Brbe9AZTCAXAkBh7oa5EOzY0BCJQ51W/mfRaQuCluCd9gZpWdgiU4AbPvwxtoVKKsenlSt8w==", "dev": true, "requires": { "chalk": "^2.4.2", diff --git a/package.json b/package.json index 844b3fba..ad209aa4 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "name": "Bernie White" }, "engines": { - "vscode": "^1.29.0" + "vscode": "^1.31.0" }, "license": "SEE LICENSE IN LICENSE", "homepage": "https://github.com/BernieWhite/PSRule-vscode/blob/master/README.md", @@ -68,19 +68,19 @@ ], "yamlValidation": [ { - "fileMatch": "PSRule.yaml", + "fileMatch": "ps-rule.yaml", "url": "./schemas/PSRule-options.schema.json" }, { - "fileMatch": "PSRule.yml", + "fileMatch": "ps-rule.yml", "url": "./schemas/PSRule-options.schema.json" }, { - "fileMatch": "psrule.yml", + "fileMatch": "psrule.yaml", "url": "./schemas/PSRule-options.schema.json" }, { - "fileMatch": "psrule.yaml", + "fileMatch": "psrule.yml", "url": "./schemas/PSRule-options.schema.json" } ] @@ -91,17 +91,17 @@ "postinstall": "node ./node_modules/vscode/bin/install" }, "dependencies": { - "vscode-languageclient": "^5.1.1" + "vscode-languageclient": "^5.2.1" }, "extensionDependencies": [ "vscode.powershell", "redhat.vscode-yaml" ], "devDependencies": { - "@types/node": "^8.10.25", - "tslint": "~5.11.0", - "typescript": "^3.1.3", - "vsce": "~1.57.1", - "vscode": "^1.1.30" + "@types/node": "~11.13.8", + "tslint": "~5.16.0", + "typescript": "^3.4.5", + "vsce": "~1.59.0", + "vscode": "^1.1.33" } } diff --git a/schemas/PSRule-options.schema.json b/schemas/PSRule-options.schema.json index 1422b093..99b18569 100644 --- a/schemas/PSRule-options.schema.json +++ b/schemas/PSRule-options.schema.json @@ -1,15 +1,10 @@ { - "title": "PSRule options", "$schema": "http://json-schema.org/draft-04/schema#", + "title": "PSRule options", + "description": "A schema for PSRule YAML options files.", "oneOf": [ { - "$ref": "#/definitions/options-v0.4.0" - }, - { - "$ref": "#/definitions/options-v0.3.0" - }, - { - "$ref": "#/definitions/options-v0.2.0" + "$ref": "#/definitions/options-v0.5.0" } ], "definitions": { @@ -40,20 +35,6 @@ }, "additionalProperties": false }, - "binding-v0.2.0": { - "type": "object", - "description": "Configure property/ object binding options.", - "properties": { - "targetName": { - "type": "array", - "description": "Specifies one or more property names to bind TargetName to.", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - }, "binding-v0.3.0": { "type": "object", "description": "Configure property/ object binding options.", @@ -80,7 +61,7 @@ }, "additionalProperties": false }, - "execution": { + "execution-v0.2.0": { "type": "object", "description": "Options that affect rule execution.", "properties": { @@ -106,27 +87,6 @@ }, "additionalProperties": false }, - "input-v0.3.0": { - "type": "object", - "description": "Options that affect how input types are processed.", - "properties": { - "format": { - "type": "string", - "description": "The input string format.", - "enum": [ - "None", - "Yaml", - "Json" - ], - "default": "None" - }, - "objectPath": { - "type": "string", - "description": "The object path to a property to use instead of the pipeline object." - } - }, - "additionalProperties": false - }, "input-v0.4.0": { "type": "object", "description": "Options that affect how input types are processed.", @@ -149,7 +109,7 @@ }, "additionalProperties": false }, - "logging-v0.4.0": { + "logging-v0.5.0": { "type": "object", "description": "Options for logging outcomes to a informational streams.", "properties": { @@ -174,15 +134,15 @@ "Information" ], "default": "None" - }, - "additionalProperties": false - } + } + }, + "additionalProperties": false }, "suppression-v0.2.0": { "type": "object", "description": "Specifies suppression rules." }, - "output-v0.4.0": { + "output-v0.5.0": { "type": "object", "description": "Options that affect how output is generated.", "properties": { @@ -201,96 +161,15 @@ "enum": [ "None", "Yaml", - "Json" + "Json", + "NUnit3" ], "default": "None" } }, "additionalProperties": false }, - "options-v0.2.0": { - "properties": { - "baseline": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/baseline-v0.2.0" - } - ] - }, - "binding": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/binding-v0.2.0" - } - ] - }, - "execution": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/execution" - } - ] - }, - "suppression": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/suppression-v0.2.0" - } - ] - } - }, - "additionalProperties": false - }, - "options-v0.3.0": { - "properties": { - "baseline": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/baseline-v0.2.0" - } - ] - }, - "binding": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/binding-v0.3.0" - } - ] - }, - "execution": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/execution" - } - ] - }, - "input": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/input-v0.3.0" - } - ] - }, - "suppression": { - "type": "object", - "oneOf": [ - { - "$ref": "#/definitions/suppression-v0.2.0" - } - ] - } - }, - "additionalProperties": false - }, - "options-v0.4.0": { + "options-v0.5.0": { "properties": { "baseline": { "type": "object", @@ -312,7 +191,7 @@ "type": "object", "oneOf": [ { - "$ref": "#/definitions/execution" + "$ref": "#/definitions/execution-v0.2.0" } ] }, @@ -328,7 +207,7 @@ "type": "object", "oneOf": [ { - "$ref": "#/definitions/logging-v0.4.0" + "$ref": "#/definitions/logging-v0.5.0" } ] }, @@ -336,7 +215,7 @@ "type": "object", "oneOf": [ { - "$ref": "#/definitions/output-v0.4.0" + "$ref": "#/definitions/output-v0.5.0" } ] }, diff --git a/syntaxes/keywords.json b/syntaxes/keywords.json index a7c5b726..909b7ab4 100644 --- a/syntaxes/keywords.json +++ b/syntaxes/keywords.json @@ -1,14 +1,18 @@ { + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "scopeName": "PSRule-powershell-keywords", - "injectionSelector": "L:meta.scriptblock.powershell", + "injectionSelector": "meta.scriptblock.powershell", "patterns": [ + { + "include": "source.powershell#commentLine" + }, { "include": "#built-in-keyword" } ], "repository": { "built-in-keyword": { - "match": "(?^\\s*|\\|\\s*)\\b(?i:AllOf|AnyOf|Exists|Match|Within|TypeOf)\\b", "name": "keyword.control.powershell" } }