diff --git a/.github/linters/.sql-config.json b/.github/linters/.sql-config.json new file mode 100644 index 00000000..db91b910 --- /dev/null +++ b/.github/linters/.sql-config.json @@ -0,0 +1,3 @@ +{ + "_comment": "details can be found at: https://sql-lint.readthedocs.io/en/latest/files/configuration.html" +} diff --git a/TEMPLATES/.sql-config.json b/TEMPLATES/.sql-config.json new file mode 100644 index 00000000..db91b910 --- /dev/null +++ b/TEMPLATES/.sql-config.json @@ -0,0 +1,3 @@ +{ + "_comment": "details can be found at: https://sql-lint.readthedocs.io/en/latest/files/configuration.html" +} diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index 4cf971b8..dc84a293 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -511,9 +511,9 @@ "integrity": "sha512-oaAg5gn74VFpPYs6Ou2pjDao3WJxnlnH29q9rLOxSGb0PTw2QtBQcTAN9xs1OAHrtI9En5kIXKM96stf7//c9w==" }, "@types/node": { - "version": "10.17.28", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.28.tgz", - "integrity": "sha512-dzjES1Egb4c1a89C7lKwQh8pwjYmlOAG9dW1pBgxEk57tMrLnssOfEthz8kdkNaBd7lIqQx7APm5+mZ619IiCQ==" + "version": "14.0.27", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", + "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==" }, "@types/normalize-package-data": { "version": "2.4.0", @@ -595,18 +595,6 @@ } } }, - "@typescript-eslint/experimental-utils": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.8.0.tgz", - "integrity": "sha512-o8T1blo1lAJE0QDsW7nSyvZHbiDzQDjINJKyB44Z3sSL39qBy5L10ScI/XwDtaiunoyKGLiY9bzRk4YjsUZl8w==", - "requires": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.8.0", - "@typescript-eslint/typescript-estree": "3.8.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - } - }, "@typescript-eslint/parser": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.9.0.tgz", @@ -661,34 +649,6 @@ } } }, - "@typescript-eslint/types": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.8.0.tgz", - "integrity": "sha512-8kROmEQkv6ss9kdQ44vCN1dTrgu4Qxrd2kXr10kz2NP5T8/7JnEfYNxCpPkArbLIhhkGLZV3aVMplH1RXQRF7Q==" - }, - "@typescript-eslint/typescript-estree": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.8.0.tgz", - "integrity": "sha512-MTv9nPDhlKfclwnplRNDL44mP2SY96YmPGxmMbMy6x12I+pERcxpIUht7DXZaj4mOKKtet53wYYXU0ABaiXrLw==", - "requires": { - "@typescript-eslint/types": "3.8.0", - "@typescript-eslint/visitor-keys": "3.8.0", - "debug": "^4.1.1", - "glob": "^7.1.6", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.8.0.tgz", - "integrity": "sha512-gfqQWyVPpT9NpLREXNR820AYwgz+Kr1GuF3nf1wxpHD6hdxI62tq03ToomFnDxY0m3pUB39IF7sil7D5TQexLA==", - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, "JSV": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", @@ -1041,6 +1001,11 @@ "node-releases": "^1.1.58" } }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, "buffer-writer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", @@ -1135,6 +1100,11 @@ "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", @@ -1231,6 +1201,11 @@ "delayed-stream": "~1.0.0" } }, + "command-exists-promise": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/command-exists-promise/-/command-exists-promise-2.0.2.tgz", + "integrity": "sha512-T6PB6vdFrwnHXg/I0kivM3DqaCGZLjjYSOe0a5WgFKcz1sOnmOeIjnhQPXVXX3QjVbLyTJ85lJkX6lUpukTzaA==" + }, "commander": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", @@ -1723,6 +1698,15 @@ "domelementtype": "1" } }, + "dot-case": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.3.tgz", + "integrity": "sha512-7hwEmg6RiSQfm/GwPL4AAWXKy3YNNZA3oFv2Pdiey0mwkRCPZ9x6SZbkLcn8Ma5PYeVokzoD4Twv2n7LKp5WeA==", + "requires": { + "no-case": "^3.0.3", + "tslib": "^1.10.0" + } + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -2429,6 +2413,14 @@ "reusify": "^1.0.4" } }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "requires": { + "pend": "~1.2.0" + } + }, "figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -2556,6 +2548,14 @@ "universalify": "^0.1.0" } }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "requires": { + "minipass": "^2.6.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3232,12 +3232,13 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, "java-caller": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/java-caller/-/java-caller-1.0.0.tgz", - "integrity": "sha512-FJYCCJchSPoQJh+sCkQwuNO4Nr8oOP48BMRIgP1/3hLnqW0fQ9QRR/8SDiraijtc4dgoTBFhP8IqQQnRbEgK9A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/java-caller/-/java-caller-2.0.0.tgz", + "integrity": "sha512-oSv2BCo1zZWo1Q6t01Bs1Gef4NXv36Rbu39n2M9vQ5Iacsopplx9ik38gfeHp4vLMuvOTVlTEnl9uAU+g3rzlA==", "requires": { "debug": "^4.1.1", - "fs-extra": "^9.0.1" + "fs-extra": "^9.0.1", + "njre": "^0.2.0" }, "dependencies": { "fs-extra": { @@ -3491,9 +3492,12 @@ } }, "lower-case": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", - "integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.1.tgz", + "integrity": "sha512-LiWgfDLLb1dwbFQZsSglpRj+1ctGnayXz3Uv0/WO8n558JycT5fg6zkNcnW0G68Nn0aEldTFeEfmjCfmqry/rQ==", + "requires": { + "tslib": "^1.10.0" + } }, "lru-cache": { "version": "5.1.1", @@ -3764,6 +3768,23 @@ } } }, + "minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "requires": { + "minipass": "^2.9.0" + } + }, "mkdirp": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", @@ -3842,12 +3863,24 @@ "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, - "no-case": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", - "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", + "njre": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/njre/-/njre-0.2.0.tgz", + "integrity": "sha512-+Wq8R6VmjK+jI8a9NdzfU6Vh50r3tjsdvl5KJE1OyHeH8I/nx5Ptm12qpO3qNUbstXuZfBDgDL0qQZw9JyjhMw==", "requires": { - "lower-case": "^1.1.1" + "command-exists-promise": "^2.0.2", + "node-fetch": "^2.5.0", + "tar": "^4.4.8", + "yauzl": "^2.10.0" + } + }, + "no-case": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.3.tgz", + "integrity": "sha512-ehY/mVQCf9BL0gKfsJBvFJen+1V//U+0HQMPrWct40ixE4jnv0bfvxDbWtAHL9EcaPEOJHVVYKoQn1TlZUB8Tw==", + "requires": { + "lower-case": "^2.0.1", + "tslib": "^1.10.0" } }, "node-fetch": { @@ -3925,9 +3958,9 @@ "integrity": "sha1-0LFF62kRicY6eNIB3E/bEpPvDAM=" }, "npm-groovy-lint": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/npm-groovy-lint/-/npm-groovy-lint-7.1.0.tgz", - "integrity": "sha512-Ss1hE8MLyMfZ3+6xMaeNi6aWMhG+spqKghuODNY5wnXe2X0vdxJcS865zhh5tGntMVa+X3QqaTLBNmJLwYb7qA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/npm-groovy-lint/-/npm-groovy-lint-7.2.0.tgz", + "integrity": "sha512-USoW673L/+0/rj+kKmLPVjCtsW5Izi4T0N4ov3wjdamdeUy67/kH1VawaHiB+F3lEPjVpnkOtUDrzn3mQw5bbQ==", "requires": { "@amplitude/node": "^0.3.3", "ansi-colors": "^4.1.1", @@ -3941,7 +3974,7 @@ "glob": "^7.1.6", "import-fresh": "^3.2.1", "ip": "^1.1.5", - "java-caller": "^1.0.0", + "java-caller": "^2.0.0", "optionator": "^0.8.3", "semver": "^7.1.3", "strip-json-comments": "^3.0.1", @@ -4116,11 +4149,12 @@ "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" }, "param-case": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz", - "integrity": "sha1-35T9jPZTHs915r75oIWPvHK+Ikc=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.3.tgz", + "integrity": "sha512-VWBVyimc1+QrzappRs7waeN2YmoZFCGXWASRYX1/rGHtXqEcrGEIDm+jqIwFa2fRXNgQEwrxaYuIrX0WcAguTA==", "requires": { - "no-case": "^2.2.0" + "dot-case": "^3.0.3", + "tslib": "^1.10.0" } }, "parent-module": { @@ -4203,6 +4237,11 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -5155,31 +5194,26 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "sql-lint": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/sql-lint/-/sql-lint-0.0.14.tgz", - "integrity": "sha512-zkIemw73nQKBD/LVFHnk8xgxi4wPPXJe4X0tMbEcktA/DQGXqqsl87oGOPTfcMYJwn0caQSWvf8ghCluVWZfwQ==", + "version": "0.0.15", + "resolved": "https://registry.npmjs.org/sql-lint/-/sql-lint-0.0.15.tgz", + "integrity": "sha512-HotT4tUH2daWTQzO3oPYRA+8qGKB+vyVmneDmfRjaYM5J8eqVHPHTt5RQRVZDIoELLB8Lt3U0Redbkul2wi1SA==", "requires": { "@types/moo": "^0.5.3", "@types/mysql": "^2.15.9", "@types/nearley": "^2.11.1", - "@types/node": "^10.14.2", + "@types/node": "^14.0.14", "@types/sprintf-js": "^1.1.2", "any-db": "^2.2.1", "any-db-mysql": "^2.1.2", "any-db-postgres": "^2.1.5", - "commander": "^2.17.1", + "commander": "^5.1.0", "moo": "^0.5.1", "mysql": "^2.16.0", "nearley": "^2.19.3", - "param-case": "^2.1.1", + "param-case": "^3.0.3", "sprintf-js": "^1.1.2" }, "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" - }, "sprintf-js": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", @@ -5681,6 +5715,20 @@ } } }, + "tar": { + "version": "4.4.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", + "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.8.6", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + } + }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -6094,6 +6142,15 @@ "camelcase": "^5.0.0", "decamelize": "^1.2.0" } + }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } } } } diff --git a/dependencies/package.json b/dependencies/package.json index 70d251b0..fd8925ec 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -16,13 +16,13 @@ "htmlhint": "^0.14.1", "jsonlint": "^1.6.3", "markdownlint-cli": "^0.23.2", - "npm-groovy-lint": "^7.1.0", + "npm-groovy-lint": "^7.2.0", "prettier": "^2.0.5", "prettyjson": "^1.2.1", + "sql-lint": "0.0.15", "standard": "^14.3.4", "stylelint": "^13.6.1", "stylelint-config-standard": "^20.0.0", - "sql-lint": "^0.0.14", "typescript": "^3.9.7" } } diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 42acb7f4..13db1ee2 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -1017,7 +1017,9 @@ moreThings() ### SQL Config file -- There is no top level _configuration file_ available at this time +- `.github/linters/.sql-config.json` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.sql-json` ### SQL disable single line diff --git a/lib/linter.sh b/lib/linter.sh index 23da8060..6afc27dc 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -110,6 +110,9 @@ PYTHON_FLAKE8_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FLAKE8_FILE_NAME} # Ruby Vars RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules +# SQL Vars +SQL_FILE_NAME=".sql-config.json" # Name of the file +SQL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${SQL_FILE_NAME}" # Path to the SQL lint rules # Terraform Vars TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules @@ -1198,6 +1201,8 @@ GetLinterRules "PYTHON_PYLINT" GetLinterRules "PYTHON_FLAKE8" # Get Ruby rules GetLinterRules "RUBY" +# Get SQL rules +GetLinterRules "SQL" # Get Terraform rules GetLinterRules "TERRAFORM" # Get TypeScript rules @@ -1736,7 +1741,7 @@ if [ "${VALIDATE_SQL}" == "true" ]; then # Lint the SQL files # ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "SQL" "sql-lint" "sql-lint" ".*\.\(sql\)\$" "${FILE_ARRAY_SQL[@]}" + LintCodebase "SQL" "sql-lint" "sql-lint --config ${SQL_LINTER_RULES}" ".*\.\(sql\)\$" "${FILE_ARRAY_SQL[@]}" fi ##################### diff --git a/lib/worker.sh b/lib/worker.sh index d1896434..a64a67cb 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -603,7 +603,7 @@ function RunTestCases() { TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" TestCodebase "STATES" "asl-validator" "asl-validator --json-path" ".*\.\(json\)\$" "states" - TestCodebase "SQL" "sql-lint" "sql-lint" ".*\.\(sql\)\$" "sql" + TestCodebase "SQL" "sql-lint" "sql-lint --config ${SQL_LINTER_RULES}" ".*\.\(sql\)\$" "sql" TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" TestCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan -f" ".*\.\(tf\)\$" "terraform_terrascan" TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript"