eslint-plugin-security 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.eslint-doc-generatorrc.js +9 -0
  2. package/.eslintrc +23 -5
  3. package/.github/ISSUE_TEMPLATE/bug-report.yml +85 -0
  4. package/.github/ISSUE_TEMPLATE/new-rule.yml +39 -0
  5. package/.github/ISSUE_TEMPLATE/rule-change.yml +61 -0
  6. package/.github/workflows/ci.yml +13 -5
  7. package/.github/workflows/pr.yml +6 -2
  8. package/.github/workflows/release-please.yml +39 -0
  9. package/.markdownlint.json +4 -0
  10. package/.markdownlintignore +3 -0
  11. package/.prettierignore +1 -0
  12. package/CHANGELOG.md +70 -15
  13. package/README.md +39 -81
  14. package/docs/bypass-connect-csrf-protection-by-abusing.md +3 -3
  15. package/docs/rules/detect-bidi-characters.md +50 -0
  16. package/docs/rules/detect-buffer-noassert.md +9 -0
  17. package/docs/rules/detect-child-process.md +9 -0
  18. package/docs/rules/detect-disable-mustache-escape.md +9 -0
  19. package/docs/rules/detect-eval-with-expression.md +7 -0
  20. package/docs/rules/detect-new-buffer.md +5 -0
  21. package/docs/rules/detect-no-csrf-before-method-override.md +9 -0
  22. package/docs/rules/detect-non-literal-fs-filename.md +7 -0
  23. package/docs/rules/detect-non-literal-regexp.md +7 -0
  24. package/docs/rules/detect-non-literal-require.md +7 -0
  25. package/docs/rules/detect-object-injection.md +7 -0
  26. package/docs/rules/detect-possible-timing-attacks.md +5 -0
  27. package/docs/rules/detect-pseudoRandomBytes.md +5 -0
  28. package/docs/rules/detect-unsafe-regex.md +7 -0
  29. package/docs/the-dangers-of-square-bracket-notation.md +11 -11
  30. package/index.js +9 -6
  31. package/package.json +17 -9
  32. package/rules/detect-bidi-characters.js +101 -0
  33. package/rules/detect-buffer-noassert.js +3 -3
  34. package/rules/detect-child-process.js +29 -20
  35. package/rules/detect-disable-mustache-escape.js +5 -5
  36. package/rules/detect-eval-with-expression.js +5 -5
  37. package/rules/detect-new-buffer.js +6 -6
  38. package/rules/detect-no-csrf-before-method-override.js +3 -3
  39. package/rules/detect-non-literal-fs-filename.js +71 -23
  40. package/rules/detect-non-literal-regexp.js +2 -2
  41. package/rules/detect-non-literal-require.js +3 -3
  42. package/rules/detect-object-injection.js +4 -4
  43. package/rules/detect-possible-timing-attacks.js +6 -6
  44. package/rules/detect-pseudoRandomBytes.js +2 -2
  45. package/rules/detect-unsafe-regex.js +8 -8
  46. package/test/detect-bidi-characters.js +74 -0
  47. package/test/detect-child-process.js +115 -4
  48. package/test/detect-disable-mustache-escape.js +3 -3
  49. package/test/detect-eval-with-expression.js +4 -4
  50. package/test/detect-new-buffer.js +4 -4
  51. package/test/detect-no-csrf-before-method-override.js +3 -3
  52. package/test/detect-non-literal-fs-filename.js +135 -8
  53. package/test/detect-non-literal-regexp.js +5 -5
  54. package/test/detect-non-literal-require.js +5 -5
  55. package/test/detect-object-injection.js +3 -3
  56. package/test/detect-possible-timing-attacks.js +8 -8
  57. package/test/detect-pseudoRandomBytes.js +3 -3
  58. package/test/detect-unsafe-regexp.js +8 -8
  59. package/test/utils/import-utils.js +172 -0
  60. package/{rules → utils}/data/fsFunctionData.json +0 -0
  61. package/utils/import-utils.js +196 -0
