mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 12:05:52 +00:00
Formatting problems(CI was not passing)
This commit is contained in:
parent
7f8f654235
commit
b4c746962f
3 changed files with 26 additions and 32 deletions
|
@ -1521,7 +1521,6 @@ var _ = Describe("Analyzer", func() {
|
||||||
Expect(controlIssues[0].Suppressions[0].Justification).To(Equal("Globally suppressed."))
|
Expect(controlIssues[0].Suppressions[0].Justification).To(Equal("Globally suppressed."))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
It("should not report an error if the analyzer is excluded", func() {
|
It("should not report an error if the analyzer is excluded", func() {
|
||||||
sample := testutils.SampleCodeG407[0]
|
sample := testutils.SampleCodeG407[0]
|
||||||
source := sample.Code[0]
|
source := sample.Code[0]
|
||||||
|
|
|
@ -57,8 +57,8 @@ func runHardCodedNonce(pass *analysis.Pass) (interface{}, error) {
|
||||||
"crypto/cipher.NewOFB": {2, 1},
|
"crypto/cipher.NewOFB": {2, 1},
|
||||||
}
|
}
|
||||||
var issues []*issue.Issue
|
var issues []*issue.Issue
|
||||||
var ssaPkgFunctions = ssaResult.SSA.SrcFuncs
|
ssaPkgFunctions := ssaResult.SSA.SrcFuncs
|
||||||
var savedArgsFromFunctions = *iterateAndGetArgsFromTrackedFunctions(ssaPkgFunctions, &calls)
|
savedArgsFromFunctions := *iterateAndGetArgsFromTrackedFunctions(ssaPkgFunctions, &calls)
|
||||||
|
|
||||||
for _, savedArg := range savedArgsFromFunctions {
|
for _, savedArg := range savedArgsFromFunctions {
|
||||||
tmp, err := raiseIssue(savedArg, &calls, ssaPkgFunctions, pass, "")
|
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
|
// 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) {
|
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 {
|
if funcsToTrack == nil || variable == nil || analyzerID == "" || issueDescription == "" || fileSet == nil {
|
||||||
return nil, errors.New("received a nil object")
|
return nil, errors.New("received a nil object")
|
||||||
}
|
}
|
||||||
var gosecIssues []*issue.Issue = nil
|
var gosecIssues []*issue.Issue = nil
|
||||||
// Go trough all functions that use the given arg variable
|
// Go trough all functions that use the given arg variable
|
||||||
for _, referrer := range *(*variable).Referrers() {
|
for _, referrer := range *(*variable).Referrers() {
|
||||||
|
|
||||||
// Iterate trough the functions we are interested
|
// Iterate trough the functions we are interested
|
||||||
for trackedFunc := range *funcsToTrack {
|
for trackedFunc := range *funcsToTrack {
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,9 @@ package testutils
|
||||||
|
|
||||||
import "github.com/securego/gosec/v2"
|
import "github.com/securego/gosec/v2"
|
||||||
|
|
||||||
var (
|
// SampleCodeG407 - Use of hardcoded nonce/IV
|
||||||
// SampleCodeG407 - Use of hardcoded nonce/IV
|
var SampleCodeG407 = []CodeSample{
|
||||||
SampleCodeG407 = []CodeSample{
|
{[]string{`package main
|
||||||
|
|
||||||
{[]string{`package main
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -25,7 +23,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 1, gosec.NewConfig()},
|
`}, 1, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -45,7 +43,7 @@ func main() {
|
||||||
|
|
||||||
`}, 0, gosec.NewConfig()},
|
`}, 0, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -79,7 +77,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 0, gosec.NewConfig()},
|
`}, 0, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -97,7 +95,7 @@ func main() {
|
||||||
|
|
||||||
}`}, 1, gosec.NewConfig()},
|
}`}, 1, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -115,7 +113,7 @@ func main() {
|
||||||
|
|
||||||
}`}, 1, gosec.NewConfig()},
|
}`}, 1, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -134,7 +132,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 1, gosec.NewConfig()},
|
`}, 1, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -154,7 +152,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -174,7 +172,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -195,7 +193,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -229,7 +227,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -262,7 +260,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -282,7 +280,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -302,7 +300,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -323,7 +321,7 @@ func main() {
|
||||||
|
|
||||||
}`}, 2, gosec.NewConfig()},
|
}`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -344,7 +342,7 @@ func main() {
|
||||||
|
|
||||||
}`}, 2, gosec.NewConfig()},
|
}`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -367,7 +365,7 @@ func main() {
|
||||||
|
|
||||||
}`}, 2, gosec.NewConfig()},
|
}`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -391,7 +389,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 2, gosec.NewConfig()},
|
`}, 2, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -408,7 +406,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 1, gosec.NewConfig()},
|
`}, 1, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -427,7 +425,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 1, gosec.NewConfig()},
|
`}, 1, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -453,7 +451,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`}, 0, gosec.NewConfig()},
|
`}, 0, gosec.NewConfig()},
|
||||||
|
|
||||||
{[]string{`package main
|
{[]string{`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
@ -472,5 +470,4 @@ func main() {
|
||||||
|
|
||||||
}
|
}
|
||||||
`}, 1, gosec.NewConfig()},
|
`}, 1, gosec.NewConfig()},
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue