Skip to content

Commit

Permalink
Merge pull request #389 from DopplerHQ/nic/salus-fix
Browse files Browse the repository at this point in the history
Fix salus failures
  • Loading branch information
nmanoogian authored May 1, 2023
2 parents c85ebe7 + 3731016 commit ebd6847
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/salus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ on:
name: Salus security scan

jobs:
semgrep:
runs-on: ubuntu-latest
name: Semgrep
steps:
- uses: actions/checkout@v2
- name: Scan
id: scan
run: |
set -eo pipefail;
python3 -m pip install semgrep;
semgrep scan --error --config https://semgrep.dev/p/trailofbits --config semgrep_configs
salus_scan_job:
runs-on: ubuntu-latest
name: Salus Security Scan
steps:
- uses: actions/checkout@v2
- name: Salus Scan
id: salus_scan
uses: federacy/scan-action@0.1.3
uses: federacy/scan-action@0.1.4
env:
SALUS_CONFIGURATION: "file://salus-config.yaml"
with:
Expand Down
12 changes: 10 additions & 2 deletions pkg/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ func performRequest(req *http.Request, verifyTLS bool) (int, http.Header, []byte
resp, err := client.Do(req) // nosemgrep: trailofbits.go.invalid-usage-of-modified-variable.invalid-usage-of-modified-variable
if err != nil {
if resp != nil {
defer resp.Body.Close()
defer func() {
if closeErr := resp.Body.Close(); closeErr != nil {
utils.LogDebug(closeErr.Error())
}
}()
}

utils.LogDebug(err.Error())
Expand Down Expand Up @@ -264,7 +268,11 @@ func performRequest(req *http.Request, verifyTLS bool) (int, http.Header, []byte
})

if response != nil {
defer response.Body.Close()
defer func() {
if closeErr := response.Body.Close(); closeErr != nil {
utils.LogDebug(closeErr.Error())
}
}()
}

if requestErr != nil && response == nil {
Expand Down
23 changes: 9 additions & 14 deletions salus-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@ reports:
format: txt

# All scanners to execute, or the String value "all"/"none"
active_scanners: "all"
active_scanners:
- Gosec
- PatternSearch
- RepoNotEmpty
- GoOSV
- GoVersionScanner
- GoPackageScanner
- ReportGoDep
- Trufflehog

# All scanners that will exit non-zero if they fail, or the String value "all"/"none"
enforced_scanners: "all"

scanner_configs:
Semgrep:
matches:
- config: https://semgrep.dev/p/trailofbits
forbidden: true
- config: semgrep_configs/print.yaml
forbidden: true
exclude:
- pkg/printer
- pkg/utils/log.go
- config: semgrep_configs/writefile.yaml
forbidden: true
exclude:
- pkg/utils/io.go
GoVersionScanner:
error:
min_version: '1.18.0'
4 changes: 4 additions & 0 deletions semgrep_configs/print.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ rules:
- pattern-regex: fmt\.Print[a-z]*
- pattern-regex: fmt\.Fprint[a-z]*
severity: ERROR
paths:
exclude:
- /pkg/printer
- /pkg/utils/log.go
3 changes: 3 additions & 0 deletions semgrep_configs/writefile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ rules:
pattern-either:
- pattern: ioutil.WriteFile
severity: ERROR
paths:
exclude:
- /pkg/utils/io.go

0 comments on commit ebd6847

Please sign in to comment.