Go源代码安全审计工具之gosec

摘要:
Gosec分析Go源代码,找出可能导致安全问题的常见编程错误。它通过扫描GoAST来检查源代码是否存在安全问题。

gosec分析Go源代码以查找可能导致安全问题的常见编程错误。

它通过扫描Go AST检查源代码是否存在安全问题。

https://github.com/securego/gosec

gosec v2.4.0

gosec - Golang security checker

gosec analyzes Go source code to look for common programming mistakes that can lead to security problems.

用法:
    # 检查单个程序包
    $ gosec $GOPATH/src/github.com/example/project

    # 检查当前目录下的所有程序包并将结果保存为JSON格式
    $ gosec -fmt=json -out=results.json ./...

    # 运行一组特定的规则 (默认情况下将运行所有的规则):
    $ gosec -include=G101,G203,G401 ./...

    # 运行除了提供的之外的所有规则
    $ gosec -exclude=G101 $GOPATH/src/github.com/example/project/...

选项:
    -conf string          可选配置文件的路径
    -confidence string    以低于给定值的置信度筛选出问题 有效选项包括: low, medium, high (default "low")
    -exclude string       以逗号分隔的要排除的规则ID列表 请参阅"规则"列表
    -exclude-dir value    从扫描中排除目录 可以多次指定
    -fmt string           设置输出格式 有效选项包括: json, yaml, csv, junit-xml, html, sonarqube, golint or text (default "text")
    -include string       以逗号分隔的要包含的规则ID列表 请参阅"规则"列表
    -log string           将消息记录到文件而不是标准错误
    -no-fail              即使发现问题也不要使扫描失败
    -nosec                设置时忽略"#nosec"注释
    -nosec-tag string"#nosec"设置替代字符串 一些例子: #dontanalyze, #falsepositive
    -out string           设置结果的输出文件
    -quiet                仅在发现错误时显示输出
    -severity string      筛选出严重性低于给定值的问题 有效选项包括: low, medium, high (default "low")
    -sort                 按严重性对问题进行排序 (default true)
    -tags string          以逗号分隔的构建标记列表
    -tests                扫描测试文件
    -version              打印版本并退出 退出代码为0

规则:
    G101: Look for hardcoded credentials
    G102: Bind to all interfaces
    G103: Audit the use of unsafe block
    G104: Audit errors not checked
    G106: Audit the use of ssh.InsecureIgnoreHostKey function
    G107: Url provided to HTTP request as taint input
    G108: Profiling endpoint is automatically exposed
    G109: Converting strconv.Atoi result to int32/int16
    G110: Detect io.Copy instead of io.CopyN when decompression
    G201: SQL query construction using format string
    G202: SQL query construction using string concatenation
    G203: Use of unescaped data in HTML templates
    G204: Audit use of command execution
    G301: Poor file permissions used when creating a directory
    G302: Poor file permissions used when creation file or using chmod
    G303: Creating tempfile using a predictable path
    G304: File path provided as taint input
    G305: File path traversal when extracting zip archive
    G306: Poor file permissions used when writing to a file
    G307: Unsafe defer call of a method returning an error
    G401: Detect the usage of DES, RC4, MD5 or SHA1
    G402: Look for bad TLS connection settings
    G403: Ensure minimum RSA key length of 2048 bits
    G404: Insecure random number source (rand)
    G501: Import blocklist: crypto/md5
    G502: Import blocklist: crypto/des
    G503: Import blocklist: crypto/rc4
    G504: Import blocklist: net/http/cgi
    G505: Import blocklist: crypto/sha1
    G601: Implicit memory aliasing in RangeStmt

免责声明:文章转载自《Go源代码安全审计工具之gosec》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇python与selenium自动化基础-xlrd读取数据,Excel生成报告微信公众号--JS-SDK下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

跟着我一步一步的搭建一个基于springcloud的微服务实例

Table of Contentsgenerated with DocToc microservicecloud 插件推荐 建立父工程Microservicecloud 搭建Employ员工服务创建数据库 创建消费者服务microservicecloud-employconsummer Eureka注册中心搭建 单机模式创建microserv...

InputString 转换成 BufferedImage 和 byte[]

获取网络的一张图片,但是某种需要,要把获取的这段流输入换为BufferedImage流,有的地方还需要转换为byte[]. 获得图片地址,获得了一个图片输入流,例如: Url img = new URL(url);InputStream in = img.openStream(); 接着把输入流转为BufferedImage: JPEGImageDecod...

Unity3D中使用委托和事件

Unity3D中使用委托和事件  c#语言规范 阅读目录 1.C#中的委托、事件引入 2.方法的参数是方法 前言: 本来早就想写写和代码设计相关的东西了,以前做2DX的时候就有过写写观察者设计模式的想法,但是实践不多。现在转到U3D的怀抱中,倒是接触了不少委托事件的写法,那干脆就在此总结一下吧。 回到目录 1.C#中的委托、事件引入 本想去找...

Java基础知识15commonslang3 第3方开源库的具体使用01(StringUtils、RandomUtils类、RandomStringUtils类)

1.commons-lang3 概述 apache提供的众多commons工具包,号称Java第二API,而common里面lang3包更是被我们使用得最多的。因此本文主要详细讲解lang3包里面几乎每个类的使用,希望以后大家使用此工具包,写出优雅的代码。 maven依赖: <dependency> <groupId>org...

impala 四舍五入后转换成string后又变成一个double的数值解决(除不尽的情况)

impala 四舍五入后转换成string后又变成一个double的数值解决(除不尽的情况)例如Query: select cast(round(2 / 3, 4)*100 as string)+---------------------------------------+| cast(round(2 / 3, 4) * 100 as string) |...

通过jpa getResultList 获取查询到的内容

String sql = "select * from spatial_event "; Query query =em.createNativeQuery(sql); //query.setParameter(1, email); //query.setParameter(2, id); List...