grype容器镜像和系统文件漏洞扫描器

grype容器镜像和系统文件漏洞扫描器

特点

①扫描容器映像或文件系统的内容以查找已知漏洞。

②查找主要操作系统软件包的漏洞.

Alpine
BusyBox
CentOS / Red Hat
Debian
Ubuntu

③查找特定于语言的程序包的漏洞

Ruby (Bundler)
Java (JARs, 等)
JavaScript (NPM/Yarn)
Python (Egg/Wheel)
Python pip/requirements.txt/setup.py listings

④支持Docker和OCI图像格式

安装方法

推荐的安装方法

#将最新版本安装到 /usr/local/bin
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin

#将特定版本安装到特定目录
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b <SOME_BIN_PATH> <RELEASE_VERSION>

macOS安装方法

brew tap anchore/grype 
brew install grype

运行Grype时,您可能会遇到“ macOS无法验证应用程序免受恶意软件感染”的错误,因为尚未签名和公证。您可以使用xattr来覆盖它。

xattr -rd com.apple.quarantine grype

实现shell

Grype通过其CLI实施(cobra)提供完成shell。通过运行以下命令之一为您的shell生成完成代码:

  • grype completion <bash|fish>
  • go run main.go completion <bash|fish>

这会将shell脚本输出到STDOUT,然后可以将其用作Grype的完成脚本。使用-h--help标志运行上述命令之一 将提供有关如何针对所选shell进行操作的说明。

注意:Cobra尚未发布完整的ZSH支持,但是一旦发布,我们将在这里添加它!

配置

配置搜索路径:

.grype.yaml
.grype/config.yaml
~/.grype.yaml
<XDG_CONFIG_HOME>/grype/config.yaml

配置选项(默认值为示例):

# 启用/禁用在启动时检查应用程序更新
check-for-app-update: true

#与-fail-on相同;在扫描时,如果严重性是在或高于给定的严重性,那么返回码将是1
# default未设置,将跳过此验证(选项:可忽略的,低的,中等的,高的,关键的)
fail-on-severity: ''

# 和-o相同;漏洞报告输出格式(选项:table、json、cyclonedx)
output: "table"

# 和-s一样;寻找包的搜索空间(选项:全层,压缩)
scope: "squashed"

# 与-q相同;禁止所有输出(漏洞列表除外)
quiet: false

db:
  # 在运行时检查数据库更新
  auto-update: true

  # 写入漏洞数据库缓存的位置
  cache-dir: "$XDG_CACHE_HOME/grype/db"

  # 漏洞数据库的URL
  update-url: "https://toolbox-data.anchore.io/grype/databases/listing.json"

日志:
  # 写日志文件的位置(默认没有日志文件)
  file: ""

  #日志级别;注意:详细的日志记录会抑制ETUI
  level: "error"

  # 使用结构化日志
  structured: false

使用方法

安装二进制文件,并确保该grype文件在您的路径中可用。
要扫描镜像中的漏洞:

grype <image>

上面的命令扫描容器中可见的漏洞(即,压缩的图像表示形式)。要在漏洞扫描中包括来自所有映像层的软件,无论其是否存在于最终映像中,请提供--scope all-layers

grype <image> --scope all-layers

Grype可以扫描Docker之外的各种来源。

#扫描一个容器镜像存档 (from the result of `docker image save ...`, `podman save ...`, or `skopeo copy` commands)
grype path/to/image.tar

# 扫描一个目录
grype dir:path/to/dir

Grype的输出格式也是可配置的:

grype <image> -o <format>

其中可用的格式是:

  • json:使用它可以从Grype中获取尽可能多的信息!
  • cyclonedx:符合CycloneDX 1.2规范的XML报告。
  • table:列摘要(默认)。

Grype提取了一个从公开可用的Anchore Feed Service衍生的漏洞数据库。
每次扫描开始时都会更新此数据库,但是也可以手动触发更新。

grype db update

项目地址

GitHub: github.com/anchore/grype

下载地址

①GitHub: grype/releases
②雨苁网盘: w.ddosi.workers.dev
③迅雷网盘: pan.xunlei.com 提取码:Rj7b
④蓝奏云: waf.lanzoui.com 密码: ddosi

sha256校验码

grype_0.2.0_linux_amd64.rpm 1b8222aa2c28aceb76f47c23d9adc65bf6eb2a3dac8ced9dc1f67dc8e6f3ca8a  
grype_0.2.0_linux_amd64.tar.gz  52af0392c7ee6afd03fc29d832c3d1809b8633de021f38ddc0dbc92a1638225b  
grype_0.2.0_linux_amd64.deb b8d5ca48f41146c669acd99bf704d5f4291b3e06d0f9fe0291b3a543f0035ee8  
grype_0.2.0_darwin_amd64.tar.gz c99985ed5b78c17401e132b9beececa11bcd46b82a6967c94dfe47a0b3ad918d  
grype-0.2.0.tar.gz  c1908ebfb6a400f69ddf9072962f1e0c3dbed726297cd9b2e27944159a228d32
grype-0.2.0.zip      7850d5ac14e5a3bce82781f176ae61d4132187518ffd5d3f7d8da1a223b92f3f

Leave a Reply

您的电子邮箱地址不会被公开。 必填项已用*标注