【问题标题】:OWASP Tricks to speed up vulnerabilities checks加速漏洞检查的 OWASP 技巧
【发布时间】:2023-01-04 17:13:03
【问题描述】:

我使用带有 OWASP 插件的 Maven 项目来检查 CI 拉取请求中每个提交的漏洞。 配置看起来很简单

<plugin>
                        <groupId>org.owasp</groupId>
                        <artifactId>dependency-check-maven</artifactId>
                        <version>${version.dependency-check-maven}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>aggregate</goal>
                                </goals>
                                <phase>verify</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <showSummary>true</showSummary>
                            <!-- this will work only in the top-level maven module -->
                            <suppressionFile>${user.dir}/owasp-suppressions.xml</suppressionFile>
                            <format>ALL</format>
                            <failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
                            <!-- alternative: fail on level (High starts at 7, Critical at 9) -->
                            <!-- <failBuildOnCVSS>4</failBuildOnCVSS> -->
                            <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
                            <cveUrlModified>address of the NVD local mirror</cveUrlModified>
                            <cveUrlBase>address of the NVD local mirror</cveUrlBase>
                            <cveWaitTime>1</cveWaitTime> <!--value in milliseconds, default is 4000-->
                        </configuration>
                    </plugin>

对于 CI 构建,我使用 PROW - https://docs.prow.k8s.io/docs/overview/ 对于本地镜像方法,这里描述了https://jeremylong.github.io/DependencyCheck/data/mirrornvd.html,镜像从这里使用https://github.com/stevespringett/nist-data-mirror/

从镜像下载 CVE 的过程仍然需要很长时间(大约 3 分钟)。从日志中我可以看到大部分时间花在下载 CVE 上

[INFO] Download Started for NVD CVE - 2003
[INFO] Download Complete for NVD CVE - 2003  (5 ms)
[INFO] Processing Started for NVD CVE - 2003
[INFO] Processing Complete for NVD CVE - 2002  (4608 ms)
[INFO] Processing Complete for NVD CVE - 2003  (1131 ms)
...

并进行一些数据库维护?

[INFO] Begin database maintenance
[INFO] Updated the CPE ecosystem on 128773 NVD records
[INFO] Removed the CPE ecosystem on 3604 NVD records
[INFO] End database maintenance (13482 ms)
[INFO] Begin database defrag
[INFO] End database defrag (3765 ms)
[INFO] Check for updates complete (112132 ms)

你知道加速 OWASP 检查的任何技巧吗?

【问题讨论】:

    标签: maven owasp


    【解决方案1】:

    这是在另一个线程上回复的:How to cache OWASP dependecy check NVD database on CI

    基本上你需要告诉 PROW 缓存 NVD 数据库的位置,当使用 Maven 插件时,它是:

    $MAVEN_HOME/.m2/repository/org/owasp/dependency-check-data/7.0/nvdcache/

    ** 考虑到您使用依赖检查版本 7.+

    【讨论】: