mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 12:05:52 +00:00
2aad3f02a5
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
47 lines
584 B
Go
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"}},
|
|
}
|