Skip to content

Commit 75d97e9

Browse files
fix: Fix opengrep config file name (#202)
1 parent 799aab5 commit 75d97e9

7 files changed

Lines changed: 34565 additions & 151 deletions

File tree

config/config.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,25 @@ func (c *ConfigType) Tools() map[string]*plugins.ToolInfo {
182182
return c.tools
183183
}
184184

185+
// toolNameAliases maps legacy tool names to their current equivalents
186+
var toolNameAliases = map[string]string{
187+
"semgrep": "opengrep",
188+
}
189+
185190
func (c *ConfigType) AddTools(configs []plugins.ToolConfig) error {
186191
// Get the plugin manager to access tool configurations
187192
pluginManager := plugins.GetPluginManager()
188193

194+
// Resolve any legacy tool name aliases on a copy to avoid mutating the caller's slice
195+
resolved := make([]plugins.ToolConfig, len(configs))
196+
copy(resolved, configs)
197+
for i := range resolved {
198+
if alias, ok := toolNameAliases[resolved[i].Name]; ok {
199+
resolved[i].Name = alias
200+
}
201+
}
202+
configs = resolved
203+
189204
// Ensure all required runtimes are present before processing tools
190205
for _, toolConfig := range configs {
191206
// Get the tool's plugin configuration to access runtime info
@@ -255,6 +270,10 @@ func (c *ConfigType) AddTools(configs []plugins.ToolConfig) error {
255270

256271
// AddToolWithDefaultVersion adds a tool with its default version to the configuration
257272
func (c *ConfigType) AddToolWithDefaultVersion(toolName string) error {
273+
if alias, ok := toolNameAliases[toolName]; ok {
274+
toolName = alias
275+
}
276+
258277
// Get the default version for the tool from plugins
259278
defaultVersions := plugins.GetToolVersions()
260279
version, ok := defaultVersions[toolName]

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

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7290,67 +7290,6 @@ rules:
72907290
exports.handler = $FUNC
72917291
- pattern: $EVENT
72927292
severity: WARNING
7293-
- id: javascript.aws-lambda.security.tainted-sql-string.tainted-sql-string
7294-
languages:
7295-
- javascript
7296-
- typescript
7297-
message: Detected user input used to manually construct a SQL string. This is usually bad practice because manual construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or modify contents of the database. Instead, use a parameterized query which is available by default in most database engines. Alternatively, consider using an object-relational mapper (ORM) such as Sequelize which will protect your queries.
7298-
metadata:
7299-
category: security
7300-
confidence: MEDIUM
7301-
cwe:
7302-
- 'CWE-89: Improper Neutralization of Special Elements used in an SQL Command (''SQL Injection'')'
7303-
cwe2021-top25: true
7304-
cwe2022-top25: true
7305-
impact: MEDIUM
7306-
likelihood: LOW
7307-
owasp:
7308-
- A01:2017 - Injection
7309-
- A03:2021 - Injection
7310-
references:
7311-
- https://owasp.org/www-community/attacks/SQL_Injection
7312-
subcategory:
7313-
- vuln
7314-
technology:
7315-
- aws-lambda
7316-
mode: taint
7317-
pattern-sinks:
7318-
- patterns:
7319-
- pattern-either:
7320-
- patterns:
7321-
- pattern-either:
7322-
- pattern: |
7323-
"$SQLSTR" + $EXPR
7324-
- pattern: |
7325-
"$SQLSTR".concat(...)
7326-
- pattern: util.format($SQLSTR, ...)
7327-
- metavariable-regex:
7328-
metavariable: $SQLSTR
7329-
regex: .*\b(?i)(select|delete|insert|create|update|alter|drop)\b.*
7330-
- patterns:
7331-
- pattern: |
7332-
`...${...}...`
7333-
- pattern-regex: |
7334-
.*\b(?i)(select|delete|insert|create|update|alter|drop)\b.*
7335-
- pattern-not-inside: |
7336-
console.$LOG(...)
7337-
pattern-sources:
7338-
- patterns:
7339-
- pattern-either:
7340-
- pattern-inside: |
7341-
exports.handler = function ($EVENT, ...) {
7342-
...
7343-
}
7344-
- pattern-inside: |
7345-
function $FUNC ($EVENT, ...) {...}
7346-
...
7347-
exports.handler = $FUNC
7348-
- pattern-inside: |
7349-
$FUNC = function ($EVENT, ...) {...}
7350-
...
7351-
exports.handler = $FUNC
7352-
- pattern: $EVENT
7353-
severity: ERROR
73547293
- id: javascript.aws-lambda.security.vm-runincontext-injection.vm-runincontext-injection
73557294
languages:
73567295
- javascript

integration-tests/init-with-token/expected/codacy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ runtimes:
44
- python@3.11.11
55
tools:
66
- eslint@8.57.0
7-
- lizard@1.17.31
8-
- opengrep@1.17.0
7+
- lizard@1.22.2
8+
- opengrep@1.21.0
99
- pmd@6.55.0
1010
- pylint@4.0.5
11-
- trivy@0.69.3
11+
- trivy@0.70.0

0 commit comments

Comments
 (0)