Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix salus failures #389

Merged
merged 4 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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