<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>OPSaid – 漏洞扫描</title><link>https://opsaid.net/docs/identity-security/supply-chain-security/vulnerability-scanning/</link><description>Recent content in 漏洞扫描 on OPSaid</description><generator>Hugo -- gohugo.io</generator><atom:link href="https://opsaid.net/docs/identity-security/supply-chain-security/vulnerability-scanning/index.xml" rel="self" type="application/rss+xml"/><item><title>Docs: 漏洞数据</title><link>https://opsaid.net/docs/identity-security/supply-chain-security/vulnerability-scanning/vulnerability/</link><pubDate>Mon, 18 Dec 2023 11:23:23 +0800</pubDate><guid>https://opsaid.net/docs/identity-security/supply-chain-security/vulnerability-scanning/vulnerability/</guid><description>
&lt;h2 id="简要概述">简要概述&lt;/h2>
&lt;p>漏洞数据的来源，数据库的下载与制作。&lt;/p>
&lt;h2 id="数据库下载">数据库下载&lt;/h2>
&lt;h3 id="通过-trivy-下载漏洞库">通过 trivy 下载漏洞库&lt;/h3>
&lt;p>各组件安全漏洞列表已由工具 &lt;a href="https://github.com/aquasecurity/trivy-db">trivy-db&lt;/a> 通过 GitHub Action 每 6 小时聚合并更新漏洞库，上传至 &lt;a href="https://github.com/aquasecurity/trivy-db/pkgs/container/trivy-db">GHCR&lt;/a>（&lt;a href="https://github.com/features/packages">为 GitHub 镜像中心服务&lt;/a>），我们可同步该漏洞库用于离线扫描镜像、K8S 集群、本地文件系统等。&lt;/p>
&lt;p>通过 &lt;a href="https://github.com/aquasecurity/trivy">trivy&lt;/a> 工具下载至本地缓存，取保网络连接可达：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic"># 线路加速，根据事情情况是否开启&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">#export HTTPS_PROXY=http://127.0.0.1:1087&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>trivy --cache-dir ./cache image --download-db-only
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="制作私有漏洞库">制作私有漏洞库&lt;/h3>
&lt;p>TODO;&lt;/p>
&lt;p>思路：&lt;/p>
&lt;ol>
&lt;li>获取仓库 &lt;a href="https://github.com/aquasecurity/trivy-db.git">https://github.com/aquasecurity/trivy-db.git&lt;/a>&lt;/li>
&lt;li>更改流水线 .github/workflows/cron.yml&lt;/li>
&lt;li>生成漏洞库上传至内部存储中心&lt;/li>
&lt;/ol>
&lt;h2 id="漏洞数据来源">漏洞数据来源&lt;/h2>
&lt;h3 id="操作系统">操作系统&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>名称&lt;/th>
&lt;th>漏洞库&lt;/th>
&lt;th>地址&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Alpine Linux&lt;/td>
&lt;td>secdb&lt;/td>
&lt;td>&lt;a href="https://secdb.alpinelinux.org/">https://secdb.alpinelinux.org/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>aquasecurity&lt;/td>
&lt;td>&lt;a href="https://github.com/aquasecurity/vuln-list">https://github.com/aquasecurity/vuln-list&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Debian&lt;/td>
&lt;td>Security Bug Tracker&lt;/td>
&lt;td>&lt;a href="https://security-tracker.debian.org/tracker/">https://security-tracker.debian.org/tracker/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>OVAL&lt;/td>
&lt;td>&lt;a href="https://www.debian.org/security/oval/">https://www.debian.org/security/oval/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>aquasecurity&lt;/td>
&lt;td>&lt;a href="https://github.com/aquasecurity/vuln-list-debian">https://github.com/aquasecurity/vuln-list-debian&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Ubuntu&lt;/td>
&lt;td>Ubuntu CVE Tracker&lt;/td>
&lt;td>&lt;a href="https://ubuntu.com/security/cve">https://ubuntu.com/security/cve&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>aquasecurity&lt;/td>
&lt;td>&lt;a href="https://github.com/aquasecurity/vuln-list">https://github.com/aquasecurity/vuln-list&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>RHEL/CentOS&lt;/td>
&lt;td>OVAL&lt;/td>
&lt;td>&lt;a href="https://www.redhat.com/security/data/oval/v2/">https://www.redhat.com/security/data/oval/v2/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>Security Data&lt;/td>
&lt;td>&lt;a href="https://www.redhat.com/security/data/metrics/">https://www.redhat.com/security/data/metrics/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>aquasecurity&lt;/td>
&lt;td>&lt;a href="https://github.com/aquasecurity/vuln-list-redhat">https://github.com/aquasecurity/vuln-list-redhat&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Arch Linux&lt;/td>
&lt;td>Vulnerable Issues&lt;/td>
&lt;td>&lt;a href="https://security.archlinux.org/">https://security.archlinux.org/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Wolfi Linux&lt;/td>
&lt;td>secdb&lt;/td>
&lt;td>&lt;a href="https://secdb.alpinelinux.org/">https://secdb.alpinelinux.org/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Chainguard&lt;/td>
&lt;td>secdb&lt;/td>
&lt;td>&lt;a href="https://secdb.alpinelinux.org/">https://secdb.alpinelinux.org/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Amazon Linux&lt;/td>
&lt;td>Amazon Linux Security Center&lt;/td>
&lt;td>&lt;a href="https://alas.aws.amazon.com/">https://alas.aws.amazon.com/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>AlmaLinux&lt;/td>
&lt;td>AlmaLinux Product Errata&lt;/td>
&lt;td>&lt;a href="https://errata.almalinux.org/">https://errata.almalinux.org/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Rocky Linux&lt;/td>
&lt;td>Rocky Linux UpdateInfo&lt;/td>
&lt;td>&lt;a href="https://download.rockylinux.org/pub/rocky/">https://download.rockylinux.org/pub/rocky/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Oracle Linux&lt;/td>
&lt;td>OVAL&lt;/td>
&lt;td>&lt;a href="https://linux.oracle.com/security/oval/">https://linux.oracle.com/security/oval/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>CBL-Mariner&lt;/td>
&lt;td>OVAL&lt;/td>
&lt;td>&lt;a href="https://github.com/microsoft/CBL-MarinerVulnerabilityData/">https://github.com/microsoft/CBL-MarinerVulnerabilityData/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>OpenSUSE/SLES&lt;/td>
&lt;td>CVRF&lt;/td>
&lt;td>&lt;a href="http://ftp.suse.com/pub/projects/security/cvrf/">http://ftp.suse.com/pub/projects/security/cvrf/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Photon OS&lt;/td>
&lt;td>Photon Security Advisory&lt;/td>
&lt;td>&lt;a href="https://packages.vmware.com/photon/photon_cve_metadata/">https://packages.vmware.com/photon/photon_cve_metadata/&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="语言框架">语言框架&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>名称&lt;/th>
&lt;th>漏洞库&lt;/th>
&lt;th>地址&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>PHP&lt;/td>
&lt;td>PHP Security Advisories Database&lt;/td>
&lt;td>&lt;a href="https://github.com/FriendsOfPHP/security-advisories">https://github.com/FriendsOfPHP/security-advisories&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>GitHub Advisory Database (Composer)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Acomposer">https://github.com/advisories?query=ecosystem%3Acomposer&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Python&lt;/td>
&lt;td>GitHub Advisory Database (pip)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Apip">https://github.com/advisories?query=ecosystem%3Apip&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>Open Source Vulnerabilities (PyPI)&lt;/td>
&lt;td>&lt;a href="https://osv.dev/list?q=&amp;amp;ecosystem=PyPI">https://osv.dev/list?q=&amp;amp;ecosystem=PyPI&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Ruby&lt;/td>
&lt;td>Ruby Advisory Database&lt;/td>
&lt;td>&lt;a href="https://github.com/rubysec/ruby-advisory-db">https://github.com/rubysec/ruby-advisory-db&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>GitHub Advisory Database (RubyGems)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Arubygems">https://github.com/advisories?query=ecosystem%3Arubygems&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Node.js&lt;/td>
&lt;td>Ecosystem Security Working Group&lt;/td>
&lt;td>&lt;a href="https://github.com/nodejs/security-wg">https://github.com/nodejs/security-wg&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>GitHub Advisory Database (npm)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Anpm">https://github.com/advisories?query=ecosystem%3Anpm&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Java&lt;/td>
&lt;td>GitHub Advisory Database (Maven)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Amaven">https://github.com/advisories?query=ecosystem%3Amaven&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Go&lt;/td>
&lt;td>GitHub Advisory Database (Go)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Ago">https://github.com/advisories?query=ecosystem%3Ago&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Rust&lt;/td>
&lt;td>Open Source Vulnerabilities (crates.io)&lt;/td>
&lt;td>&lt;a href="https://osv.dev/list?q=&amp;amp;ecosystem=crates.io">https://osv.dev/list?q=&amp;amp;ecosystem=crates.io&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>.NET&lt;/td>
&lt;td>GitHub Advisory Database (NuGet)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Anuget">https://github.com/advisories?query=ecosystem%3Anuget&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>C/C++&lt;/td>
&lt;td>GitLab Advisories Community&lt;/td>
&lt;td>&lt;a href="https://gitlab.com/gitlab-org/advisories-community">https://gitlab.com/gitlab-org/advisories-community&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Dart&lt;/td>
&lt;td>GitHub Advisory Database (Pub)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Apub">https://github.com/advisories?query=ecosystem%3Apub&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Elixir&lt;/td>
&lt;td>GitHub Advisory Database (Erlang)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Aerlang">https://github.com/advisories?query=ecosystem%3Aerlang&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Swift&lt;/td>
&lt;td>GitHub Advisory Database (Swift)&lt;/td>
&lt;td>&lt;a href="https://github.com/advisories?query=ecosystem%3Aswift">https://github.com/advisories?query=ecosystem%3Aswift&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="kubernetes">Kubernetes&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>名称&lt;/th>
&lt;th>漏洞库&lt;/th>
&lt;th>地址&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Bitnami&lt;/td>
&lt;td>bitnami&lt;/td>
&lt;td>&lt;a href="https://github.com/bitnami/vulndb">https://github.com/bitnami/vulndb&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Kubernetes&lt;/td>
&lt;td>CVE feed&lt;/td>
&lt;td>&lt;a href="https://kubernetes.io/docs/reference/issues-security/official-cve-feed/">https://kubernetes.io/docs/reference/issues-security/official-cve-feed/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>aquasecurity&lt;/td>
&lt;td>&lt;a href="https://github.com/aquasecurity/vuln-list-k8s">https://github.com/aquasecurity/vuln-list-k8s&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="其他来源">其他来源&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>名称&lt;/th>
&lt;th>漏洞库&lt;/th>
&lt;th>地址&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>GitHub&lt;/td>
&lt;td>GitHub&lt;/td>
&lt;td>&lt;a href="https://github.com/github/advisory-database">https://github.com/github/advisory-database&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>NVD&lt;/td>
&lt;td>NVD&lt;/td>
&lt;td>&lt;a href="https://nvd.nist.gov/">https://nvd.nist.gov/&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>aquasecurity&lt;/td>
&lt;td>&lt;a href="https://github.com/aquasecurity/vuln-list-nvd">https://github.com/aquasecurity/vuln-list-nvd&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>CocoaPods&lt;/td>
&lt;td>CocoaPods&lt;/td>
&lt;td>&lt;a href="https://github.com/CocoaPods/Specs">https://github.com/CocoaPods/Specs&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="使用-bbolt-存储的数据结构">使用 bbolt 存储的数据结构&lt;/h2>
&lt;h3 id="获取-buckets-列表">获取 buckets 列表&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ bbolt buckets assets/trivy.db
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pub::GitHub Security Advisory Pub
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>rocky &lt;span style="color:#0000cf;font-weight:bold">8&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>rocky &lt;span style="color:#0000cf;font-weight:bold">9&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>rubygems::GitHub Security Advisory RubyGems
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ubuntu 22.04
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>vulnerability
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>wolfi
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="查找-buckets-下的-keys">查找 buckets 下的 keys&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ bbolt keys assets/trivy.db vulnerability
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CVE-1234-0007
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CVE-1234-1234
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CVE-1999-0150
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CVE-1999-0163
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CVE-1999-0199
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CVE-1999-0236
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>openSUSE-SU-2023:0396-1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>openSUSE-SU-2023:0397-1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>openSUSE-SU-2023:0404-1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>openSUSE-SU-2023:0405-1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="获取-buckets-下-key-内容">获取 buckets 下 key 内容&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ bbolt get assets/trivy.db vulnerability CVE-1999-0150
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;Title&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;CVE-1999-0150 affecting package finger 0.17-4&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;Description&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;The Perl fingerd program allows arbitrary command execution from remote users.&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;Severity&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;HIGH&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;VendorSeverity&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;cbl-mariner&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#0000cf;font-weight:bold">3&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;nvd&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#0000cf;font-weight:bold">3&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;CVSS&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;nvd&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;V2Vector&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;AV:N/AC:L/Au:N/C:P/I:P/A:P&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;V2Score&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#0000cf;font-weight:bold">7.5&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;References&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;https://exchange.xforce.ibmcloud.com/vulnerabilities/CVE-1999-0150&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;https://nvd.nist.gov/vuln/detail/CVE-1999-0150&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;PublishedDate&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;1997-07-01T04:00:00Z&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;LastModifiedDate&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;2022-08-17T07:15:00Z&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="几个关键的-buckets">几个关键的 buckets&lt;/h3>
&lt;ul>
&lt;li>漏洞官方数据来源&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>data-source
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>$ bbolt get assets/trivy.db data-source &amp;#34;k8s::Official Kubernetes CVE Feed&amp;#34;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;ID&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;k8s&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;Name&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;Official Kubernetes CVE Feed&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;URL&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;https://kubernetes.io/docs/reference/issues-security/official-cve-feed/index.json&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Docs: 漏洞扫描</title><link>https://opsaid.net/docs/identity-security/supply-chain-security/vulnerability-scanning/scanner/</link><pubDate>Fri, 15 Dec 2023 10:40:52 +0800</pubDate><guid>https://opsaid.net/docs/identity-security/supply-chain-security/vulnerability-scanning/scanner/</guid><description>
&lt;h2 id="简要概述">简要概述&lt;/h2>
&lt;p>通过开源漏洞库，实现对镜像、文件系统、代码仓库、K8S 配置清单等进行扫描以提前发现问题。&lt;/p>
&lt;h2 id="配置参数">配置参数&lt;/h2>
&lt;p>工具 trivy 支持在 cli 直接跟参数或通过 &lt;code>trivy --cofnig trivy.yaml &lt;/code> 使用配置文件，内容如下：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic"># 同 cli 参数 &amp;#39;--cache-dir&amp;#39;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 存放漏洞库等缓存数据，首次初始化会自动从 github 下载&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">cache&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">dir&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">./cache/&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">db&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 同 cli 参数 &amp;#39;--skip-db-update&amp;#39;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 本地漏洞库存在有效期，超过后会重新下载，这里忽略时间检测&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">skip-update&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">true&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 仅列出 &amp;#34;UNKNOWN&amp;#34; &amp;#34;HIGH&amp;#34; &amp;#34;CRITICAL&amp;#34; 三个级别事件&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">severity&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#000">UNKNOWN&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#000">HIGH&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#000">CRITICAL&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">scan&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 默认开启 &amp;#34;漏洞扫描“ 与 &amp;#34;密钥扫描&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">scanners&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#000">vuln&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic">#- misconfig&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#000">secret&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic">#- license&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以上等同于 cli 模式：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --cache-dir ./cache/ &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --skip-policy-update &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --skip-db-update &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --skip-java-db-update &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以下实验均使用配置文件模式，更多内容可参考&lt;a href="https://aquasecurity.github.io/trivy/latest/docs/references/configuration/config-file/">官方文档&lt;/a>。&lt;/p>
&lt;h2 id="支持的功能">支持的功能&lt;/h2>
&lt;h3 id="漏洞扫描">漏洞扫描&lt;/h3>
&lt;p>仅支持以上这些系统的安装包检测，如果是自编译或者第三方安装包则不被支持，因为漏洞源中没有相关数据。&lt;/p>
&lt;p>安全评估等级&lt;/p>
&lt;p>如果相同的漏洞，多家给予不通的评分，则一般以供应商的评估等级更加准确，比如 &lt;a href="https://access.redhat.com/security/cve/cve-2023-0464">cve-2023-0464&lt;/a> 上 Redhat 与 NVD 不同。因为安全评估的严重性取决于编译选项、默认配置等，NVD 不知道供应商如何分发软件，而厂商可以更准确地评估。&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>分数范围&lt;/th>
&lt;th>等级&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>-&lt;/td>
&lt;td>UNKNOWN&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>0.1 - 3.9&lt;/td>
&lt;td>Low&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4.0 - 6.9&lt;/td>
&lt;td>Medium&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>7.0 - 8.9&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>9.0 - 10.0&lt;/td>
&lt;td>Critical&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>评估等级优先级：系统厂商 &amp;gt; NVD。如果 NVD 未找到则标志等级为 &amp;ldquo;UNKNOWN&amp;rdquo;&lt;/p>
&lt;h3 id="错误配置扫描">错误配置扫描&lt;/h3>
&lt;p>TODO;&lt;/p>
&lt;h3 id="密钥扫描">密钥扫描&lt;/h3>
&lt;p>TODO;&lt;/p>
&lt;h3 id="许可证扫描">许可证扫描&lt;/h3>
&lt;p>TODO;&lt;/p>
&lt;h2 id="扫描的目标">扫描的目标&lt;/h2>
&lt;h3 id="容器镜像">容器镜像&lt;/h3>
&lt;p>默认开关的扫描功能：&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>功能&lt;/th>
&lt;th>启动参数&lt;/th>
&lt;th>默认启用&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>漏洞扫描&lt;/td>
&lt;td>&lt;code>trivy image --scanners vuln&lt;/code>&lt;/td>
&lt;td>是&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>错误配置扫描&lt;/td>
&lt;td>&lt;code>trivy image --scanners config&lt;/code>&lt;/td>
&lt;td>否&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>密钥扫描&lt;/td>
&lt;td>&lt;code>trivy image --scanners secret&lt;/code>&lt;/td>
&lt;td>是&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>许可证扫描&lt;/td>
&lt;td>&lt;code>trivy image --scanners license&lt;/code>&lt;/td>
&lt;td>否&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>通过对镜像 &lt;code>docker.io/bitnami/redis:7.2.3-debian-11-r2&lt;/code> 进行扫描：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml image docker.io/bitnami/redis:7.2.3-debian-11-r2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="代码仓库">代码仓库&lt;/h3>
&lt;p>默认开关的扫描功能：&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>功能&lt;/th>
&lt;th>启动参数&lt;/th>
&lt;th>默认启用&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>漏洞扫描&lt;/td>
&lt;td>&lt;code>trivy repo --scanners vuln&lt;/code>&lt;/td>
&lt;td>是&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>错误配置扫描&lt;/td>
&lt;td>&lt;code>trivy repo --scanners config&lt;/code>&lt;/td>
&lt;td>否&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>密钥扫描&lt;/td>
&lt;td>&lt;code>trivy repo --scanners secret&lt;/code>&lt;/td>
&lt;td>是&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>许可证扫描&lt;/td>
&lt;td>&lt;code>trivy repo --scanners license&lt;/code>&lt;/td>
&lt;td>否&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>实现原理是通过扫描各语言依赖关系的锁定文件，部分如下列表：&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>语言&lt;/th>
&lt;th>扫描文件&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>go&lt;/td>
&lt;td>go.mod&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>node&lt;/td>
&lt;td>package-lock.json&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ruby&lt;/td>
&lt;td>Gemfile.lock&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>支持扫描本地或者远程代码仓库，这里针对代码仓库 &lt;code>github.com/grpc-kit/cli&lt;/code> 进行在线扫描：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml repo https://github.com/grpc-kit/cli.git
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>然后生成如下报告：&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Library&lt;/th>
&lt;th>Vulnerability&lt;/th>
&lt;th>Severity&lt;/th>
&lt;th>Status&lt;/th>
&lt;th>Installed Version&lt;/th>
&lt;th>Fixed Version&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>golang.org/x/net&lt;/td>
&lt;td>CVE-2022-41723&lt;/td>
&lt;td>HIGH&lt;/td>
&lt;td>fixed&lt;/td>
&lt;td>0.6.0&lt;/td>
&lt;td>0.7.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>golang.org/x/net&lt;/td>
&lt;td>CVE-2023-39325&lt;/td>
&lt;td>HIGH&lt;/td>
&lt;td>fixed&lt;/td>
&lt;td>0.6.0&lt;/td>
&lt;td>0.17.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>github.com/emicklei/go-restful&lt;/td>
&lt;td>CVE-2022-1996&lt;/td>
&lt;td>CRITICAL&lt;/td>
&lt;td>fixed&lt;/td>
&lt;td>2.9.5+incompatible&lt;/td>
&lt;td>2.16.0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="本地文件">本地文件&lt;/h3>
&lt;p>默认开关的扫描功能：&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>功能&lt;/th>
&lt;th>启动参数&lt;/th>
&lt;th>默认启用&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>漏洞扫描&lt;/td>
&lt;td>&lt;code>trivy fs --scanners vuln&lt;/code>&lt;/td>
&lt;td>是&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>错误配置扫描&lt;/td>
&lt;td>&lt;code>trivy fs --scanners config&lt;/code>&lt;/td>
&lt;td>否&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>密钥扫描&lt;/td>
&lt;td>&lt;code>trivy fs --scanners secret&lt;/code>&lt;/td>
&lt;td>是&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>许可证扫描&lt;/td>
&lt;td>&lt;code>trivy fs --scanners license&lt;/code>&lt;/td>
&lt;td>否&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>本地扫描文件存在两种不通的工作模式：&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>参数&lt;/th>
&lt;th>用途&lt;/th>
&lt;th>场景&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>trivy fs&lt;/code>&lt;/td>
&lt;td>针对镜像、语言依赖库扫描&lt;/td>
&lt;td>一般用于 CICD 场景&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>trivy rootfs&lt;/code>&lt;/td>
&lt;td>针对文件系统上二进制文件等&lt;/td>
&lt;td>操作系统扫描&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>如果代码仓库、容器镜像等均在本地，也可以通过该方式扫描，如：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml fs test/go.mod
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>针对系统目录下 &lt;code>/usr/local/bin&lt;/code> 二进制文件扫描，当然这些二进制文件必须是公开漏洞库中已有的数据，不能是内部自己编译应用：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml rootfs /usr/local/bin/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="kubernetes">Kubernetes&lt;/h3>
&lt;p>需要能访问到 k8s 集群，trivy 默认是通过读取 &amp;ldquo;$HOME/.kube/config&amp;rdquo; 连接集群。&lt;/p>
&lt;p>可扫描以下内容：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml k8s all
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml k8s pods
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml k8s deploy myapp
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml k8s pod/mypod
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml k8s pods,deploy
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>trivy --config trivy.yaml k8s cluster
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>支持针对以下几个合规进行扫描：&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>规则&lt;/th>
&lt;th>指令参数&lt;/th>
&lt;th>规范地址&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>NSA, CISA Kubernetes Hardening Guidance v1.2&lt;/td>
&lt;td>k8s-nsa&lt;/td>
&lt;td>&lt;a href="https://media.defense.gov/2022/Aug/29/2003066362/-1/-1/0/CTR_KUBERNETES_HARDENING_GUIDANCE_1.2_20220829.PDF">url&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>CIS Benchmark for Kubernetes v1.23&lt;/td>
&lt;td>k8s-cis&lt;/td>
&lt;td>&lt;a href="https://www.cisecurity.org/benchmark/kubernetes">url&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pod Security Standards, Baseline&lt;/td>
&lt;td>k8s-pss-baseline&lt;/td>
&lt;td>&lt;a href="https://kubernetes.io/docs/concepts/security/pod-security-standards/#baseline">url&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Pod Security Standards, Restricted&lt;/td>
&lt;td>k8s-pss-restricted&lt;/td>
&lt;td>&lt;a href="https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted">url&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>这里使用 k8s cis 规范进行检查，同 &lt;code>kube-beach&lt;/code>：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy k8s cluster &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --config trivy.yaml &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --scanners vuln &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --report summary &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span> --compliance&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>k8s-cis
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="java">Java&lt;/h3>
&lt;p>TODO;&lt;/p>
&lt;h2 id="应用案例实践">应用案例实践&lt;/h2>
&lt;h3 id="容器镜像扫描">容器镜像扫描&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy --cache-dir ./cache/ image docker.io/bitnami/redis:7.2.3-debian-11-r2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>预先下载漏洞库至本地目录 &amp;ldquo;./cache&amp;rdquo;，否则会在线下载。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy --cache-dir ./cache/ image docker.io/bitnami/redis:7.2.3-debian-11-r2 --report summary --severity UNKNOWN,HIGH,CRITICAL
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>仅列出 &amp;ldquo;HIGH&amp;rdquo; 与 &amp;ldquo;CRITICAL&amp;rdquo; 级别漏洞。&lt;/p>
&lt;h3 id="k8s-集群扫描">K8S 集群扫描&lt;/h3>
&lt;p>使用本地病毒库&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>trivy --cache-dir ./cache/ k8s -n kube-system --report summary all
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="业务开发代码仓库">业务开发代码仓库&lt;/h3>
&lt;p>TODO;&lt;/p>
&lt;h3 id="基础设施既代码">基础设施既代码&lt;/h3>
&lt;p>TODO;&lt;/p></description></item></channel></rss>