diff --git a/CHANGELOG.md b/CHANGELOG.md index 26462a8..6fbe1d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log All notable changes to the "kubescape" extension will be documented in this file. +## [0.3.0] +Major changes + +- Updated to latest @kubescape/install +- Using newer Kubescape version and report format (v2) ## [0.1.1] Minor fixes diff --git a/README.md b/README.md index a77bbd8..97dd62c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Kubescape -Visual studio extension the utilize the power 💪 of [Kubescape](https://github.com/armosec/kubescape) directly into your +Visual studio extension the utilize the power 💪 of [Kubescape](https://github.com/kubescape/kubescape) directly into your favorite text editor. ## ✨ Features -### Scan yaml files and get analysis from Kubescape. +### Scan yaml files and get analysis from Kubescape Yaml files can be scanned using a commands. You can access any of this extension commands by opening the Command Palette (Ctrl+Shift+P on Linux/Windows and Cmd+Shift+P on Mac), and then typing in the command name. @@ -36,7 +36,7 @@ you can use the option `Dir Path` which a custom directory on your system. ### Scan triggers As for now, kubescape scan can take a while, so it might be unwise to run scans -without a good reason (like a dirty file). +without a good reason (like a dirty file). I chose to do a background scan only when a new file is saved on the disk. To choose between available files to scan on save use the option `Scan On Save`. @@ -94,7 +94,7 @@ This extension is available officially at either: - [Microsoft VScode Extensions Marketplace](https://marketplace.visualstudio.com/items?itemName=kubescape.kubescape) - [Open VSX Registry](https://open-vsx.org/extension/kubescape/kubescape) -- [Kubescape Github Releases](https://github.com/armosec/kubescape/releases) +- [Kubescape Github Releases](https://github.com/kubescape/kubescape/releases) ## 🗒️ Release Notes diff --git a/package-lock.json b/package-lock.json index 0795eee..3f6d598 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,22 +1,22 @@ { "name": "kubescape", - "version": "0.2.1", + "version": "0.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "kubescape", - "version": "0.2.1", + "version": "0.3.0", "license": "Apache", "dependencies": { - "@armosec/yamlparse": "^0.1.0", - "@kubescape/install": "^0.3.6", + "@kubescape/install": "^0.4.0", + "@kubescape/yamlparse": "^0.1.0", "abort-controller": "^3.0.0", "jsdom": "^19.0.0", "node-fetch": "^2.6.0" }, "devDependencies": { - "@types/glob": "^7.1.4", + "@types/glob": "^8.0.0", "@types/jsdom": "^16.2.14", "@types/mocha": "^9.0.0", "@types/node": "14.x", @@ -26,20 +26,15 @@ "@typescript-eslint/parser": "^4.31.1", "@vscode/test-electron": "^1.6.2", "eslint": "^7.32.0", - "glob": "^7.1.7", - "mocha": "^9.1.1", + "glob": "^8.0.3", + "mocha": "^10.1.0", "typescript": "^4.4.3", - "vsce": "^2.6.7" + "vsce": "^2.14.0" }, "engines": { "vscode": "^1.50.0" } }, - "node_modules/@armosec/yamlparse": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@armosec/yamlparse/-/yamlparse-0.1.0.tgz", - "integrity": "sha512-5yCD/YaspwyiYx5kTwOj33jnO44yohqMlhzotzRWxnVq1gcTJ6rV/0eNxqqmmmcT+eLLWkFfC/GTjr3DZlR0Cw==" - }, "node_modules/@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", @@ -50,21 +45,21 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.15.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", - "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", - "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.14.5", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -110,13 +105,13 @@ "node_modules/@babel/highlight/node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, "node_modules/@babel/highlight/node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, "engines": { "node": ">=0.8.0" @@ -125,7 +120,7 @@ "node_modules/@babel/highlight/node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, "engines": { "node": ">=4" @@ -209,21 +204,42 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, "node_modules/@kubescape/install": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/@kubescape/install/-/install-0.3.6.tgz", - "integrity": "sha512-sMU+yVNe5VC5SXxSJ1nV2MjH94BnVzTgOmxScq/CAvB+SR6HknO1TA7y2+nwa/SxLqEq6eYd0yJFavyEjRz4fA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@kubescape/install/-/install-0.4.0.tgz", + "integrity": "sha512-IGmZhZ/eI3UVCUapVnZHZ7uOHNdlQDnjhtOhQHFC/JS6MrBlr7nA1lCZvnt2/KWRAySYsYTr6frCpcZAjzI3NQ==", "dependencies": { "abort-controller": "^3.0.0", + "compare-versions": "^5.0.1", "node-fetch": "^2.6.0", - "which": "^2.0.2" + "uuid": "^9.0.0", + "which": "^3.0.0" + } + }, + "node_modules/@kubescape/install/node_modules/which": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.0.tgz", + "integrity": "sha512-nla//68K9NU6yRiwDY/Q8aU6siKlSs64aEC7+IV56QoAuyQT2ovsJcgGYGyqMOmI/CGN1BOR6mM5EN0FBO+zyQ==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@kubescape/yamlparse": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@kubescape/yamlparse/-/yamlparse-0.1.0.tgz", + "integrity": "sha512-jlmQZKTUaWPbj9h9pbFPRInmMo0t/u+Bc/hd8BRKCn9BEALUTeRWM2bUUXNt2/6GXekQvTTCoC4hEvTzx0xg6g==" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -269,9 +285,9 @@ } }, "node_modules/@types/glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-w+LsMxKyYQm347Otw+IfBXOv9UWVjpHpCDdbBMt8Kz/xbvCYNjP+0qPh91Km3iKfSRLBB0P7fAMf0KHrPu+MyA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.0.0.tgz", + "integrity": "sha512-l6NQsDDyQUVeoTynNpC9uRvCUint/gSUXQA2euwmTuWGvPY5LSDUu6tkCtJB2SvGQlJQzLaKqcGZP4//7EDveA==", "dev": true, "dependencies": { "@types/minimatch": "*", @@ -498,12 +514,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, "node_modules/@vscode/test-electron": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-1.6.2.tgz", @@ -1074,6 +1084,11 @@ "node": ">= 6" } }, + "node_modules/compare-versions": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-5.0.1.tgz", + "integrity": "sha512-v8Au3l0b+Nwkp4G142JcgJFh1/TUhdxut7wzD1Nq1dyp5oa3tXaqb03EXOAB6jS4gMlalkjAUPZBMiAfKUixHQ==" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1200,9 +1215,9 @@ } }, "node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { "ms": "2.1.2" }, @@ -1970,6 +1985,26 @@ "node": ">=0.6" } }, + "node_modules/fstream/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/fstream/node_modules/rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -2087,20 +2122,19 @@ "dev": true }, "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" }, "engines": { - "node": "*" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -2118,10 +2152,31 @@ "node": ">= 6" } }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/globals": { - "version": "13.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", - "integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==", + "version": "13.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz", + "integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -2159,15 +2214,6 @@ "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", "dev": true }, - "node_modules/growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true, - "engines": { - "node": ">=4.x" - } - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -2316,9 +2362,9 @@ ] }, "node_modules/ignore": { - "version": "5.1.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", - "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", + "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", "dev": true, "engines": { "node": ">= 4" @@ -2673,12 +2719,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash.clonedeep": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", - "dev": true - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -2688,7 +2728,7 @@ "node_modules/lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==", "dev": true }, "node_modules/log-symbols": { @@ -2816,9 +2856,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -2852,48 +2892,98 @@ "dev": true }, "node_modules/mocha": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", - "integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", + "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", "dev": true, "dependencies": { - "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", "chokidar": "3.5.3", - "debug": "4.3.3", + "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", "glob": "7.2.0", - "growl": "1.10.5", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", - "minimatch": "3.0.4", + "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.2.0", + "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", + "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" }, "bin": { "_mocha": "bin/_mocha", - "mocha": "bin/mocha" + "mocha": "bin/mocha.js" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 14.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/mochajs" } }, + "node_modules/mocha/node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/mocha/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -2927,9 +3017,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" @@ -3164,7 +3254,7 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3457,6 +3547,26 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -3682,7 +3792,7 @@ "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "node_modules/string_decoder": { @@ -3756,26 +3866,25 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" }, "node_modules/table": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz", - "integrity": "sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg==", + "version": "6.8.1", + "resolved": "https://registry.npmjs.org/table/-/table-6.8.1.tgz", + "integrity": "sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==", "dev": true, "dependencies": { "ajv": "^8.0.1", - "lodash.clonedeep": "^4.5.0", "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0" + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1" }, "engines": { "node": ">=10.0.0" } }, "node_modules/table/node_modules/ajv": { - "version": "8.6.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz", - "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", @@ -4042,6 +4151,14 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "node_modules/uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -4049,9 +4166,9 @@ "dev": true }, "node_modules/vsce": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/vsce/-/vsce-2.6.7.tgz", - "integrity": "sha512-5dEtdi/yzWQbOU7JDUSOs8lmSzzkewBR5P122BUkmXE6A/DEdFsKNsg2773NGXJTwwF1MfsOgUR6QVF3cLLJNQ==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/vsce/-/vsce-2.14.0.tgz", + "integrity": "sha512-LH0j++sHjcFNT++SYcJ86Zyw49GvyoTRfzYJGmaCgfzTyL7MyMhZeVEnj9K9qKh/m1N3/sdWWNxP+PFS/AvWiA==", "dev": true, "dependencies": { "azure-devops-node-api": "^11.0.1", @@ -4132,6 +4249,26 @@ "node": ">=0.8.0" } }, + "node_modules/vsce/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/vsce/node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -4218,6 +4355,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { "isexe": "^2.0.0" }, @@ -4246,9 +4384,9 @@ } }, "node_modules/workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "node_modules/wrap-ansi": { @@ -4419,11 +4557,6 @@ } }, "dependencies": { - "@armosec/yamlparse": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@armosec/yamlparse/-/yamlparse-0.1.0.tgz", - "integrity": "sha512-5yCD/YaspwyiYx5kTwOj33jnO44yohqMlhzotzRWxnVq1gcTJ6rV/0eNxqqmmmcT+eLLWkFfC/GTjr3DZlR0Cw==" - }, "@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", @@ -4434,18 +4567,18 @@ } }, "@babel/helper-validator-identifier": { - "version": "7.15.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", - "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true }, "@babel/highlight": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", - "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.14.5", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -4482,19 +4615,19 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true }, "supports-color": { @@ -4564,21 +4697,38 @@ } }, "@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, "@kubescape/install": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/@kubescape/install/-/install-0.3.6.tgz", - "integrity": "sha512-sMU+yVNe5VC5SXxSJ1nV2MjH94BnVzTgOmxScq/CAvB+SR6HknO1TA7y2+nwa/SxLqEq6eYd0yJFavyEjRz4fA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@kubescape/install/-/install-0.4.0.tgz", + "integrity": "sha512-IGmZhZ/eI3UVCUapVnZHZ7uOHNdlQDnjhtOhQHFC/JS6MrBlr7nA1lCZvnt2/KWRAySYsYTr6frCpcZAjzI3NQ==", "requires": { "abort-controller": "^3.0.0", + "compare-versions": "^5.0.1", "node-fetch": "^2.6.0", - "which": "^2.0.2" + "uuid": "^9.0.0", + "which": "^3.0.0" + }, + "dependencies": { + "which": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.0.tgz", + "integrity": "sha512-nla//68K9NU6yRiwDY/Q8aU6siKlSs64aEC7+IV56QoAuyQT2ovsJcgGYGyqMOmI/CGN1BOR6mM5EN0FBO+zyQ==", + "requires": { + "isexe": "^2.0.0" + } + } } }, + "@kubescape/yamlparse": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@kubescape/yamlparse/-/yamlparse-0.1.0.tgz", + "integrity": "sha512-jlmQZKTUaWPbj9h9pbFPRInmMo0t/u+Bc/hd8BRKCn9BEALUTeRWM2bUUXNt2/6GXekQvTTCoC4hEvTzx0xg6g==" + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -4612,9 +4762,9 @@ "dev": true }, "@types/glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-w+LsMxKyYQm347Otw+IfBXOv9UWVjpHpCDdbBMt8Kz/xbvCYNjP+0qPh91Km3iKfSRLBB0P7fAMf0KHrPu+MyA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.0.0.tgz", + "integrity": "sha512-l6NQsDDyQUVeoTynNpC9uRvCUint/gSUXQA2euwmTuWGvPY5LSDUu6tkCtJB2SvGQlJQzLaKqcGZP4//7EDveA==", "dev": true, "requires": { "@types/minimatch": "*", @@ -4767,12 +4917,6 @@ "eslint-visitor-keys": "^2.0.0" } }, - "@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, "@vscode/test-electron": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-1.6.2.tgz", @@ -5197,6 +5341,11 @@ "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", "dev": true }, + "compare-versions": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-5.0.1.tgz", + "integrity": "sha512-v8Au3l0b+Nwkp4G142JcgJFh1/TUhdxut7wzD1Nq1dyp5oa3tXaqb03EXOAB6jS4gMlalkjAUPZBMiAfKUixHQ==" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -5300,9 +5449,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "requires": { "ms": "2.1.2" } @@ -5873,6 +6022,20 @@ "rimraf": "2" }, "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -5973,17 +6136,36 @@ "dev": true }, "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "glob-parent": { @@ -5996,9 +6178,9 @@ } }, "globals": { - "version": "13.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", - "integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==", + "version": "13.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz", + "integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -6024,12 +6206,6 @@ "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", "dev": true }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -6127,9 +6303,9 @@ "dev": true }, "ignore": { - "version": "5.1.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", - "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", + "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", "dev": true }, "import-fresh": { @@ -6399,12 +6575,6 @@ "p-locate": "^5.0.0" } }, - "lodash.clonedeep": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", - "dev": true - }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -6414,7 +6584,7 @@ "lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==", "dev": true }, "log-symbols": { @@ -6505,9 +6675,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" @@ -6535,37 +6705,79 @@ "dev": true }, "mocha": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", - "integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", + "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", "dev": true, "requires": { - "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", "chokidar": "3.5.3", - "debug": "4.3.3", + "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", "glob": "7.2.0", - "growl": "1.10.5", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", - "minimatch": "3.0.4", + "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.2.0", + "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", + "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" }, "dependencies": { + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + } + } + }, "ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -6595,9 +6807,9 @@ "dev": true }, "nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true }, "napi-build-utils": { @@ -6775,7 +6987,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-key": { @@ -6983,6 +7195,22 @@ "dev": true, "requires": { "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "run-parallel": { @@ -7124,7 +7352,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "string_decoder": { @@ -7185,23 +7413,22 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" }, "table": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz", - "integrity": "sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg==", + "version": "6.8.1", + "resolved": "https://registry.npmjs.org/table/-/table-6.8.1.tgz", + "integrity": "sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==", "dev": true, "requires": { "ajv": "^8.0.1", - "lodash.clonedeep": "^4.5.0", "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0" + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1" }, "dependencies": { "ajv": { - "version": "8.6.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz", - "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -7419,6 +7646,11 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -7426,9 +7658,9 @@ "dev": true }, "vsce": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/vsce/-/vsce-2.6.7.tgz", - "integrity": "sha512-5dEtdi/yzWQbOU7JDUSOs8lmSzzkewBR5P122BUkmXE6A/DEdFsKNsg2773NGXJTwwF1MfsOgUR6QVF3cLLJNQ==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/vsce/-/vsce-2.14.0.tgz", + "integrity": "sha512-LH0j++sHjcFNT++SYcJ86Zyw49GvyoTRfzYJGmaCgfzTyL7MyMhZeVEnj9K9qKh/m1N3/sdWWNxP+PFS/AvWiA==", "dev": true, "requires": { "azure-devops-node-api": "^11.0.1", @@ -7494,6 +7726,20 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -7564,6 +7810,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "requires": { "isexe": "^2.0.0" } @@ -7583,9 +7830,9 @@ "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" }, "workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "wrap-ansi": { diff --git a/package.json b/package.json index ce2170f..827df5d 100644 --- a/package.json +++ b/package.json @@ -8,17 +8,17 @@ }, "license": "Apache", "icon": "images/logo.png", - "version": "0.2.1", + "version": "0.3.0", "publisher": "kubescape", "engines": { "vscode": "^1.50.0" }, "repository": { "type": "git", - "url": "https://github.com/armosec/vscode-kubescape" + "url": "https://github.com/kubescape/vscode-kubescape" }, "bugs": { - "url": "https://github.com/armosec/vscode-kubescape/issues" + "url": "https://github.com/kubescape/vscode-kubescape/issues" }, "categories": [ "Linters" @@ -105,7 +105,7 @@ "vscode.yaml" ], "devDependencies": { - "@types/glob": "^7.1.4", + "@types/glob": "^8.0.0", "@types/jsdom": "^16.2.14", "@types/mocha": "^9.0.0", "@types/node": "14.x", @@ -115,10 +115,10 @@ "@typescript-eslint/parser": "^4.31.1", "@vscode/test-electron": "^1.6.2", "eslint": "^7.32.0", - "glob": "^7.1.7", - "mocha": "^9.1.1", + "glob": "^8.0.3", + "mocha": "^10.1.0", "typescript": "^4.4.3", - "vsce": "^2.6.7" + "vsce": "^2.14.0" }, "config": { "platformPackages": { @@ -131,8 +131,8 @@ } }, "dependencies": { - "@armosec/yamlparse": "^0.1.0", - "@kubescape/install": "^0.3.6", + "@kubescape/yamlparse": "^0.1.0", + "@kubescape/install": "^0.4.0", "abort-controller": "^3.0.0", "jsdom": "^19.0.0", "node-fetch": "^2.6.0" diff --git a/src/Kubescape/config.ts b/src/Kubescape/config.ts index 661454d..81e4ed1 100644 --- a/src/Kubescape/config.ts +++ b/src/Kubescape/config.ts @@ -1,85 +1,87 @@ import vscode = require('vscode'); -import * as path from 'path' +import * as path from 'path'; -import { expend } from '../utils/path' -import { getExtensionContext } from '../utils/context' +import { expend } from '../utils/path'; +import { getExtensionContext } from '../utils/context'; import { PACKAGE_STABLE_BUILD } from './globals'; -const CONFIG_SCAN_ON_SAVE = "scanOnSave" -const CONFIG_SCAN_FRAMEWORKS = "scanFrameworks" -const CONFIG_REQUIRED_FRAMEWORKS = "requiredFrameworks" -const CONFIG_DIR_PATH = "dirPath" -const CONFIG_VERSION_TIER = "versionTier" -const CONFIG_CUSTOM_FRAMEWORKS_DIR = "customFrameworksDir" +const CONFIG_SCAN_ON_SAVE = "scanOnSave"; +const CONFIG_SCAN_FRAMEWORKS = "scanFrameworks"; +const CONFIG_REQUIRED_FRAMEWORKS = "requiredFrameworks"; +const CONFIG_DIR_PATH = "dirPath"; +const CONFIG_VERSION_TIER = "versionTier"; +const CONFIG_CUSTOM_FRAMEWORKS_DIR = "customFrameworksDir"; export class KubescapeConfig { private static _instance: KubescapeConfig = new KubescapeConfig(); - private configuration : vscode.WorkspaceConfiguration + private configuration : vscode.WorkspaceConfiguration; private constructor() { if (!KubescapeConfig._instance) { - KubescapeConfig._instance = this + KubescapeConfig._instance = this; } - this.configuration = vscode.workspace.getConfiguration('kubescape') + this.configuration = vscode.workspace.getConfiguration('kubescape'); } static get instance() : KubescapeConfig { - return this._instance + return this._instance; } get kubescapeDir(): string { /* Enable override from configuration */ if (this.configuration[CONFIG_DIR_PATH]) { - return expend(this.configuration[CONFIG_DIR_PATH]) + return expend(this.configuration[CONFIG_DIR_PATH]); } - const extensionContext = getExtensionContext() + const extensionContext = getExtensionContext(); if (!extensionContext) { - throw new Error("The extension is not loaded properly!") + throw new Error("The extension is not loaded properly!"); } - return path.join(extensionContext.extensionPath, "install") + return path.join(extensionContext.extensionPath, "install"); } get scanOnSave(): boolean { return !!this.configuration[CONFIG_SCAN_ON_SAVE] && - this.configuration[CONFIG_SCAN_ON_SAVE] !== "none" + this.configuration[CONFIG_SCAN_ON_SAVE] !== "none"; } get kubescapeVersion(): string { if (this.configuration[CONFIG_VERSION_TIER] && - this.configuration[CONFIG_VERSION_TIER] === "latest") return "latest" + this.configuration[CONFIG_VERSION_TIER] === "latest") { + return "latest"; + } - return PACKAGE_STABLE_BUILD + return PACKAGE_STABLE_BUILD; } get scanFrameworks() : string[] { if (this.configuration[CONFIG_SCAN_FRAMEWORKS]) { - return this.configuration[CONFIG_SCAN_FRAMEWORKS] + return this.configuration[CONFIG_SCAN_FRAMEWORKS]; } - return ['all'] + return ['all']; } get requiredFrameworks() : string[] { if (this.configuration[CONFIG_REQUIRED_FRAMEWORKS]) { - return this.configuration[CONFIG_REQUIRED_FRAMEWORKS] + return this.configuration[CONFIG_REQUIRED_FRAMEWORKS]; } - return ['all'] + return ['all']; } get customFrameworkDirectory() : string | undefined { - const fDir = this.configuration[CONFIG_CUSTOM_FRAMEWORKS_DIR] + const fDir = this.configuration[CONFIG_CUSTOM_FRAMEWORKS_DIR]; if (fDir && fDir.length > 0) { /* Get custom frameworks from specified directories */ - return expend(fDir) + return expend(fDir); } - return undefined + return undefined; } } diff --git a/src/Kubescape/diagnostic.ts b/src/Kubescape/diagnostic.ts index 5ad1b6b..378a40d 100644 --- a/src/Kubescape/diagnostic.ts +++ b/src/Kubescape/diagnostic.ts @@ -1,94 +1,97 @@ -import * as vscode from 'vscode' -import { COMMAND_VIEW_CTRL_DOC } from './globals' +import * as vscode from 'vscode'; +import { COMMAND_VIEW_CTRL_DOC } from './globals'; -export const KUBESCAPE_DIAGNOSTIC_ID = "kubescape" -export const KUBESCAPE_COMMAND = "kubescape" +export const KUBESCAPE_DIAGNOSTIC_ID = "kubescape"; +export const KUBESCAPE_COMMAND = "kubescape"; export type KubescapeReport = { framework : string id: string, name : string, - alert: string, description : string, remediation : string, range : vscode.Range, severity : vscode.DiagnosticSeverity, path : string, fix : string | undefined -} +}; function getFormattedField(str : string, label? : string) { - return str.length > 0 ? `\n${label}: ${str}\n` : "" + return str.length > 0 ? `\n${label}: ${str}\n` : ""; } -export const KubescapeDiagnosticCollections : any = {} +export const kubescapeDiagnosticCollections : any = {}; export class KubescapeDiagnostic { - private _kubescapeFileReports : any - private static _instance: KubescapeDiagnostic + private _kubescapeFileReports : any; + private static _instance: KubescapeDiagnostic; constructor() { - this._kubescapeFileReports = {} + this._kubescapeFileReports = {}; } public static get instance() : KubescapeDiagnostic { - if (!this._instance) this._instance = new KubescapeDiagnostic - return this._instance + if (!this._instance) { + this._instance = new KubescapeDiagnostic; + } + return this._instance; } private get reportsObj() : any { - const filename = vscode.window.activeTextEditor?.document.fileName - if (!filename || !this._kubescapeFileReports) return {} + const filename = vscode.window.activeTextEditor?.document.fileName; + if (!filename || !this._kubescapeFileReports) { + return {}; + } if (!this._kubescapeFileReports[filename]) { - this._kubescapeFileReports[filename] = {} + this._kubescapeFileReports[filename] = {}; } - return this._kubescapeFileReports[filename] + return this._kubescapeFileReports[filename]; } public get reports() : KubescapeReport[] { - return Object.values(this.reportsObj) + return Object.values(this.reportsObj); } public get reportsIds() : string[] { - return Object.keys(this.reportsObj) + return Object.keys(this.reportsObj); } public get diagnostics() : vscode.Diagnostic[] { return this.reports.map(report => { - const heading = `${report.name}` + const heading = `${report.name}`; const message = `${heading}\n${'_'.repeat(heading.length)}\n` + - `${getFormattedField(report.alert, "Alert")}` + `${getFormattedField(report.description, "Description")}` + - `${getFormattedField(report.remediation, "Remediation")}` + `${getFormattedField(report.remediation, "Remediation")}`; - const diagnostic = new vscode.Diagnostic(report.range, message, report.severity) - diagnostic.source = KUBESCAPE_DIAGNOSTIC_ID - diagnostic.code = `${report.id}` + const diagnostic = new vscode.Diagnostic(report.range, message, report.severity); + diagnostic.source = KUBESCAPE_DIAGNOSTIC_ID; + diagnostic.code = `${report.id}`; - return diagnostic - }) + return diagnostic; + }); } public has(controlId : string) : boolean { - return this.reportsObj[controlId] != undefined + return this.reportsObj[controlId] != undefined; } public get(controlId : string) : KubescapeReport | undefined { - return this.reportsObj[controlId] + return this.reportsObj[controlId]; } public addReport(report : KubescapeReport) { - this.reportsObj[report.id] = report + this.reportsObj[report.id] = report; } public clear() { - const filename = vscode.window.activeTextEditor?.document.fileName - if (!filename || !this._kubescapeFileReports) return - - this._kubescapeFileReports[filename] = [] + const filename = vscode.window.activeTextEditor?.document.fileName; + if (!filename || !this._kubescapeFileReports) { + return; + } + this._kubescapeFileReports[filename] = []; } } @@ -97,16 +100,16 @@ export class KubescapeCodeAction implements vscode.CodeActionProvider { public static readonly providedCodeActionKinds = [ vscode.CodeActionKind.QuickFix - ] + ]; private createFix(document: vscode.TextDocument, range: vscode.Range, ctrlReport: KubescapeReport): vscode.CodeAction | undefined { const fix = new vscode.CodeAction(`Fix ${ctrlReport.path}`, vscode.CodeActionKind.QuickFix); - const elementPos = ctrlReport.path.lastIndexOf('.') - const element = ctrlReport.path.substring(elementPos + 1) - const fixStr = `${element}: ${ctrlReport.fix}` + const elementPos = ctrlReport.path.lastIndexOf('.'); + const element = ctrlReport.path.substring(elementPos + 1); + const fixStr = `${element}: ${ctrlReport.fix}`; fix.edit = new vscode.WorkspaceEdit(); fix.edit.replace(document.uri, new vscode.Range(ctrlReport.range.start, ctrlReport.range.end.translate(0, Number.MAX_SAFE_INTEGER)), fixStr); - return fix + return fix; } private createCommand(ctrlReport : KubescapeReport): vscode.CodeAction | undefined { @@ -117,32 +120,32 @@ export class KubescapeCodeAction implements vscode.CodeActionProvider { arguments: [ctrlReport.id], title: `Learn more about ${ctrlReport.name}`, tooltip: 'This will open the browser with the control documentation' - } - return action + }; + return action; } public provideCodeActions(document: vscode.TextDocument, range: vscode.Range | vscode.Selection, context: vscode.CodeActionContext, token: vscode.CancellationToken): vscode.CodeAction[] | undefined { - const codeActions : vscode.CodeAction[] = [] - context.diagnostics.filter(diag => diag.source == KUBESCAPE_DIAGNOSTIC_ID) + const codeActions : vscode.CodeAction[] = []; + context.diagnostics.filter(diag => diag.source === KUBESCAPE_DIAGNOSTIC_ID) .forEach(diag => { if (diag.code) { - const ctrlReport = KubescapeDiagnostic.instance.get(diag.code.toString()) + const ctrlReport = KubescapeDiagnostic.instance.get(diag.code.toString()); if (ctrlReport) { - const action = this.createCommand(ctrlReport) + const action = this.createCommand(ctrlReport); if (action) { - codeActions.push(action) + codeActions.push(action); } if (ctrlReport.fix) { - const fix = this.createFix(document, range, ctrlReport) + const fix = this.createFix(document, range, ctrlReport); if (fix) { - codeActions.push(fix) + codeActions.push(fix); } } } } - }) + }); - return codeActions + return codeActions; } } \ No newline at end of file diff --git a/src/Kubescape/globals.ts b/src/Kubescape/globals.ts index 2b6ae09..9507c7c 100644 --- a/src/Kubescape/globals.ts +++ b/src/Kubescape/globals.ts @@ -1,3 +1,3 @@ -export const PACKAGE_STABLE_BUILD = "v2.0.144" -export const ERROR_KUBESCAPE_NOT_INSTALLED = "Kubescape is not installed!" -export const COMMAND_VIEW_CTRL_DOC = "kubescape.viewCtrlDoc" \ No newline at end of file +export const PACKAGE_STABLE_BUILD = "v2.0.176"; +export const ERROR_KUBESCAPE_NOT_INSTALLED = "Kubescape is not installed!"; +export const COMMAND_VIEW_CTRL_DOC = "kubescape.viewCtrlDoc"; \ No newline at end of file diff --git a/src/Kubescape/kubescape.ts b/src/Kubescape/kubescape.ts index da07da3..da19642 100644 --- a/src/Kubescape/kubescape.ts +++ b/src/Kubescape/kubescape.ts @@ -1,44 +1,44 @@ -import * as vscode from 'vscode' -import * as jsdom from 'jsdom' -import fetch from 'node-fetch' +import * as vscode from 'vscode'; +import * as jsdom from 'jsdom'; +import fetch from 'node-fetch'; -import * as scan from './scan' +import * as scan from './scan'; -import { Logger } from '../utils/log' +import { Logger } from '../utils/log'; export async function scanYaml() { - const currentFile = vscode.window.activeTextEditor + const currentFile = vscode.window.activeTextEditor; if (!currentFile) { - Logger.error("Could not locate open directories") - return + Logger.error("Could not locate open directories"); + return; } if (currentFile.document.languageId !== "yaml") { - Logger.error("Not an YAML configuration file") + Logger.error("Not an YAML configuration file"); return; } - scan.kubescapeScanYaml(currentFile.document, true) + scan.kubescapeScanYaml(currentFile.document, true); } export async function viewCtrlDoc(params: any[]) { - const url = `https://hub.armo.cloud/docs/${params.toString().toLowerCase()}` + const url = `https://hub.armosec.io/docs/${params.toString().replaceAll('.', '-').toLowerCase()}`; fetch(url).then(async res => { if (res.ok) { - const content = await res.text() + const content = await res.text(); - const { document } = new jsdom.JSDOM(content).window + const { document } = new jsdom.JSDOM(content).window; - console.log(document) - const markdown = document.getElementById('content-container') + console.log(document); + const markdown = document.getElementById('content-container'); - console.log(markdown) + console.log(markdown); if (markdown) { - const markdownContent = markdown.querySelector('.markdown-body') + const markdownContent = markdown.querySelector('.markdown-body'); if (markdownContent) { @@ -48,16 +48,16 @@ export async function viewCtrlDoc(params: any[]) { vscode.ViewColumn.Beside, {} - ) + ); - panel.webview.html = markdownContent.innerHTML + panel.webview.html = markdownContent.innerHTML; } } } }) .catch(err=> { - Logger.error(err) - vscode.env.openExternal(vscode.Uri.parse(url)) - }) + Logger.error(err); + vscode.env.openExternal(vscode.Uri.parse(url)); + }); } \ No newline at end of file diff --git a/src/Kubescape/scan.ts b/src/Kubescape/scan.ts index 9f6d0ad..dbacda5 100644 --- a/src/Kubescape/scan.ts +++ b/src/Kubescape/scan.ts @@ -1,141 +1,158 @@ -import * as vscode from 'vscode' - -import { YamlHighlighter } from '@armosec/yamlparse' -import { KubescapeApi } from '@kubescape/install' - -import { VscodeUi } from '../utils/ui' -import { Logger } from '../utils/log' -import { ERROR_KUBESCAPE_NOT_INSTALLED } from './globals' -import { KubescapeDiagnostic, KubescapeReport, KubescapeDiagnosticCollections } from './diagnostic' - -function handleFailedPaths(framework : any, ctrlReport : any, ruleResponse : any, - lines : string[], has_failed : boolean, problems : any) { - for (let fPath of (ruleResponse.failedPaths ? ruleResponse.failedPaths : [])) { - if (fPath === "") continue - const steps = YamlHighlighter.splitPathToSteps(fPath) - let position = YamlHighlighter.getStartIndexAcc(steps, lines) - - if (position.startIndex > 0) { - let start = position.prevIndent - let end = start + steps[steps.length - 1].length - let row = position.startIndex - const range = new vscode.Range(new vscode.Position(row, start), - new vscode.Position(row, end)) - - let kubescapeReport: KubescapeReport = { - framework: framework.name, - id: ctrlReport.id, - name: ctrlReport.name, - alert: ruleResponse.alertMessage, - description: ctrlReport.description, - remediation: ctrlReport.remediation, - range : range, - severity : has_failed ? vscode.DiagnosticSeverity.Warning : vscode.DiagnosticSeverity.Information, - path: fPath, - fix: undefined - } - KubescapeDiagnostic.instance.addReport(kubescapeReport) +import * as vscode from 'vscode'; + +import { YamlHighlighter } from '@kubescape/yamlparse'; +import { KubescapeApi } from '@kubescape/install'; + +import { VscodeUi } from '../utils/ui'; +import { Logger } from '../utils/log'; +import { ERROR_KUBESCAPE_NOT_INSTALLED } from './globals'; +import { KubescapeDiagnostic, KubescapeReport, kubescapeDiagnosticCollections } from './diagnostic'; + +function handlePaths(framework : any, ctrlReport : any, ruleResponse : any, lines : string[], hasFailed : boolean) { + for (let pathObj of (ruleResponse.paths ? ruleResponse.paths : [])) { + if (pathObj.failedPath && pathObj.failedPath !== "") { + handleFailedPaths(framework, ctrlReport, ruleResponse, lines, hasFailed, pathObj.failedPath); + } else { + handleFixedPaths(framework, ctrlReport, ruleResponse, lines, hasFailed, pathObj.fixPath); } } } -function handleFixedPaths(framework : any, ctrlReport : any, ruleResponse : any, - lines : string[], has_failed : boolean, problems : any) { - for (let fPathObj of (ruleResponse.fixPaths ? ruleResponse.fixPaths : [])) { - const fPath = fPathObj.path - const fValue = fPathObj.value - if (!fPath || fPath === "") continue - - const steps = YamlHighlighter.splitPathToSteps(fPath) - let position = YamlHighlighter.getStartIndexAcc(steps, lines) - - if (position.startIndex > 0) { - let start = position.prevIndent - let end = start + steps[steps.length - 1].length - let row = position.startIndex - const range = new vscode.Range(new vscode.Position(row, start), - new vscode.Position(row, end)) - - let kubescapeReport: KubescapeReport = { - framework: framework.name, - id: ctrlReport.id, - name: ctrlReport.name, - alert: ruleResponse.alertMessage, - description: ctrlReport.description, - remediation: ctrlReport.remediation, - range : range, - severity : has_failed ? vscode.DiagnosticSeverity.Warning : vscode.DiagnosticSeverity.Information, - path: fPath, - fix: fValue - } - KubescapeDiagnostic.instance.addReport(kubescapeReport) - } +function handleFailedPaths(framework : any, ctrlReport : any, ruleResponse : any, lines : string[], hasFailed : boolean, fPath: any) { + if (fPath === "") { + return; + } + + const steps = YamlHighlighter.splitPathToSteps(fPath); + let position = YamlHighlighter.getStartIndexAcc(steps, lines); + + if (position.startIndex > 0) { + let start = position.prevIndent; + let end = start + steps[steps.length - 1].length; + let row = position.startIndex; + const range = new vscode.Range(new vscode.Position(row, start), + new vscode.Position(row, end)); + + let kubescapeReport: KubescapeReport = { + framework: framework.name, + id: ctrlReport.controlID, + name: ctrlReport.name, + description: ctrlReport.description, + remediation: ctrlReport.remediation, + range : range, + severity : hasFailed ? vscode.DiagnosticSeverity.Warning : vscode.DiagnosticSeverity.Information, + path: fPath, + fix: undefined + }; + KubescapeDiagnostic.instance.addReport(kubescapeReport); + } + +} + +function handleFixedPaths(framework : any, ctrlReport : any, ruleResponse : any, lines : string[], hasFailed : boolean, fixPath: any) { + const fPath = fixPath.path; + const fValue = fixPath.value; + if (!fPath || fPath === "") { + return; + } + + const steps = YamlHighlighter.splitPathToSteps(fPath); + let position = YamlHighlighter.getStartIndexAcc(steps, lines); + + if (position.startIndex > 0) { + let start = position.prevIndent; + let end = start + steps[steps.length - 1].length; + let row = position.startIndex; + const range = new vscode.Range(new vscode.Position(row, start), + new vscode.Position(row, end)); + + let kubescapeReport: KubescapeReport = { + framework: framework.name, + id: ctrlReport.controlID, + name: ctrlReport.name, + description: ctrlReport.description, + remediation: ctrlReport.remediation, + range : range, + severity : hasFailed ? vscode.DiagnosticSeverity.Warning : vscode.DiagnosticSeverity.Information, + path: fPath, + fix: fValue + }; + KubescapeDiagnostic.instance.addReport(kubescapeReport); } + } function processKubescapeResult(res : any, filePath : string) { - const problems = KubescapeDiagnostic.instance - problems.clear() - if (!KubescapeDiagnosticCollections[filePath]) { - KubescapeDiagnosticCollections[filePath] = vscode.languages.createDiagnosticCollection() - const x = vscode.languages.createDiagnosticCollection() + const problems = KubescapeDiagnostic.instance; + problems.clear(); + if (!kubescapeDiagnosticCollections[filePath]) { + kubescapeDiagnosticCollections[filePath] = vscode.languages.createDiagnosticCollection(); + const x = vscode.languages.createDiagnosticCollection(); } else { - KubescapeDiagnosticCollections[filePath].clear() + kubescapeDiagnosticCollections[filePath].clear(); } if (vscode.window.activeTextEditor) { - const doc = vscode.window.activeTextEditor.document - const currentFileUri = doc.uri - - const lines = doc.getText().split(new RegExp(/\n/)) - - for (let framework of res) { - let frameWorkFailedPaths : boolean = false - for (let ctrlReport of framework.controlReports) { - if (problems.has(ctrlReport.id)) continue - const has_failed = ctrlReport.failedResources > 0 - const has_warn = ctrlReport.warningResources > 0 - if (has_failed || has_warn) { - frameWorkFailedPaths = true - for (let ruleReport of (ctrlReport.ruleReports ? ctrlReport.ruleReports : [])) { - for (let ruleResponse of (ruleReport.ruleResponses ? ruleReport.ruleResponses : [])) { - handleFailedPaths(framework, ctrlReport, ruleResponse, lines, has_failed, problems) - handleFixedPaths(framework, ctrlReport, ruleResponse, lines, has_failed, problems) + const doc = vscode.window.activeTextEditor.document; + const currentFileUri = doc.uri; + + const lines = doc.getText().split(new RegExp(/\n/)); + + for (let framework of res.summaryDetails.frameworks) { + let frameWorkFailedPaths : boolean = false; + for (let ctrlId in framework.controls) { + let ctrlReport = framework.controls[ctrlId]; + if (problems.has(ctrlId)) { + continue; + } + const controlSummary = res.summaryDetails.controls[ctrlId]; + + const hasFailed = ctrlReport.ResourceCounters.failedResources > 0; + const hasWarn = ctrlReport.ResourceCounters.excludedResources > 0; + if (hasFailed || hasWarn) { + frameWorkFailedPaths = true; + for (let result of res.results) { + const ctrlResult = result.controls.find((c: any) => c.controlID === ctrlId); + if (!ctrlResult) { + continue; + } + for (let ruleReport of (ctrlResult.rules ? ctrlResult.rules : [])) { + handlePaths(framework, controlSummary, ruleReport, lines, hasFailed); } } } } if (!frameWorkFailedPaths) { - Logger.info(`Framework ${framework.name} has no failed paths to mark`) + Logger.info(`Framework ${framework.name} has no failed paths to mark`); } } - KubescapeDiagnosticCollections[filePath].set(currentFileUri, problems.diagnostics); + kubescapeDiagnosticCollections[filePath].set(currentFileUri, problems.diagnostics); } } export function removeFileDiagnostics(filePath : string) { - if (KubescapeDiagnosticCollections && KubescapeDiagnosticCollections[filePath]) { - KubescapeDiagnosticCollections[filePath].clear() - delete KubescapeDiagnosticCollections[filePath] + if (kubescapeDiagnosticCollections && kubescapeDiagnosticCollections[filePath]) { + kubescapeDiagnosticCollections[filePath].clear(); + delete kubescapeDiagnosticCollections[filePath]; } } export async function kubescapeScanYaml(document : vscode.TextDocument, displayOutput : boolean = false) : Promise { if (!document || document.isUntitled) { - Logger.error('Scanning only works for real documents', true) - return + Logger.error('Scanning only works for real documents', true); + return; } - const yamlPath = document.uri.fsPath - const kubescapeApi = KubescapeApi.instance + const yamlPath = document.uri.fsPath; + const kubescapeApi = KubescapeApi.instance; if (!kubescapeApi.isInstalled) { - Logger.error(ERROR_KUBESCAPE_NOT_INSTALLED, true) - throw new Error + Logger.error(ERROR_KUBESCAPE_NOT_INSTALLED, true); + throw new Error; } - const scanResults = await kubescapeApi.scanYaml(new VscodeUi, yamlPath) + const scanResults = await kubescapeApi.scanYaml(new VscodeUi, yamlPath); if (displayOutput) { // calls back into the provider @@ -149,5 +166,5 @@ export async function kubescapeScanYaml(document : vscode.TextDocument, displayO }); } - processKubescapeResult(scanResults, yamlPath) + processKubescapeResult(scanResults, yamlPath); } \ No newline at end of file diff --git a/src/Kubescape/types.ts b/src/Kubescape/types.ts index 60fe454..513b6cf 100644 --- a/src/Kubescape/types.ts +++ b/src/Kubescape/types.ts @@ -1,10 +1,10 @@ export class KubescapeVersion { - version: string - isLatest: boolean + version: string; + isLatest: boolean; constructor() { - this.version = "unknown" - this.isLatest = true + this.version = "unknown"; + this.isLatest = true; } } @@ -12,15 +12,15 @@ export type KubescapePath = { fullPath : string, baseDir : string, isCustom : boolean -} +}; export type KubescapeFramework = { name : string, isInstalled : boolean, location : string -} +}; export type KubescapeDir = { directory : string, isCustom : boolean -} +}; diff --git a/src/Kubescape/yamlParse.ts b/src/Kubescape/yamlParse.ts index a0e68d8..34a4556 100644 --- a/src/Kubescape/yamlParse.ts +++ b/src/Kubescape/yamlParse.ts @@ -3,14 +3,14 @@ export interface IYamlHighlight { endIndex: number; } -type startIndexAccType = { startIndex: number; prevIndent: number; tempMatch: RegExpMatchArray | null; }; +type StartIndexAccType = { startIndex: number; prevIndent: number; tempMatch: RegExpMatchArray | null; }; -function checkAndUpdateIndent(startIndexAcc : startIndexAccType, index : number) : boolean { +function checkAndUpdateIndent(startIndexAcc : StartIndexAccType, index : number) : boolean { if (index >= startIndexAcc.prevIndent) { - startIndexAcc.prevIndent = index - return true + startIndexAcc.prevIndent = index; + return true; } else { - return false + return false; } } @@ -41,13 +41,13 @@ export class ResourceHighlightsHelperService { } - static getStartIndexAcc(steps: string[], lines: string[]): startIndexAccType { + static getStartIndexAcc(steps: string[], lines: string[]): StartIndexAccType { const indentArray = '- '; // const indentArray = ' - '; const regExpForArray = new RegExp(/\[\d+]/); const regExpForArrayIndex = new RegExp(/\d+/); - return steps.reduce((startIndexAcc: startIndexAccType, step: string, stepIndex: number) => { + return steps.reduce((startIndexAcc: StartIndexAccType, step: string, stepIndex: number) => { const stepWithOutArr = step.replace(regExpForArray, '') + ':'; if (startIndexAcc.tempMatch) { @@ -55,7 +55,7 @@ export class ResourceHighlightsHelperService { } else { startIndexAcc.startIndex = lines.findIndex((line: string, indexLine: number) => { if (indexLine > startIndexAcc.startIndex) { - return checkAndUpdateIndent(startIndexAcc, line.indexOf(stepWithOutArr)) + return checkAndUpdateIndent(startIndexAcc, line.indexOf(stepWithOutArr)); } return false; @@ -67,7 +67,7 @@ export class ResourceHighlightsHelperService { const isLastItem = stepIndex === (steps.length - 1); if (isLastItem && startIndexAcc.tempMatch) { - handleArrayMatch(startIndexAcc, lines, indentArray, indentArray) + handleArrayMatch(startIndexAcc, lines, indentArray, indentArray); } return startIndexAcc; @@ -91,7 +91,7 @@ export class ResourceHighlightsHelperService { } } -function handleArrayMatch(startIndexAcc: startIndexAccType, lines: string[], indentArray: string, searchTerm: string) { +function handleArrayMatch(startIndexAcc: StartIndexAccType, lines: string[], indentArray: string, searchTerm: string) { if (startIndexAcc.tempMatch) { const arrayIndex = +startIndexAcc.tempMatch[0]; diff --git a/src/extension.ts b/src/extension.ts index 93989b5..f81ee4f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,30 +1,30 @@ import * as vscode from 'vscode'; -import { IKubescapeConfig, KubescapeApi } from '@kubescape/install' +import { IKubescapeConfig, KubescapeApi } from '@kubescape/install'; -import * as kubescape from './Kubescape/kubescape' -import * as scan from './Kubescape/scan' -import * as contextHelper from './utils/context' -import { KubescapeConfig } from './Kubescape/config' +import * as kubescape from './Kubescape/kubescape'; +import * as scan from './Kubescape/scan'; +import * as contextHelper from './utils/context'; +import { KubescapeConfig } from './Kubescape/config'; import { Logger } from './utils/log'; -import { VscodeUi } from './utils/ui' +import { VscodeUi } from './utils/ui'; import { ERROR_KUBESCAPE_NOT_INSTALLED -} from './Kubescape/globals' +} from './Kubescape/globals'; import { KubescapeCodeAction } from './Kubescape/diagnostic'; // this method is called when your extension is activated // your extension is activated the very first time the command is executed export async function activate(context: vscode.ExtensionContext) { - contextHelper.setExtensionContext(context) + contextHelper.setExtensionContext(context); - let subscriptions = context.subscriptions + let subscriptions = context.subscriptions; // Subscribe all the exported functions in kubescape.ts for (let exportedFunc of Object.keys(kubescape)){ - let fullFuncName = `kubescape.${exportedFunc}` - subscriptions.push(vscode.commands.registerCommand(fullFuncName, (args) => eval(`${fullFuncName}(args)`))) + let fullFuncName = `kubescape.${exportedFunc}`; + subscriptions.push(vscode.commands.registerCommand(fullFuncName, (args) => eval(`${fullFuncName}(args)`))); } subscriptions.push( @@ -33,39 +33,39 @@ export async function activate(context: vscode.ExtensionContext) { }) ); - const kubescapeApi = KubescapeApi.instance - await initializeExtension(kubescapeApi) + const kubescapeApi = KubescapeApi.instance; + await initializeExtension(kubescapeApi); if (!kubescapeApi.isInstalled) { - Logger.error(ERROR_KUBESCAPE_NOT_INSTALLED) - throw new Error + Logger.error(ERROR_KUBESCAPE_NOT_INSTALLED); + throw new Error; } /* Auto scan on save */ - addOnSaveTextDocument(context) + addOnSaveTextDocument(context); /* Scan on new file open */ - addOnOpenTextDocument(context) + addOnOpenTextDocument(context); /* Remove diagnostics on file close */ vscode.workspace.onDidCloseTextDocument(doc => { - scan.removeFileDiagnostics(doc.fileName) - }) + scan.removeFileDiagnostics(doc.fileName); + }); /* First scan of current file */ if (vscode.window.activeTextEditor) { - const doc = vscode.window.activeTextEditor.document - scan.kubescapeScanYaml(doc) + const doc = vscode.window.activeTextEditor.document; + scan.kubescapeScanYaml(doc); } - Logger.info("Kubescape in active") + Logger.info("Kubescape is active"); } // this method is called when your extension is deactivated export function deactivate() { - contextHelper.setExtensionContext(undefined) - Logger.info("Kubescape deactivated") + contextHelper.setExtensionContext(undefined); + Logger.info("Kubescape deactivated"); } function addOnSaveTextDocument(context : vscode.ExtensionContext) { @@ -76,7 +76,7 @@ function addOnSaveTextDocument(context : vscode.ExtensionContext) { if (KubescapeConfig.instance.scanOnSave) { if (vscode.window.visibleTextEditors.some((e) => e.document.fileName === document.fileName)) { - scan.kubescapeScanYaml(document) + scan.kubescapeScanYaml(document); } } }, null, context.subscriptions); @@ -88,28 +88,28 @@ function addOnOpenTextDocument(context : vscode.ExtensionContext) { return; } - scan.kubescapeScanYaml(document) + scan.kubescapeScanYaml(document); }, null, context.subscriptions); } async function initializeExtension(kubescapeApi : KubescapeApi) { - const config = KubescapeConfig.instance + const config = KubescapeConfig.instance; await kubescapeApi.setup(new VscodeUi, new class implements IKubescapeConfig { get version() : string { - return config.kubescapeVersion + return config.kubescapeVersion; } get frameworksDirectory() : string | undefined { - return config.customFrameworkDirectory + return config.customFrameworkDirectory; } get baseDirectory(): string { - return config.kubescapeDir + return config.kubescapeDir; } get requiredFrameworks(): string[] | undefined { - return config.requiredFrameworks + return config.requiredFrameworks; } get scanFrameworks(): string[] | undefined { - return config.scanFrameworks + return config.scanFrameworks; } - }) + }); } diff --git a/src/utils/context.ts b/src/utils/context.ts index 060f84c..2187c53 100644 --- a/src/utils/context.ts +++ b/src/utils/context.ts @@ -1,7 +1,7 @@ -import * as vscode from 'vscode' +import * as vscode from 'vscode'; -let extensionContext : vscode.ExtensionContext | undefined = undefined +let extensionContext : vscode.ExtensionContext | undefined = undefined; export function setExtensionContext(context : vscode.ExtensionContext | undefined) { extensionContext = context; diff --git a/src/utils/extensionMethods.ts b/src/utils/extensionMethods.ts index a21c10b..2041294 100644 --- a/src/utils/extensionMethods.ts +++ b/src/utils/extensionMethods.ts @@ -1,4 +1,4 @@ -export {} +export {}; declare global { export interface String { extractBetween(surround : string) : string @@ -11,35 +11,35 @@ String.prototype.extractBetween = function(this: string, surround : string) { return this.substring( this.indexOf(surround) + 1, this.lastIndexOf(surround) - ) -} + ); +}; String.prototype.toJson = function() : any { - let obj - let str = this.toString() + let obj; + let str = this.toString(); try { - obj = JSON.parse(str) + obj = JSON.parse(str); } catch { - obj = {} + obj = {}; } - return obj -} + return obj; +}; String.prototype.toJsonArray = function() : any { - let obj - let str = this.toString() + let obj; + let str = this.toString(); try { if (this[0] !== '[') { - str = '[' + str + ']' + str = '[' + str + ']'; } - obj = JSON.parse(str) + obj = JSON.parse(str); } catch { - obj = [] + obj = []; } - return obj -} \ No newline at end of file + return obj; +}; \ No newline at end of file diff --git a/src/utils/log.ts b/src/utils/log.ts index 05c79c4..34e43d4 100644 --- a/src/utils/log.ts +++ b/src/utils/log.ts @@ -1,68 +1,70 @@ -import * as vscode from 'vscode' +import * as vscode from 'vscode'; enum LogLevels { - Debug, Error, Warning, Info + debug, error, warning, info } export class Logger { private static _instance: Logger = new Logger(); - private channel : vscode.OutputChannel + private channel : vscode.OutputChannel; private constructor() { if (!Logger._instance) { - Logger._instance = this + Logger._instance = this; } - this.channel = vscode.window.createOutputChannel("kubescape") + this.channel = vscode.window.createOutputChannel("kubescape"); } private static log(level : LogLevels, message : string, ui : boolean) { - let outputConsole = console.debug - let uiOutput = (message: string, ...items: string[]) : Thenable => new Promise(res=>{}) + let outputConsole = console.debug; + let uiOutput = (message: string, ...items: string[]) : Thenable => new Promise(res=>{}); - let longMessage = `${new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')} ${message}` + let longMessage = `${new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')} ${message}`; switch(level) { - case LogLevels.Debug: - longMessage = `[debug] ${longMessage}` + case LogLevels.debug: + longMessage = `[debug] ${longMessage}`; break; - case LogLevels.Error: - longMessage = `[error] ${longMessage}` - uiOutput = vscode.window.showErrorMessage - outputConsole = console.error + case LogLevels.error: + longMessage = `[error] ${longMessage}`; + uiOutput = vscode.window.showErrorMessage; + outputConsole = console.error; break; - case LogLevels.Warning: - longMessage = `[warn ] ${longMessage}` - uiOutput = vscode.window.showWarningMessage - outputConsole = console.warn + case LogLevels.warning: + longMessage = `[warn ] ${longMessage}`; + uiOutput = vscode.window.showWarningMessage; + outputConsole = console.warn; break; - case LogLevels.Info: - longMessage = `[info ] ${longMessage}` - uiOutput = vscode.window.showInformationMessage - outputConsole = console.info + case LogLevels.info: + longMessage = `[info ] ${longMessage}`; + uiOutput = vscode.window.showInformationMessage; + outputConsole = console.info; break; - default: break + default: break; } - this._instance.channel.appendLine(longMessage) - outputConsole(longMessage) - if (ui) uiOutput(message) + this._instance.channel.appendLine(longMessage); + outputConsole(longMessage); + if (ui) { + uiOutput(message); + } } public static debug(message: string, ui = false) { - this.log(LogLevels.Debug, message, ui) + this.log(LogLevels.debug, message, ui); } public static error(message: string, ui = false) { - this.log(LogLevels.Error, message, ui) + this.log(LogLevels.error, message, ui); } public static info(message: string, ui = false) { - this.log(LogLevels.Info, message, ui) + this.log(LogLevels.info, message, ui); } public static warning(message: string, ui = false) { - this.log(LogLevels.Warning, message, ui) + this.log(LogLevels.warning, message, ui); } } diff --git a/src/utils/path.ts b/src/utils/path.ts index db43e9f..1cf2f3d 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -1,22 +1,25 @@ -import * as os from 'os' -import * as path from 'path' +import * as os from 'os'; +import * as path from 'path'; export function expend(str : string) : string { - let expendedPath = path.normalize(str) - - if (expendedPath.length <= 0) return expendedPath; - + let expendedPath = path.normalize(str); + if (expendedPath.length <= 0) { + return expendedPath; + } + if (expendedPath[0] === '~') { - expendedPath = path.join(os.homedir(), expendedPath.slice(1)) + expendedPath = path.join(os.homedir(), expendedPath.slice(1)); } for (let env of Object.keys(process.env)) { - const to = process.env[env] - const from = "$" + env - if (!to) continue - expendedPath = expendedPath.replace(from, to) + const to = process.env[env]; + const from = "$" + env; + if (!to) { + continue; + } + expendedPath = expendedPath.replace(from, to); } - return expendedPath + return expendedPath; } \ No newline at end of file diff --git a/src/utils/ui.ts b/src/utils/ui.ts index 9d353a7..926e853 100644 --- a/src/utils/ui.ts +++ b/src/utils/ui.ts @@ -1,7 +1,7 @@ -import * as vscode from 'vscode' +import * as vscode from 'vscode'; import AbortController from "abort-controller"; -import { KubescapeUi } from '@kubescape/install' +import { KubescapeUi } from '@kubescape/install'; import { Logger } from './log'; @@ -26,8 +26,10 @@ export class VscodeUi implements KubescapeUi { cancellable: cancel !== null, }; const result = vscode.window.withProgress(opts, async (progress, canc) => { - if (cancel) + if (cancel) { canc.onCancellationRequested((_) => cancel.abort()); + } + let lastFraction = 0; return body(fraction => { if (fraction > lastFraction) { @@ -44,7 +46,8 @@ export class VscodeUi implements KubescapeUi { debug(s: string) { Logger.debug(s); } async showHelp(message: string, url: string) { - if (await vscode.window.showInformationMessage(message, 'Open website')) + if (await vscode.window.showInformationMessage(message, 'Open website')) { vscode.env.openExternal(vscode.Uri.parse(url)); + } } } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 8427a50..e02f57d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,8 @@ "target": "ES2020", "outDir": "out", "lib": [ - "ES2020" + "ES2020", + "ES2021.String" ], "sourceMap": true, "rootDir": "src",