mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 11:35:51 +00:00
Add a unit test to detect the false negative in rule G306 for os.ModePerm permissions
Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch>
This commit is contained in:
parent
417a44c73b
commit
dc5e5a99d0
1 changed files with 20 additions and 1 deletions
|
@ -21,7 +21,6 @@ func check(e error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
d1 := []byte("hello\ngo\n")
|
d1 := []byte("hello\ngo\n")
|
||||||
err := ioutil.WriteFile("/tmp/dat1", d1, 0744)
|
err := ioutil.WriteFile("/tmp/dat1", d1, 0744)
|
||||||
check(err)
|
check(err)
|
||||||
|
@ -52,5 +51,25 @@ func main() {
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
`}, 1, gosec.NewConfig()},
|
||||||
|
{[]string{`
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func check(e error) {
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
content := []byte("hello\ngo\n")
|
||||||
|
err := ioutil.WriteFile("/tmp/dat1", content, os.ModePerm)
|
||||||
|
check(err)
|
||||||
|
}
|
||||||
`}, 1, gosec.NewConfig()},
|
`}, 1, gosec.NewConfig()},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue