1
0
mirror of https://github.com/securego/gosec.git synced 2025-07-15 01:04:43 +02:00

chore: Refactor Sample Code to Separate Files

Split the code in `source.go` to individual sample files, one per rule.
This will help contributors submit samples for new rules, or
improvements to existing rules. The cgo sample was all that was left
after refactoring, which resulted in its own sample file.

Sample code was also formatted to have some level of consistency.
Each sample go "file" attempts to keep the formatting of `gofmt`, and
each code sample is in its own section in the sample file.

Signed-off-by: Adam Kaplan <adam@adambkaplan.com>
This commit is contained in:
Adam Kaplan
2023-11-25 17:51:38 -05:00
committed by Cosmin Cojocar
parent bc03d1c1bc
commit 0e2a61899a
38 changed files with 4461 additions and 4076 deletions

20
testutils/g106_samples.go Normal file
View File

@ -0,0 +1,20 @@
package testutils
import "github.com/securego/gosec/v2"
var (
// SampleCodeG106 - ssh InsecureIgnoreHostKey
SampleCodeG106 = []CodeSample{
{[]string{`
package main
import (
"golang.org/x/crypto/ssh"
)
func main() {
_ = ssh.InsecureIgnoreHostKey()
}
`}, 1, gosec.NewConfig()},
}
)