mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 19:45:51 +00:00
50 lines
593 B
Go
50 lines
593 B
Go
|
package testutils
|
||
|
|
||
|
import "github.com/securego/gosec/v2"
|
||
|
|
||
|
var (
|
||
|
// SampleCodeG307 - Poor permissions for os.Create
|
||
|
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"}},
|
||
|
}
|
||
|
)
|