|
42 | 42 |
|
43 | 43 | If this is a test fixture or example: |
44 | 44 | - Add comment: # nosemgrep: generic-hardcoded-secret |
45 | | - - Or use obviously fake values: password = "REPLACE_ME" |
| 45 | + - Or use obviously fake values: password = "FAKE" |
46 | 46 | patterns: |
47 | 47 | - pattern-regex: |- |
48 | 48 | (?i)(password|passwd|pwd|secret|token|api[_-]?key|private[_-]?key)\s*[:=]+\s*["'][^"']{8,}["'] |
|
71 | 71 | - Enable AWS CloudTrail for key usage monitoring |
72 | 72 |
|
73 | 73 | False Positive: If this is documentation/example, replace with: |
74 | | - AKIAIOSFODNN7EXAMPLE (official AWS example key) |
| 74 | + AKIA...EXAMPLE (redacted AWS example key) |
75 | 75 | pattern-regex: 'AKIA[0-9A-Z]{16}' |
76 | 76 | metadata: |
77 | 77 | cwe: "CWE-798" |
@@ -773,6 +773,10 @@ rules: |
773 | 773 | patterns: |
774 | 774 | - pattern-not: ${{ secrets.$SECRET }} |
775 | 775 | - pattern-not: ${{ env.$ENV }} |
| 776 | + paths: |
| 777 | + include: |
| 778 | + - "**/.github/workflows/*.yml" |
| 779 | + - "**/.github/workflows/*.yaml" |
776 | 780 | metadata: |
777 | 781 | cwe: "CWE-798" |
778 | 782 | category: "security" |
@@ -1047,13 +1051,25 @@ rules: |
1047 | 1051 | patterns: |
1048 | 1052 | - pattern-either: |
1049 | 1053 | - pattern: | |
1050 | | - const $VAR = "password" |
1051 | | - - pattern: | |
1052 | | - const $VAR = "secret" |
| 1054 | + $VAR := $VALUE |
1053 | 1055 | - pattern: | |
1054 | | - const $VAR = "token" |
| 1056 | + const $VAR = $VALUE |
1055 | 1057 | - pattern: | |
1056 | | - var $VAR = "Bearer ..." |
| 1058 | + var $VAR = $VALUE |
| 1059 | + - metavariable-regex: |
| 1060 | + metavariable: $VAR |
| 1061 | + regex: (?i)(password|passwd|secret|token|api[_-]?key|private[_-]?key|credentials?) |
| 1062 | + - metavariable-regex: |
| 1063 | + metavariable: $VALUE |
| 1064 | + regex: '"[^"]{8,}"' |
| 1065 | + - pattern-not: | |
| 1066 | + $VAR := os.Getenv("...") |
| 1067 | + - pattern-not: | |
| 1068 | + var $VAR = os.Getenv("...") |
| 1069 | + - pattern-not: | |
| 1070 | + const $VAR = os.Getenv("...") |
| 1071 | + - pattern-not: | |
| 1072 | + $VAR, $_ := os.LookupEnv("...") |
1057 | 1073 | metadata: |
1058 | 1074 | cwe: "CWE-798" |
1059 | 1075 | owasp: "A07:2021" |
|
0 commit comments