mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +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
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ATNStateSomethingElse = 1,
|
ATNStateSomethingElse = 1
|
||||||
ATNStateTokenStart = 42,
|
ATNStateTokenStart = 42
|
||||||
)
|
)
|
||||||
func main() {
|
func main() {
|
||||||
println(ATNStateTokenStart)
|
println(ATNStateTokenStart)
|
||||||
}`, analyzer)
|
}`, analyzer)
|
||||||
checkTestResults(t, issues, 0, "Potential hardcoded credentials")
|
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