Formatting problems(CI was not passing)

This commit is contained in:
Dimitar Banchev 2024-08-30 11:50:08 +02:00 committed by Cosmin Cojocar
parent 7f8f654235
commit b4c746962f
3 changed files with 26 additions and 32 deletions

View file

@ -1521,7 +1521,6 @@ var _ = Describe("Analyzer", func() {
Expect(controlIssues[0].Suppressions[0].Justification).To(Equal("Globally suppressed."))
})
It("should not report an error if the analyzer is excluded", func() {
sample := testutils.SampleCodeG407[0]
source := sample.Code[0]

View file

@ -57,8 +57,8 @@ func runHardCodedNonce(pass *analysis.Pass) (interface{}, error) {
"crypto/cipher.NewOFB": {2, 1},
}
var issues []*issue.Issue
var ssaPkgFunctions = ssaResult.SSA.SrcFuncs
var savedArgsFromFunctions = *iterateAndGetArgsFromTrackedFunctions(ssaPkgFunctions, &calls)
ssaPkgFunctions := ssaResult.SSA.SrcFuncs
savedArgsFromFunctions := *iterateAndGetArgsFromTrackedFunctions(ssaPkgFunctions, &calls)
for _, savedArg := range savedArgsFromFunctions {
tmp, err := raiseIssue(savedArg, &calls, ssaPkgFunctions, pass, "")
@ -148,14 +148,12 @@ func raiseIssue(val *ssa.Value, funcsToTrack *map[string][]int, ssaFuncs []*ssa.
// Iterate through all places that use the `variable` argument and check if it's used in one of the tracked functions
func iterateThroughReferrers(variable *ssa.Value, funcsToTrack *map[string][]int, analyzerID string, issueDescription string, fileSet *token.FileSet, issueSeverity issue.Score, issueConfidence issue.Score) ([]*issue.Issue, error) {
if funcsToTrack == nil || variable == nil || analyzerID == "" || issueDescription == "" || fileSet == nil {
return nil, errors.New("received a nil object")
}
var gosecIssues []*issue.Issue = nil
// Go trough all functions that use the given arg variable
for _, referrer := range *(*variable).Referrers() {
// Iterate trough the functions we are interested
for trackedFunc := range *funcsToTrack {

View file

@ -2,11 +2,9 @@ package testutils
import "github.com/securego/gosec/v2"
var (
// SampleCodeG407 - Use of hardcoded nonce/IV
SampleCodeG407 = []CodeSample{
{[]string{`package main
// SampleCodeG407 - Use of hardcoded nonce/IV
var SampleCodeG407 = []CodeSample{
{[]string{`package main
import (
"crypto/aes"
@ -25,7 +23,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -45,7 +43,7 @@ func main() {
`}, 0, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -79,7 +77,7 @@ func main() {
}
`}, 0, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -97,7 +95,7 @@ func main() {
}`}, 1, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -115,7 +113,7 @@ func main() {
}`}, 1, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -134,7 +132,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -154,7 +152,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -174,7 +172,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -195,7 +193,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -229,7 +227,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -262,7 +260,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -282,7 +280,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -302,7 +300,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -323,7 +321,7 @@ func main() {
}`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -344,7 +342,7 @@ func main() {
}`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -367,7 +365,7 @@ func main() {
}`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -391,7 +389,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -408,7 +406,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -427,7 +425,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -453,7 +451,7 @@ func main() {
}
`}, 0, gosec.NewConfig()},
{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
@ -472,5 +470,4 @@ func main() {
}
`}, 1, gosec.NewConfig()},
}
)
}