Skip to content

Commit 9fecada

Browse files
fix: update go version and custom rules regexTarget documentation (#373)
<!-- Thanks for contributing to 2ms by offering a pull request. --> Closes # **Proposed Changes** Update go version and custom rules regexTarget documentation <!-- Please describe the big picture of your changes here. If it fixes a bug or resolves a feature request, be sure to link to that issue. --> **Checklist** - [ ] I covered my changes with tests. - [ ] I Updated the documentation that is affected by my changes: - [ ] Change in the CLI arguments - [ ] Change in the configuration file I submit this contribution under the Apache-2.0 license.
1 parent ebeeeeb commit 9fecada

8 files changed

Lines changed: 14 additions & 6 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# and "Missing User Instruction" since 2ms container is stopped after scan
44

55
# Builder image
6-
FROM checkmarx/go:1.25.3-r0-b47cbbc1194cd0@sha256:b47cbbc1194cd0d801fe7739fca12091d610117b0d30c32b52fc900217a0821a AS builder
6+
FROM checkmarx/go:1.25.7-r0-b270bc965b34b4@sha256:b270bc965b34b4ffec624413bc1f1830c58c0abb142580ca76d42116b3b06764 AS builder
77

88
WORKDIR /app
99

@@ -20,7 +20,7 @@ COPY . .
2020
RUN GOOS=linux GOARCH=amd64 go build -buildvcs=false -ldflags="-s -w" -a -o /app/2ms .
2121

2222
# Runtime image
23-
FROM checkmarx/git:2.49.0-r2-d7ebbe7c56dc47@sha256:d7ebbe7c56dc478c08aba611c35b30689090d28605d83130ce4d1e15a84f0389
23+
FROM checkmarx/git:2.53.0-r0-dadf19ec31d471@sha256:dadf19ec31d4711eeace2763e89511693b36ba0ea5c9e12a763978b4b29ddba0
2424

2525
WORKDIR /app
2626

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ Other fields are optional and can be seen in the example bellow of a file with a
372372
allowLists: # allowed values to ignore if matched
373373
- description: Allowlist for Custom Rule
374374
matchCondition: OR # Can be AND or OR. determines whether all criteria in the allowList must match. Defaults to OR if not specified
375-
regexTarget: match - # Can be match or line. Determines whether the regexes in allowList are tested against the rule.Regex match or the full line being scanned. Defaults to "match" if not specified
375+
regexTarget: match # Specifies what to test allowList regexes against. Options: 'match', 'line', or empty/omitted.
376+
# - 'match': test against the full rule.Regex match
377+
# - 'line': test against the entire line where the secret was found
378+
# - empty/omitted: test against the secret itself (which is the first capture group from rule.Regex, or the group specified by rule.secretGroup if defined)
376379
regexes: # allowed regex patterns
377380
- (?i)(?:access(?:ibility|or)|access[_.-]?id|random[_.-]?access|api[_.-]?(?:id|name|version)|rapid|capital|[a-z0-9-]*?api[a-z0-9-]*?:jar:|author|X-MS-Exchange-Organization-Auth|Authentication-Results|(?:credentials?[_.-]?id|withCredentials)|(?:25[0-5]|2[0-4]\d|1?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}|(?:bucket|foreign|hot|idx|natural|primary|pub(?:lic)?|schema|sequence)[_.-]?key|(?:turkey)|key[_.-]?(?:alias|board|code|frame|id|length|mesh|name|pair|press(?:ed)?|ring|selector|signature|size|stone|storetype|word|up|down|left|right)|KeyVault(?:[A-Za-z]*?(?:Administrator|Reader|Contributor|Owner|Operator|User|Officer))\s*[:=]\s*['"]?[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}['"]?|key[_.-]?vault[_.-]?(?:id|name)|keyVaultToStoreSecrets|key(?:store|tab)[_.-]?(?:file|path)|issuerkeyhash|(?-i:[DdMm]onkey|[DM]ONKEY)|keying|(?:secret)[_.-]?(?:length|name|size)|UserSecretsId|(?:csrf)[_.-]?token|(?:io\.jsonwebtoken[
378381
\t]?:[

engine/validation/alibaba.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func alibabaRequest(accessKey, secretKey string) (secrets.ValidationResult, erro
6969
req.URL.RawQuery = params.Encode()
7070

7171
client := &http.Client{}
72+
// #nosec G704 -- URL is hardcoded to Alibaba API, only query params contain credentials being validated
7273
resp, err := client.Do(req)
7374
if err != nil {
7475
return secrets.UnknownResult, err

engine/validation/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func sendValidationRequest(endpoint, authorization string) (*http.Response, erro
1414

1515
// TODO: do not recreate this client for each request
1616
client := &http.Client{}
17+
// #nosec G704 -- URL is hardcoded in both github and gitlab uses, only query params contain credentials being validated
1718
resp, err := client.Do(req)
1819
if err != nil {
1920
return nil, err

engine/validation/gcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func validateGCP(s *secrets.Secret) (secrets.ValidationResult, string) {
3131
log.Warn().Err(err).Msg("Failed to validate secret")
3232
return secrets.UnknownResult, ""
3333
}
34-
3534
client := &http.Client{}
35+
// #nosec G704 -- URL is hardcoded to GCP API, only query params contain credentials being validated
3636
resp, err := client.Do(req)
3737
if err != nil {
3838
log.Warn().Err(err).Msg("Failed to validate secret")

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/checkmarx/2ms/v5
22

3-
go 1.25.6
3+
go 1.25.7
44

55
replace (
66
golang.org/x/oauth2 => golang.org/x/oauth2 v0.30.0

lib/utils/http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func HttpRequest(method, url string, authorization IAuthorizationHeader, retry R
4040

4141
// TODO: do not recreate this client for each request
4242
client := &http.Client{}
43+
// #nosec G704 -- URL is intentionally user-provided for plugin API calls to external services
4344
response, err := client.Do(request)
4445
if err != nil {
4546
return nil, response, fmt.Errorf("unable to send http request %w", err)

plugins/confluence_client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ func (c *httpConfluenceClient) discoverCloudID(ctx context.Context) (string, err
190190
if err != nil {
191191
return "", fmt.Errorf("build tenant_info request: %w", err)
192192
}
193+
// #nosec G704 -- URL is intentionally user-provided for plugin API calls to external services
193194
resp, err := c.httpClient.Do(req)
194195
if err != nil {
195196
return "", ErrBaseURLInvalidOrUnreachable
@@ -475,6 +476,7 @@ func (c *httpConfluenceClient) getJSON(ctx context.Context, reqURL string) ([]by
475476
}
476477
req.Header.Set("Accept", "application/json")
477478

479+
// #nosec G704 -- URL is intentionally user-provided for plugin API calls to external services
478480
resp, err := c.httpClient.Do(req)
479481
if err != nil {
480482
return nil, nil, fmt.Errorf("http get: %w", err)
@@ -525,7 +527,7 @@ func (c *httpConfluenceClient) getJSONStream(ctx context.Context, reqURL string)
525527
req.SetBasicAuth(c.username, c.token)
526528
}
527529
req.Header.Set("Accept", "application/json")
528-
530+
// #nosec G704 -- URL is intentionally user-provided for plugin API calls to external services
529531
resp, err := c.httpClient.Do(req)
530532
if err != nil {
531533
return nil, nil, fmt.Errorf("http get: %w", err)

0 commit comments

Comments
 (0)