gosec/testutils/g307_samples.go
Cosmin Cojocar 2aad3f02a5 Fix lint warnings by properly formatting the files
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
2023-12-08 14:46:36 +01:00

47 lines
584 B
Go

package testutils
import "github.com/securego/gosec/v2"
// SampleCodeG307 - Poor permissions for os.Create
var SampleCodeG307 = []CodeSample{
{[]string{`
package main
import (
"fmt"
"os"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
f, err := os.Create("/tmp/dat2")
check(err)
defer f.Close()
}
`}, 0, gosec.NewConfig()},
{[]string{`
package main
import (
"fmt"
"os"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
f, err := os.Create("/tmp/dat2")
check(err)
defer f.Close()
}
`}, 1, gosec.Config{"G307": "0o600"}},
}