mirror of
https://github.com/securego/gosec.git
synced 2024-12-24 11:35:52 +00:00
Fix test case (invalid sample code)
This commit is contained in:
parent
d1e67fc995
commit
1e736c8838
1 changed files with 18 additions and 2 deletions
|
@ -120,11 +120,27 @@ func TestHardcodedConstInteger(t *testing.T) {
|
|||
package main
|
||||
|
||||
const (
|
||||
ATNStateSomethingElse = 1,
|
||||
ATNStateTokenStart = 42,
|
||||
ATNStateSomethingElse = 1
|
||||
ATNStateTokenStart = 42
|
||||
)
|
||||
func main() {
|
||||
println(ATNStateTokenStart)
|
||||
}`, analyzer)
|
||||
checkTestResults(t, issues, 0, "Potential hardcoded credentials")
|
||||
}
|
||||
|
||||
func TestHardcodedConstString(t *testing.T) {
|
||||
config := map[string]interface{}{"ignoreNosec": false}
|
||||
analyzer := gas.NewAnalyzer(config, nil)
|
||||
analyzer.AddRule(NewHardcodedCredentials(config))
|
||||
issues := gasTestRunner(`
|
||||
package main
|
||||
|
||||
const (
|
||||
ATNStateTokenStart = "foo bar"
|
||||
)
|
||||
func main() {
|
||||
println(ATNStateTokenStart)
|
||||
}`, analyzer)
|
||||
checkTestResults(t, issues, 1, "Potential hardcoded credentials")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue