mirror of
https://github.com/securego/gosec.git
synced 2025-06-14 23:45:03 +02:00
feat: add os.ReadFile to G304 (#706)
In Go 1.16 or higher, the `io/ioutil` has been deprecated and the `ioutil.ReadFile` function now calls `os.ReadFile`. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@ -1787,6 +1787,22 @@ func main() {
|
||||
}`}, 1, gosec.NewConfig()}, {[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f := os.Getenv("tainted_file")
|
||||
body, err := os.ReadFile(f)
|
||||
if err != nil {
|
||||
log.Printf("Error: %v\n", err)
|
||||
}
|
||||
log.Print(body)
|
||||
|
||||
}`}, 1, gosec.NewConfig()}, {[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
Reference in New Issue
Block a user