@@ -0,0 +1,9 @@
1
+ const { format } = require('prettier');
2
+ const prettierRC = require('./.prettierrc.json');
3
+
4
+ /** @type {import('eslint-doc-generator').GenerateOptions} */
5
+ const config = {
6
+ postprocess: (doc) => format(doc, { ...prettierRC, parser: 'markdown' }),
7
+ };
8
+
9
+ module.exports = config;
package/.eslintrc CHANGED
@@ -1,13 +1,31 @@
1
1
  {
2
- "extends": [
3
- "eslint:recommended",
4
- "prettier"
5
- ],
2
+ "extends": ["eslint:recommended", "prettier", "plugin:eslint-plugin/recommended"],
6
3
  "parserOptions": {
7
4
  "ecmaVersion": "latest"
8
5
  },
9
6
  "env": {
10
7
  "node": true,
11
8
  "es2020": true
12
- }
9
+ },
10
+ "rules": {
11
+ "eslint-plugin/prefer-message-ids": "off", // TODO: enable
12
+ "eslint-plugin/require-meta-docs-description": ["error", { "pattern": "^(Detects|Enforces|Requires|Disallows) .+\\.$" }],
13
+ "eslint-plugin/require-meta-docs-url": [
14
+ "error",
15
+ {
16
+ "pattern": "https://github.com/eslint-community/eslint-plugin-security/blob/main/docs/rules/{{name}}.md"
17
+ }
18
+ ],
19
+ "eslint-plugin/require-meta-schema": "off", // TODO: enable
20
+ "eslint-plugin/require-meta-type": "off" // TODO: enable
21
+ },
22
+ "overrides": [
23
+ {
24
+ "files": ["test/**/*.js"],
25
+ "globals": {
26
+ "describe": "readonly",
27
+ "it": "readonly"
28
+ }
29
+ }
30
+ ]
13
31
  }
@@ -0,0 +1,85 @@
1
+ name: "\U0001F41E Report a problem"
2
+ description: 'Report an issue with a rule'
3
+ title: 'Bug: (fill in)'
4
+ labels:
5
+ - bug
6
+ - 'repro:needed'
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: By opening an issue, you agree to abide by the [Open JS Foundation Code of Conduct](https://eslint.org/conduct).
11
+ - type: input
12
+ attributes:
13
+ label: What version of eslint-plugin-security are you using?
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ attributes:
18
+ label: ESLint Environment
19
+ description: |
20
+ Please tell us about how you're running ESLint (Run `npx eslint --env-info`.)
21
+ value: |
22
+ Node version:
23
+ npm version:
24
+ Local ESLint version:
25
+ Global ESLint version:
26
+ Operating System:
27
+ validations:
28
+ required: true
29
+ - type: dropdown
30
+ attributes:
31
+ label: What parser are you using?
32
+ description: |
33
+ Please keep in mind that some problems are parser-specific.
34
+ options:
35
+ - 'Default (Espree)'
36
+ - '@typescript-eslint/parser'
37
+ - '@babel/eslint-parser'
38
+ - 'vue-eslint-parser'
39
+ - '@angular-eslint/template-parser'
40
+ - Other
41
+ validations:
42
+ required: true
43
+ - type: textarea
44
+ attributes:
45
+ label: What did you do?
46
+ description: |
47
+ Please include a *minimal* reproduction case. If possible, include a link to a reproduction of the problem in the [ESLint demo](https://eslint.org/demo). Otherwise, include source code, configuration file(s), and any other information about how you're using ESLint. You can use Markdown in this field.
48
+ value: |
49
+ <details>
50
+ <summary>Configuration</summary>
51
+
52
+ ```
53
+ <!-- Paste your configuration here -->
54
+ ```
55
+ </details>
56
+
57
+ ```js
58
+ <!-- Paste your code here -->
59
+ ```
60
+ validations:
61
+ required: true
62
+ - type: textarea
63
+ attributes:
64
+ label: What did you expect to happen?
65
+ description: |
66
+ You can use Markdown in this field.
67
+ validations:
68
+ required: true
69
+ - type: textarea
70
+ attributes:
71
+ label: What actually happened?
72
+ description: |
73
+ Please copy-paste the actual ESLint output. You can use Markdown in this field.
74
+ validations:
75
+ required: true
76
+ - type: checkboxes
77
+ attributes:
78
+ label: Participation
79
+ options:
80
+ - label: I am willing to submit a pull request for this issue.
81
+ required: false
82
+ - type: textarea
83
+ attributes:
84
+ label: Additional comments
85
+ description: Is there anything else that's important for the team to know?
@@ -0,0 +1,39 @@
1
+ name: "\U0001F680 Propose a new rule"
2
+ description: 'Propose a new rule to be added to the plugin'
3
+ title: 'New Rule: (fill in)'
4
+ labels:
5
+ - rule
6
+ - feature
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: By opening an issue, you agree to abide by the [Open JS Foundation Code of Conduct](https://eslint.org/conduct).
11
+ - type: input
12
+ attributes:
13
+ label: Rule details
14
+ description: What should the new rule do?
15
+ validations:
16
+ required: true
17
+ - type: input
18
+ attributes:
19
+ label: Related CVE
20
+ description: We only accept new rules that have a published [CVE](https://www.redhat.com/en/topics/security/what-is-cve).
21
+ validations:
22
+ required: true
23
+ - type: textarea
24
+ attributes:
25
+ label: Example code
26
+ description: Please provide some example JavaScript code that this rule will warn about. This field will render as JavaScript.
27
+ render: js
28
+ validations:
29
+ required: true
30
+ - type: checkboxes
31
+ attributes:
32
+ label: Participation
33
+ options:
34
+ - label: I am willing to submit a pull request to implement this rule.
35
+ required: false
36
+ - type: textarea
37
+ attributes:
38
+ label: Additional comments
39
+ description: Is there anything else that's important for the team to know?
@@ -0,0 +1,61 @@
1
+ name: "\U0001F4DD Request a rule change"
2
+ description: 'Request a change to an existing rule'
3
+ title: 'Rule Change: (fill in)'
4
+ labels:
5
+ - enhancement
6
+ - rule
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: By opening an issue, you agree to abide by the [Open JS Foundation Code of Conduct](https://eslint.org/conduct).
11
+ - type: input
12
+ attributes:
13
+ label: What rule do you want to change?
14
+ validations:
15
+ required: true
16
+ - type: dropdown
17
+ attributes:
18
+ label: What change to do you want to make?
19
+ options:
20
+ - Generate more warnings
21
+ - Generate fewer warnings
22
+ - Implement autofix
23
+ - Implement suggestions
24
+ validations:
25
+ required: true
26
+ - type: dropdown
27
+ attributes:
28
+ label: How do you think the change should be implemented?
29
+ options:
30
+ - A new option
31
+ - A new default behavior
32
+ - Other
33
+ validations:
34
+ required: true
35
+ - type: textarea
36
+ attributes:
37
+ label: Example code
38
+ description: Please provide some example code that this change will affect. This field will render as JavaScript.
39
+ render: js
40
+ validations:
41
+ required: true
42
+ - type: textarea
43
+ attributes:
44
+ label: What does the rule currently do for this code?
45
+ validations:
46
+ required: true
47
+ - type: textarea
48
+ attributes:
49
+ label: What will the rule do after it's changed?
50
+ validations:
51
+ required: true
52
+ - type: checkboxes
53
+ attributes:
54
+ label: Participation
55
+ options:
56
+ - label: I am willing to submit a pull request to implement this change.
57
+ required: false
58
+ - type: textarea
59
+ attributes:
60
+ label: Additional comments
61
+ description: Is there anything else that's important for the team to know?
@@ -9,9 +9,13 @@ jobs:
9
9
  lint:
10
10
  name: Lint
11
11
  runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
12
14
  steps:
13
- - uses: actions/checkout@v2
14
- - uses: actions/setup-node@v2
15
+ - uses: actions/checkout@v3
16
+ with:
17
+ persist-credentials: false
18
+ - uses: actions/setup-node@v3
15
19
  with:
16
20
  node-version: '16.x'
17
21
 
@@ -26,17 +30,21 @@ jobs:
26
30
  strategy:
27
31
  matrix:
28
32
  os: [ubuntu-latest]
29
- node: [17.x, 16.x, 14.x, 12.x, '12.22.0']
33
+ node: [18.x, 16.x, 14.x, 12.x, '12.22.0']
30
34
  include:
31
35
  - os: windows-latest
32
36
  node: '16.x'
33
37
  - os: macOS-latest
34
38
  node: '16.x'
35
39
  runs-on: ${{ matrix.os }}
40
+ permissions:
41
+ contents: read
36
42
  steps:
37
- - uses: actions/checkout@v2
43
+ - uses: actions/checkout@v3
44
+ with:
45
+ persist-credentials: false
38
46
 
39
- - uses: actions/setup-node@v2
47
+ - uses: actions/setup-node@v3
40
48
  with:
41
49
  node-version: ${{ matrix.node }}
42
50
 
@@ -5,9 +5,13 @@ jobs:
5
5
  conventional:
6
6
  name: Conventional PR
7
7
  runs-on: ubuntu-latest
8
+ permissions:
9
+ contents: read
8
10
  steps:
9
- - uses: actions/checkout@v2
10
- - uses: actions/setup-node@v2
11
+ - uses: actions/checkout@v3
12
+ with:
13
+ persist-credentials: false
14
+ - uses: actions/setup-node@v3
11
15
  - uses: beemojs/conventional-pr-action@v2
12
16
  env:
13
17
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,39 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - main
5
+ name: release-please
6
+ jobs:
7
+ release-please:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: GoogleCloudPlatform/release-please-action@v2
11
+ id: release
12
+ with:
13
+ release-type: node
14
+ package-name: test-release-please
15
+ # The logic below handles the npm publication:
16
+ - uses: actions/checkout@v3
17
+ # these if statements ensure that a publication only occurs when
18
+ # a new release is created:
19
+ if: ${{ steps.release.outputs.release_created }}
20
+ - uses: actions/setup-node@v3
21
+ with:
22
+ node-version: 16
23
+ registry-url: 'https://registry.npmjs.org'
24
+ if: ${{ steps.release.outputs.release_created }}
25
+ - run: npm ci
26
+ if: ${{ steps.release.outputs.release_created }}
27
+ - run: npm publish
28
+ env:
29
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
30
+ if: ${{ steps.release.outputs.release_created }}
31
+
32
+ # Tweets out release announcement
33
+ - run: 'npx @humanwhocodes/tweet "${{ github.event.repository.full_name }} v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}"'
34
+ if: ${{ steps.release.outputs.release_created }}
35
+ env:
36
+ TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
37
+ TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
38
+ TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
39
+ TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
@@ -0,0 +1,4 @@
1
+ {
2
+ "line-length": false,
3
+ "no-inline-html": { "allowed_elements": ["kbd"] }
4
+ }
@@ -0,0 +1,3 @@
1
+ CHANGELOG.md
2
+ LICENSE
3
+ node_modules
@@ -0,0 +1 @@
1
+ /CHANGELOG.md
package/CHANGELOG.md CHANGED
@@ -1,39 +1,94 @@
1
- # 1.4.0 / 2017-06-12
1
+ # Changelog
2
+
3
+ ## [1.7.0](https://www.github.com/eslint-community/eslint-plugin-security/compare/v1.6.0...v1.7.0) (2023-01-26)
4
+
5
+
6
+ ### Features
7
+
8
+ * improve detect-child-process rule ([#108](https://www.github.com/eslint-community/eslint-plugin-security/issues/108)) ([64ae529](https://www.github.com/eslint-community/eslint-plugin-security/commit/64ae52944a86f9d9daee769acd63ebbdfc5b6631))
9
+
10
+ ## [1.6.0](https://www.github.com/eslint-community/eslint-plugin-security/compare/v1.5.0...v1.6.0) (2023-01-11)
11
+
12
+ ### Features
13
+
14
+ * Add meta object documentation for all rules ([#79](https://www.github.com/eslint-community/eslint-plugin-security/issues/79)) ([fb1d9ef](https://www.github.com/eslint-community/eslint-plugin-security/commit/fb1d9ef56e0cf2705b9e413b483261df394c45e1))
15
+ * detect-bidi-characters rule ([#95](https://www.github.com/eslint-community/eslint-plugin-security/issues/95)) ([4294d29](https://www.github.com/eslint-community/eslint-plugin-security/commit/4294d29cca8af5c627de759919add6dd698644ba))
16
+ * **detect-non-literal-fs-filename:** change to track non-top-level `require()` as well ([#105](https://www.github.com/eslint-community/eslint-plugin-security/issues/105)) ([d3b1543](https://www.github.com/eslint-community/eslint-plugin-security/commit/d3b15435b45b9ac2ee5f0d3249f590e32369d7d2))
17
+ * extend detect non literal fs filename ([#92](https://www.github.com/eslint-community/eslint-plugin-security/issues/92)) ([08ba476](https://www.github.com/eslint-community/eslint-plugin-security/commit/08ba4764a83761f6f44cb28940923f1d25f88581))
18
+ * **non-literal-require:** support template literals ([#81](https://www.github.com/eslint-community/eslint-plugin-security/issues/81)) ([208019b](https://www.github.com/eslint-community/eslint-plugin-security/commit/208019bad4f70a142ab1f0ea7238c37cb70d1a5a))
19
+
20
+ ### Bug Fixes
21
+
22
+ * Avoid crash when exec() is passed no arguments ([7f97815](https://www.github.com/eslint-community/eslint-plugin-security/commit/7f97815accf6bcd87de73c32a967946b1b3b0530)), closes [#82](https://www.github.com/eslint-community/eslint-plugin-security/issues/82) [#23](https://www.github.com/eslint-community/eslint-plugin-security/issues/23)
23
+ * Avoid TypeError when exec stub is used with no arguments ([#97](https://www.github.com/eslint-community/eslint-plugin-security/issues/97)) ([9c18f16](https://www.github.com/eslint-community/eslint-plugin-security/commit/9c18f16187719b58cc5dfde9860344bad823db28))
24
+ * **detect-child-process:** false positive for destructuring with `exec` ([#102](https://www.github.com/eslint-community/eslint-plugin-security/issues/102)) ([657921a](https://www.github.com/eslint-community/eslint-plugin-security/commit/657921a93f6f73c0de6113e497b22e7cf079f520))
25
+ * **detect-child-process:** false positives for destructuring `spawn` ([#103](https://www.github.com/eslint-community/eslint-plugin-security/issues/103)) ([fdfe37d](https://www.github.com/eslint-community/eslint-plugin-security/commit/fdfe37d667367e5fd228c26573a1791c81a044d2))
26
+ * Incorrect method name in detect-buffer-noassert. ([313c0c6](https://www.github.com/eslint-community/eslint-plugin-security/commit/313c0c693f48aa85d0c9b65a46f6c620cd10f907)), closes [#63](https://www.github.com/eslint-community/eslint-plugin-security/issues/63) [#80](https://www.github.com/eslint-community/eslint-plugin-security/issues/80)
27
+
28
+ ## 1.5.0 / 2022-04-14
29
+
30
+ - Fix avoid crash when exec() is passed no arguments
31
+ Closes [#82](https://github.com/eslint-community/eslint-plugin-security/pull/82) with ref as [#23](https://github.com/eslint-community/eslint-plugin-security/pull/23)
32
+ - Fix incorrect method name in detect-buffer-noassert
33
+ Closes [#63](https://github.com/eslint-community/eslint-plugin-security/pull/63) and [#80](https://github.com/eslint-community/eslint-plugin-security/pull/80)
34
+ - Clean up source code formatting
35
+ Fixes [#4](https://github.com/eslint-community/eslint-plugin-security/issues/4) and closes [#78](https://github.com/eslint-community/eslint-plugin-security/pull/78)
36
+ - Add release script
37
+ [Script](https://github.com/eslint-community/eslint-plugin-security/commit/0a6631ea448eb0031af7b351c85b3aa298c2e44c)
38
+ - Add non-literal require TemplateLiteral support [#81](https://github.com/eslint-community/eslint-plugin-security/pull/81)
39
+ - Add meta object documentation for all rules [#79](https://github.com/eslint-community/eslint-plugin-security/pull/79)
40
+ - Added Git pre-commit hook to format JS files
41
+ [Pre-commit hook](https://github.com/eslint-community/eslint-plugin-security/commit/e2ae2ee9ef214ca6d8f69fbcc438d230fda2bf97)
42
+ - Added yarn installation method
43
+ - Fix linting errors and step
44
+ [Lint errors](https://github.com/eslint-community/eslint-plugin-security/commit/1258118c2d07722e9fb388a672b287bb43bc73b3), [Lint step](https://github.com/eslint-community/eslint-plugin-security/commit/84f3ed3ab88427753c7ac047d0bccbe557f28aa5)
45
+ - Create workflows
46
+ Check commit message on pull requests, Set up ci on main branch
47
+ - Update test and lint commands to work cross-platform
48
+ [Commit](https://github.com/eslint-community/eslint-plugin-security/commit/d3d8e7a27894aa3f83b560f530eb49750e9ee19a)
49
+ - Merge pull request [#47](https://github.com/eslint-community/eslint-plugin-security/pull/47) from pdehaan/add-docs
50
+ Add old liftsecurity blog posts to docs/ folder
51
+ - Bumped up dependencies
52
+ - Added `package-lock.json`
53
+ - Fixed typos in README and documentation
54
+ Replaced dead links in README
55
+
56
+ ## 1.4.0 / 2017-06-12
2
57
 
3
58
  - 1.4.0
4
59
  - Stuff and things for 1.4.0 beep boop 🤖
5
- - Merge pull request [#14](https://github.com/nodesecurity/eslint-plugin-security/issues/14) from travi/recommended-example
60
+ - Merge pull request [#14](https://github.com/eslint-community/eslint-plugin-security/issues/14) from travi/recommended-example
6
61
  Add recommended ruleset to the usage example
7
- - Merge pull request [#19](https://github.com/nodesecurity/eslint-plugin-security/issues/19) from pdehaan/add-changelog
62
+ - Merge pull request [#19](https://github.com/eslint-community/eslint-plugin-security/issues/19) from pdehaan/add-changelog
8
63
  Add basic CHANGELOG.md file
9
- - Merge pull request [#17](https://github.com/nodesecurity/eslint-plugin-security/issues/17) from pdehaan/issue-16
64
+ - Merge pull request [#17](https://github.com/eslint-community/eslint-plugin-security/issues/17) from pdehaan/issue-16
10
65
  Remove filename from error output
11
66
  - Add basic CHANGELOG.md file
12
67
  - Remove filename from error output
13
68
  - Add recommended ruleset to the usage example
14
- for [#9](https://github.com/nodesecurity/eslint-plugin-security/issues/9)
15
- - Merge pull request [#10](https://github.com/nodesecurity/eslint-plugin-security/issues/10) from pdehaan/issue-9
69
+ for [#9](https://github.com/eslint-community/eslint-plugin-security/issues/9)
70
+ - Merge pull request [#10](https://github.com/eslint-community/eslint-plugin-security/issues/10) from pdehaan/issue-9
16
71
  Add 'plugin:security/recommended' config to plugin
17
- - Merge pull request [#12](https://github.com/nodesecurity/eslint-plugin-security/issues/12) from tupaschoal/patch-1
72
+ - Merge pull request [#12](https://github.com/eslint-community/eslint-plugin-security/issues/12) from tupaschoal/patch-1
18
73
  Fix broken link for detect-object-injection
19
74
  - Fix broken link for detect-object-injection
20
75
  The current link leads to a 404 page, the new one is the proper page.
21
76
  - Add 'plugin:security/recommended' config to plugin
22
77
 
23
- # 1.3.0 / 2017-02-09
78
+ ## 1.3.0 / 2017-02-09
24
79
 
25
80
  - 1.3.0
26
81
  - Merge branch 'scottnonnenberg-update-docs'
27
82
  - Fix merge conflicts because I can't figure out how to accept pr's in the right order
28
- - Merge pull request [#7](https://github.com/nodesecurity/eslint-plugin-security/issues/7) from HamletDRC/patch-1
83
+ - Merge pull request [#7](https://github.com/eslint-community/eslint-plugin-security/issues/7) from HamletDRC/patch-1
29
84
  README.md - documentation detect-new-buffer rule
30
- - Merge pull request [#8](https://github.com/nodesecurity/eslint-plugin-security/issues/8) from HamletDRC/patch-2
85
+ - Merge pull request [#8](https://github.com/eslint-community/eslint-plugin-security/issues/8) from HamletDRC/patch-2
31
86
  README.md - document detect-disable-mustache-escape rule
32
- - Merge pull request [#3](https://github.com/nodesecurity/eslint-plugin-security/issues/3) from jesusprubio/master
87
+ - Merge pull request [#3](https://github.com/eslint-community/eslint-plugin-security/issues/3) from jesusprubio/master
33
88
  A bit of love
34
89
  - README.md - document detect-disable-mustache-escape rule
35
90
  - README.md - documentation detect-new-buffer rule
36
- - Merge pull request [#6](https://github.com/nodesecurity/eslint-plugin-security/issues/6) from mathieumg/csrf-bug
91
+ - Merge pull request [#6](https://github.com/eslint-community/eslint-plugin-security/issues/6) from mathieumg/csrf-bug
37
92
  Fixed crash with `detect-no-csrf-before-method-override` rule
38
93
  - Fixed crash with `detect-no-csrf-before-method-override` rule.
39
94
  - Finishing last commit
@@ -47,17 +102,17 @@
47
102
  - A little bit of massage to readme intro
48
103
  - Add additional information to README for each rule
49
104
 
50
- # 1.2.0 / 2016-01-21
105
+ ## 1.2.0 / 2016-01-21
51
106
 
52
107
  - 1.2.0
53
108
  - updated to check for new RegExp too
54
109
 
55
- # 1.1.0 / 2016-01-06
110
+ ## 1.1.0 / 2016-01-06
56
111
 
57
112
  - 1.1.0
58
113
  - adding eslint rule to detect new buffer hotspot
59
114
 
60
- # 1.0.0 / 2015-11-15
115
+ ## 1.0.0 / 2015-11-15
61
116
 
62
117
  - updated desc
63
118
  - rules disabled by default
package/README.md CHANGED
@@ -1,14 +1,24 @@
1
1
  # eslint-plugin-security
2
2
 
3
+ [![NPM version](https://img.shields.io/npm/v/eslint-plugin-security.svg?style=flat)](https://npmjs.org/package/eslint-plugin-security)
4
+
3
5
  ESLint rules for Node Security
4
6
 
5
7
  This project will help identify potential security hotspots, but finds a lot of false positives which need triage by a human.
6
8
 
7
- ### Installation
9
+ ## Installation
10
+
11
+ ```sh
12
+ npm install --save-dev eslint-plugin-security
13
+ ```
14
+
15
+ or
8
16
 
9
- `npm install --save-dev eslint-plugin-security` or `yarn add eslint-plugin-security --dev`
17
+ ```sh
18
+ yarn add --dev eslint-plugin-security
19
+ ```
10
20
 
11
- ### Usage
21
+ ## Usage
12
22
 
13
23
  Add the following to your `.eslintrc` file:
14
24
 
@@ -29,86 +39,34 @@ Add the following to your `.eslintrc` file:
29
39
  npm run-script cont-int
30
40
  ```
31
41
 
32
- ### Tests
42
+ ## Tests
33
43
 
34
44
  ```sh
35
45
  npm test
36
46
  ```
37
47
 
38
- ### Rules
39
-
40
- #### `detect-unsafe-regex`
41
-
42
- Locates potentially unsafe regular expressions, which may take a very long time to run, blocking the event loop.
43
-
44
- More information: [Regular Expression DoS and Node.js](docs/regular-expression-dos-and-node.md)
45
-
46
- #### `detect-buffer-noassert`
47
-
48
- Detect calls to [`buffer`](https://nodejs.org/api/buffer.html) with `noAssert` flag set.
49
-
50
- From the Node.js API docs: "Setting `noAssert` to true skips validation of the `offset`. This allows the `offset` to be beyond the end of the `Buffer`."
51
-
52
- #### `detect-child-process`
53
-
54
- Detect instances of [`child_process`](https://nodejs.org/api/child_process.html) & non-literal [`exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
55
-
56
- More information: [Avoiding Command Injection in Node.js](docs/avoid-command-injection-node.md)
57
-
58
- #### `detect-disable-mustache-escape`
59
-
60
- Detects `object.escapeMarkup = false`, which can be used with some template engines to disable escaping of HTML entities. This can lead to Cross-Site Scripting (XSS) vulnerabilities.
61
-
62
- More information: [OWASP XSS](<https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)>)
63
-
64
- #### `detect-eval-with-expression`
65
-
66
- Detects `eval(variable)` which can allow an attacker to run arbitrary code inside your process.
67
-
68
- More information: [What are the security issues with eval in JavaScript?](http://security.stackexchange.com/questions/94017/what-are-the-security-issues-with-eval-in-javascript)
69
-
70
- #### `detect-no-csrf-before-method-override`
71
-
72
- Detects Express `csrf` middleware setup before `method-override` middleware. This can allow `GET` requests (which are not checked by `csrf`) to turn into `POST` requests later.
73
-
74
- More information: [Bypass Connect CSRF protection by abusing methodOverride Middleware](docs/bypass-connect-csrf-protection-by-abusing.md)
75
-
76
- #### `detect-non-literal-fs-filename`
77
-
78
- Detects variable in filename argument of `fs` calls, which might allow an attacker to access anything on your system.
79
-
80
- More information: [OWASP Path Traversal](https://www.owasp.org/index.php/Path_Traversal)
81
-
82
- #### `detect-non-literal-regexp`
83
-
84
- Detects `RegExp(variable)`, which might allow an attacker to DOS your server with a long-running regular expression.
85
-
86
- More information: [Regular Expression DoS and Node.js](docs/regular-expression-dos-and-node.md)
87
-
88
- #### `detect-non-literal-require`
89
-
90
- Detects `require(variable)`, which might allow an attacker to load and run arbitrary code, or access arbitrary files on disk.
91
-
92
- More information: [Where does Node.js and require look for modules?](http://www.bennadel.com/blog/2169-where-does-node-js-and-require-look-for-modules.htm)
93
-
94
- #### `detect-object-injection`
95
-
96
- Detects `variable[key]` as a left- or right-hand assignment operand.
97
-
98
- More information: [The Dangers of Square Bracket Notation](docs/the-dangers-of-square-bracket-notation.md)
99
-
100
- #### `detect-possible-timing-attacks`
101
-
102
- Detects insecure comparisons (`==`, `!=`, `!==` and `===`), which check input sequentially.
103
-
104
- More information: [A lesson in timing attacks](https://codahale.com/a-lesson-in-timing-attacks/)
105
-
106
- #### `detect-pseudoRandomBytes`
107
-
108
- Detects if `pseudoRandomBytes()` is in use, which might not give you the randomness you need and expect.
109
-
110
- More information: [Randombytes vs pseudorandombytes](http://stackoverflow.com/questions/18130254/randombytes-vs-pseudorandombytes)
111
-
112
- #### `detect-new-buffer`
113
-
114
- Detect instances of new Buffer(argument) where argument is any non-literal value.
48
+ ## Rules
49
+
50
+ <!-- begin auto-generated rules list -->
51
+
52
+ ⚠️ Configurations set to warn in.\
53
+ ✅ Set in the `recommended` configuration.
54
+
55
+ | Name                                  | Description | ⚠️ |
56
+ | :------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------- | :-- |
57
+ | [detect-bidi-characters](docs/rules/detect-bidi-characters.md) | Detects trojan source attacks that employ unicode bidi attacks to inject malicious code. | ✅ |
58
+ | [detect-buffer-noassert](docs/rules/detect-buffer-noassert.md) | Detects calls to "buffer" with "noAssert" flag set. | ✅ |
59
+ | [detect-child-process](docs/rules/detect-child-process.md) | Detects instances of "child_process" & non-literal "exec()" calls. | ✅ |
60
+ | [detect-disable-mustache-escape](docs/rules/detect-disable-mustache-escape.md) | Detects "object.escapeMarkup = false", which can be used with some template engines to disable escaping of HTML entities. | ✅ |
61
+ | [detect-eval-with-expression](docs/rules/detect-eval-with-expression.md) | Detects "eval(variable)" which can allow an attacker to run arbitrary code inside your process. | ✅ |
62
+ | [detect-new-buffer](docs/rules/detect-new-buffer.md) | Detects instances of new Buffer(argument) where argument is any non-literal value. | ✅ |
63
+ | [detect-no-csrf-before-method-override](docs/rules/detect-no-csrf-before-method-override.md) | Detects Express "csrf" middleware setup before "method-override" middleware. | ✅ |
64
+ | [detect-non-literal-fs-filename](docs/rules/detect-non-literal-fs-filename.md) | Detects variable in filename argument of "fs" calls, which might allow an attacker to access anything on your system. | ✅ |
65
+ | [detect-non-literal-regexp](docs/rules/detect-non-literal-regexp.md) | Detects "RegExp(variable)", which might allow an attacker to DOS your server with a long-running regular expression. | ✅ |
66
+ | [detect-non-literal-require](docs/rules/detect-non-literal-require.md) | Detects "require(variable)", which might allow an attacker to load and run arbitrary code, or access arbitrary files on disk. | ✅ |
67
+ | [detect-object-injection](docs/rules/detect-object-injection.md) | Detects "variable[key]" as a left- or right-hand assignment operand. | ✅ |
68
+ | [detect-possible-timing-attacks](docs/rules/detect-possible-timing-attacks.md) | Detects insecure comparisons (`==`, `!=`, `!==` and `===`), which check input sequentially. | ✅ |
69
+ | [detect-pseudoRandomBytes](docs/rules/detect-pseudoRandomBytes.md) | Detects if "pseudoRandomBytes()" is in use, which might not give you the randomness you need and expect. | ✅ |
70
+ | [detect-unsafe-regex](docs/rules/detect-unsafe-regex.md) | Detects potentially unsafe regular expressions, which may take a very long time to run, blocking the event loop. | ✅ |
71
+
72
+ <!-- end auto-generated rules list -->
@@ -8,7 +8,7 @@ This issue was found and reported to us by [Luca Carettoni](http://twitter.com/_
8
8
 
9
9
  Connect, methodOverride middleware
10
10
 
11
- ### Description:
11
+ ### Description
12
12
 
13
13
  **Connect's "methodOverride" middleware allows an HTTP request to override the method of the request with the value of the "\_method" post key or with the header "x-http-method-override".**
14
14
 
@@ -25,7 +25,7 @@ app.use express.methodOverride()
25
25
 
26
26
  Connect's CSRF middleware does not check csrf tokens in case of idempotent verbs (GET/HEAD/OPTIONS, see lib/middleware/csrf.js). As a result, it is possible to bypass this security control by sending a GET request with a POST MethodOverride header or key.
27
27
 
28
- ### Example:
28
+ ### Example
29
29
 
30
30
  ```sh
31
31
  GET / HTTP/1.1
@@ -33,7 +33,7 @@ GET / HTTP/1.1
33
33
  _method=POST
34
34
  ```
35
35
 
36
- ### Mitigation Factors:
36
+ ### Mitigation Factors
37
37
 
38
38
  Disable methodOverride or make sure that it takes precedence over other middleware declarations.
39
39