admin管理员组

文章数量:1565350

Secure Go  - A project devoted to secure programming in the Go language,

gosec   - Golang Security Checker为go语言安全编码的github,其默认提供了如下规则。在扫描过程中,我们针对部分中签的规则,找到了一些安全编码的解决办法。


  • 万能解决办法

如果gosec报告已手动验证为安全的,则可以使用如下“#nosec”来注释代码。扫描的时候可通过参数指定忽略该注释代码。个人不建议使用此方法,毕竟代码合规最重要。

import "md5" // #nosec  

func main(){
    /* #nosec */
    if x > y {
        h := md5.New() // this will also be ignored
    }
}

// 以上是不建议使用的。
// 如果使用,你需要执行命令来运行扫描程序以及忽略#nosec注释:$ gosec -nosec=true ./...

  • G101: Look for hard coded credentials
  • G102: Bind to all interfaces
  • G103: Audit the use of unsafe block
  • G104: Audit errors not checked

反例:

本文标签: 解决办法规则常见Golanggosec