1
0
mirror of https://github.com/securego/gosec.git synced 2025-07-17 01:12:33 +02:00

Fix nosec when applied to a block

Handle properly nosec directive when applied to a block or as a single
line on a multi-line issue.

Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch>
This commit is contained in:
Cosmin Cojocar
2024-05-28 11:46:49 +01:00
parent ed3f51e663
commit ac75d44f56
3 changed files with 91 additions and 1 deletions

View File

@ -278,6 +278,50 @@ func main() {
fmt.Println(bearer)
}
`}, 1, gosec.NewConfig()},
{[]string{`
package main
import "fmt"
// #nosec G101
const (
ConfigLearnerTokenAuth string = "learner_auth_token_config" // #nosec G101
)
func main() {
fmt.Printf("%s\n", ConfigLearnerTokenAuth)
}
`}, 0, gosec.NewConfig()},
{[]string{`
package main
import "fmt"
// #nosec G101
const (
ConfigLearnerTokenAuth string = "learner_auth_token_config"
)
func main() {
fmt.Printf("%s\n", ConfigLearnerTokenAuth)
}
`}, 0, gosec.NewConfig()},
{[]string{`
package main
import "fmt"
const (
ConfigLearnerTokenAuth string = "learner_auth_token_config" // #nosec G101
)
func main() {
fmt.Printf("%s\n", ConfigLearnerTokenAuth)
}
`}, 0, gosec.NewConfig()},
}
// SampleCodeG101Values code snippets for hardcoded credentials