3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Maven】OWASP Dependency Checkで警告を抑制する

Last updated at Posted at 2019-07-05

やること

OWASP Dependency Checkでは、failBuildOnCVSSを指定することで任意のスコア以上の脆弱性があった場合にビルドを失敗させることができます。
一方、このチェックで引っ掛けて欲しくない脆弱性も有ったりします(e.g. Windows環境でのみ発生するが、使う環境がWindowsでない場合など)。

pom.xml
<!-- 省略 -->
<plugin>
    <groupId>org.owasp</groupId>
    <artifactId>dependency-check-maven</artifactId>
    <version>5.0.0</version>
    <configuration>
        <!-- CVEスコア8以上で落とす設定 -->
        <failBuildOnCVSS>8</failBuildOnCVSS>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<!-- 省略 -->

ということで、一部脆弱性に関する警告を抑制(無視)する設定をします。

やり方

SuppressionFileを用意した上でconfigurationsuppressionFilesを設定すればできます。

SuppressionFileを用意する

まず抑制する内容について記述したSuppressionFileを用意します。
ファイル名は任意ですが、今回はowasp-dependency-check-suppressions.xmlとしています。
このファイルの内容は現在自分がやっているプロジェクトから取ってきたものです(コメントに関しては一部修正しているので実際はもっと詳細に調査しています)。

owasp-dependency-check-suppressions.xml
<?xml version="1.0" encoding="UTF-8"?>
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.2.xsd">
    <!-- OWASPの脆弱性チェックで無視する内容(xmlnsの最新版は1.3だが、1.3だとエラーが出て機能しないため1.2にしている) -->
    <suppress>
        <notes><![CDATA[
        Spring Security 5.0.5と任意のバージョンのSpring Securityを組み合わせた時に発生する脆弱性。
        このプロジェクトではSpring Security 5.0.5を使っていないため無視する。
        ]]></notes>
        <cve>CVE-2018-1258</cve>
    </suppress>
    <suppress>
        <notes><![CDATA[
        MySqlのコネクションに関する脆弱性。
        このプロジェクトでは特に問題にはならないため無視する。
        ]]></notes>
        <cve>CVE-2018-3258</cve>
    </suppress>
    <suppress>
        <notes><![CDATA[
        Windows環境でTomcatを動かした場合に発生する脆弱性。
        このプロジェクトはプロダクション環境がWindowsでないため無視する。
        ]]></notes>
        <cve>CVE-2019-0232</cve>
    </suppress>
</suppressions>

補足

dependency-suppressionは1.3が記事公開時点で最新かつ公式のサンプルもこのバージョンが指定されていますが、1.2を指定しないと複数環境で動かなかったので、今回は1.2を指定しています(エラーに関して自分が書いた記事です)。

configurationにsuppressionFilesを設定する

次にconfiguration内に用意したファイルのパスを設定することで、設定が有効になります。
owasp-dependency-check-suppressions.xmlはpomと同じ階層に置いた場合を想定しています。
suppressionを有効にした状態でチェックをした場合、Reportにもその内容は表示されなくなります。

pom.xml(追記後)
<plugin>
    <groupId>org.owasp</groupId>
    <artifactId>dependency-check-maven</artifactId>
    <version>5.0.0</version>
    <configuration>
        <failBuildOnCVSS>8</failBuildOnCVSS>
        <suppressionFiles>
            <suppressionFile>owasp-dependency-check-suppressions.xml</suppressionFile>
        </suppressionFiles>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>

より詳しい内容

今回はCVEを個別に設定しましたが、他にも様々な設定方法が有るので、より詳しくは公式サイトを参照してください。
SuppressionFileをURLで指定するだとか、あるpackageからの内容を無視するといったことも可能です。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?