Skip to content

Commit

Permalink
Formatting problems(CI was not passing)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitar Banchev authored and ccojocar committed Aug 30, 2024
1 parent 7f8f654 commit b4c7469
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 32 deletions.
1 change: 0 additions & 1 deletion analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 2 additions & 4 deletions analyzers/hardcodedNonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down Expand Up @@ -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 {

Expand Down
51 changes: 24 additions & 27 deletions testutils/g407_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -25,7 +23,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -45,7 +43,7 @@ func main() {
`}, 0, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand Down Expand Up @@ -79,7 +77,7 @@ func main() {
}
`}, 0, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -97,7 +95,7 @@ func main() {
}`}, 1, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -115,7 +113,7 @@ func main() {
}`}, 1, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -134,7 +132,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -154,7 +152,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -174,7 +172,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -195,7 +193,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand Down Expand Up @@ -229,7 +227,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand Down Expand Up @@ -262,7 +260,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -282,7 +280,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -302,7 +300,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -323,7 +321,7 @@ func main() {
}`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -344,7 +342,7 @@ func main() {
}`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -367,7 +365,7 @@ func main() {
}`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -391,7 +389,7 @@ func main() {
}
`}, 2, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -408,7 +406,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -427,7 +425,7 @@ func main() {
}
`}, 1, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -453,7 +451,7 @@ func main() {
}
`}, 0, gosec.NewConfig()},

{[]string{`package main
{[]string{`package main
import (
"crypto/aes"
Expand All @@ -472,5 +470,4 @@ func main() {
}
`}, 1, gosec.NewConfig()},
}
)
}

0 comments on commit b4c7469

Please sign in to comment.