Skip to content

Commit aa86ee2

Browse files
committed
fix: semgrep rules updated CF-1809
1 parent b86f8b5 commit aa86ee2

File tree

6 files changed

+27400
-96646
lines changed

6 files changed

+27400
-96646
lines changed

codacy-client/client.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,19 @@ func GetDefaultToolPatternsConfig(initFlags domain.InitFlags, toolUUID string, o
177177
baseURL += "?enabled=true"
178178
}
179179

180-
return getAllPages(baseURL, initFlags, parseDefaultPatternConfigurations)
180+
allPaterns, err := getAllPages(baseURL, initFlags, parseDefaultPatternConfigurations)
181+
if err != nil {
182+
return nil, err
183+
}
184+
185+
onlyRecommendedPatterns := make([]domain.PatternConfiguration, 0)
186+
for _, pattern := range allPaterns {
187+
if pattern.PatternDefinition.Enabled {
188+
onlyRecommendedPatterns = append(onlyRecommendedPatterns, pattern)
189+
}
190+
}
191+
192+
return onlyRecommendedPatterns, nil
181193
}
182194

183195
// GetRepositoryToolPatterns fetches the patterns for a tool in a repository

integration-tests/config-discover/expected/tools-configs/semgrep.yaml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29501,6 +29501,43 @@ rules:
2950129501
}
2950229502
- focus-metavariable: $SECRET
2950329503
severity: WARNING
29504+
- id: terraform.aws.security.aws-provisioner-exec.aws-provisioner-exec
29505+
languages:
29506+
- terraform
29507+
message: Provisioners are a tool of last resort and should be avoided where possible. Provisioner behavior cannot be mapped by Terraform as part of a plan, and execute arbitrary shell commands by design.
29508+
metadata:
29509+
category: security
29510+
confidence: HIGH
29511+
cwe:
29512+
- 'CWE-77: Improper Neutralization of Special Elements used in a Command (''Command Injection'')'
29513+
- 'CWE-94: Improper Control of Generation of Code (''Code Injection'')'
29514+
impact: MEDIUM
29515+
likelihood: HIGH
29516+
owasp:
29517+
- A03:2021 - Injection
29518+
- A01:2017 - Injection
29519+
references:
29520+
- https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec
29521+
- https://developer.hashicorp.com/terraform/language/resources/provisioners/local-exec
29522+
subcategory:
29523+
- guardrail
29524+
technology:
29525+
- terraform
29526+
patterns:
29527+
- pattern-either:
29528+
- pattern: |
29529+
provisioner "remote-exec" {
29530+
...
29531+
}
29532+
- pattern: |
29533+
provisioner "local-exec" {
29534+
...
29535+
}
29536+
- pattern-inside: |
29537+
resource "aws_instance" "..." {
29538+
...
29539+
}
29540+
severity: WARNING
2950429541
- id: terraform.aws.security.aws-rds-backup-no-retention.aws-rds-backup-no-retention
2950529542
languages:
2950629543
- hcl
@@ -34374,8 +34411,12 @@ rules:
3437434411
- A3:2017 Sensitive Data Exposure
3437534412
options:
3437634413
generic_ellipsis_max_span: 0
34377-
pattern: |
34378-
$PASSWORD VARCHAR2($LENGTH) := $...VALUE;
34414+
patterns:
34415+
- pattern: |
34416+
$PASSWORD VARCHAR2($LENGTH) := $...VALUE;
34417+
- metavariable-regex:
34418+
metavariable: $PASSWORD
34419+
regex: (?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd).*
3437934420
severity: ERROR
3438034421
- id: codacy.generic.plsql.resource-injection
3438134422
languages:

integration-tests/init-with-token/expected/tools-configs/semgrep.yaml

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
rules:
2+
- id: bash.lang.correctness.unquoted-expansion.unquoted-variable-expansion-in-command
3+
languages:
4+
- bash
5+
message: Variable expansions must be double-quoted so as to prevent being split into multiple pieces according to whitespace or whichever separator is specified by the IFS variable. If you really wish to split the variable's contents, you may use a variable that starts with an underscore e.g. $_X instead of $X, and semgrep will ignore it. If what you need is an array, consider using a proper bash array.
6+
metadata:
7+
category: correctness
8+
technology:
9+
- bash
10+
patterns:
11+
- pattern-either:
12+
- pattern: |
13+
... ${$VAR} ...
14+
- pattern: |
15+
... ...${$VAR}... ...
16+
- metavariable-regex:
17+
metavariable: $VAR
18+
regex: '[*@0-9]|[A-Za-z].*'
19+
severity: INFO
220
- id: clojure.lang.security.use-of-md5.use-of-md5
321
languages:
422
- clojure
@@ -8,20 +26,20 @@ rules:
826
category: security
927
confidence: HIGH
1028
cwe:
11-
- 'CWE-328: Use of Weak Hash'
29+
- 'CWE-328: Use of Weak Hash'
1230
impact: HIGH
1331
likelihood: MEDIUM
1432
owasp:
15-
- A03:2017 - Sensitive Data Exposure
16-
- A02:2021 - Cryptographic Failures
33+
- A03:2017 - Sensitive Data Exposure
34+
- A02:2021 - Cryptographic Failures
1735
references:
18-
- https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html
19-
- https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
36+
- https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html
37+
- https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
2038
source-rule-url: https://github.com/clj-holmes/clj-holmes-rules/blob/main/security/weak-hash-function-md5.yml
2139
subcategory:
22-
- vuln
40+
- vuln
2341
technology:
24-
- clojure
42+
- clojure
2543
pattern-either:
2644
- pattern: (MessageDigest/getInstance "MD5")
2745
- pattern: (MessageDigest/getInstance MessageDigestAlgorithms/MD5)
@@ -30,6 +48,19 @@ rules:
3048
- pattern: (java.security.MessageDigest/getInstance MessageDigestAlgorithms/MD5)
3149
- pattern: (java.security.MessageDigest/getInstance org.apache.commons.codec.digest.MessageDigestAlgorithms/MD5)
3250
severity: WARNING
51+
- fix: Bitwise.bnot($VAL)
52+
id: elixir.lang.best-practice.deprecated-bnot-operator.deprecated_bnot_operator
53+
languages:
54+
- elixir
55+
message: The bitwise operator (`^^^`) is already deprecated. Please use `Bitwise.bnot($VAL)` instead.
56+
metadata:
57+
category: best-practice
58+
references:
59+
- https://github.com/elixir-lang/elixir/commit/f1b9d3e818e5bebd44540f87be85979f24b9abfc
60+
technology:
61+
- elixir
62+
pattern: ~~~$VAL
63+
severity: WARNING
3364
- id: codacy.generic.plsql.empty-strings
3465
languages:
3566
- generic

0 commit comments

Comments
 (0)