4
3

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.

IntelliJのgradleプロジェクトにowasp dependency checkを導入する

Last updated at Posted at 2018-08-31

#概要

  • 開発段階で、依存ライブラリに脆弱性が見つかる場合が多々あるが、自動的に検出したい。
  • gradleプラグインの「owasp dependency check」は、依存ライブラリを、NISTが主催するNVD(National Vulnerability Database)のデータと照合し、既知の脆弱をレポート(CVSSスコア、CVE区分など)する。
  • IntelliJのgradleプロジェクトに「owasp dependency check」を導入し、依存ライブラリの脆弱性を検出するタスクを実践してみる。
  • 設定はbuild.gradleのみ、実行もgradleタスクなので、他のIDE(eclipse)でも同様に導入可能。

#環境

#gradleへのプラグイン追加

  • build.gradleへのプラグイン定義追加


    plugins {
        id 'java'
        // ↓の一行の追加のみでOK
        id "org.owasp.dependencycheck" version "3.3.1"
    }

  • gradleプロジェクトツールウィンドウで「Refresh all Gradle projects」を実行すると、以下の「owasp dependency-check」タスクフォルダが現れる。

owasp dependency-checkタスク

#プロジェクト構成1 (あえて古いライブラリapache-shiro 1.3.0に依存)

  • dependenciesタスクを実行


    runtimeClasspath - Runtime classpath of source set 'main'.
    +--- ch.qos.logback:logback-core:1.2.3
    +--- ch.qos.logback:logback-classic:1.2.3
    |    +--- ch.qos.logback:logback-core:1.2.3
    |    \--- org.slf4j:slf4j-api:1.7.25
    +--- org.apache.shiro:shiro-core:1.3.0
    |    +--- org.slf4j:slf4j-api:1.6.4 -> 1.7.25
    |    \--- commons-beanutils:commons-beanutils:1.8.3
    \--- commons-logging:commons-logging:1.2

  • dependencyCheckAnalyzeを実行
    • commons-beanutils 1.8.3に脆弱性CVE-2014-0114が検出された模様。


    Task :dependencyCheckAnalyze
    Verifying dependencies for project JavaSample
    Checking for updates and analyzing dependencies for vulnerabilities
    Generating report for project JavaSample
    Found 1 vulnerabilities in project JavaSample
    
    One or more dependencies were identified with known vulnerabilities:
    
    commons-beanutils-1.8.3.jar: ids:(commons-beanutils:commons- 
    beanutils:1.8.3, cpe:/a:apache:commons_beanutils:1.8.3) : CVE-2014-0114
    
    See the dependency-check report for more details.
    
    BUILD SUCCESSFUL in 30s
    1 actionable task: 1 executed
    17:12:41: Task execution finished 'dependencyCheckAnalyze'.

  • build/reports/dependency-check-report.htmlに脆弱性の詳細な情報(Severity-High、CVSSスコア=7.5、CWE区分=20)が出力されます。

dependency-check-report.html

#プロジェクト構成2 (最新のapache-shiro 1.4.0に依存)

  • dependenciesタスクを実行。
    • 依存するcommons-beanutilsが1.9.3にUP


runtimeClasspath - Runtime classpath of source set 'main'.
+--- ch.qos.logback:logback-core:1.2.3
+--- ch.qos.logback:logback-classic:1.2.3
|    +--- ch.qos.logback:logback-core:1.2.3
|    \--- org.slf4j:slf4j-api:1.7.25
+--- org.apache.shiro:shiro-core:1.4.0
|    +--- org.apache.shiro:shiro-lang:1.4.0
|    |    \--- org.slf4j:slf4j-api:1.7.21 -> 1.7.25
|    +--- org.apache.shiro:shiro-cache:1.4.0
|    |    \--- org.apache.shiro:shiro-lang:1.4.0 (*)
|    +--- org.apache.shiro:shiro-crypto-hash:1.4.0
|    |    +--- org.apache.shiro:shiro-lang:1.4.0 (*)
|    |    \--- org.apache.shiro:shiro-crypto-core:1.4.0
|    |         \--- org.apache.shiro:shiro-lang:1.4.0 (*)
|    +--- org.apache.shiro:shiro-crypto-cipher:1.4.0
|    |    +--- org.apache.shiro:shiro-lang:1.4.0 (*)
|    |    \--- org.apache.shiro:shiro-crypto-core:1.4.0 (*)
|    +--- org.apache.shiro:shiro-config-core:1.4.0
|    |    \--- org.apache.shiro:shiro-lang:1.4.0 (*)
|    +--- org.apache.shiro:shiro-config-ogdl:1.4.0
|    |    +--- org.apache.shiro:shiro-lang:1.4.0 (*)
|    |    +--- org.apache.shiro:shiro-config-core:1.4.0 (*)
|    |    +--- org.apache.shiro:shiro-event:1.4.0
|    |    |    \--- org.apache.shiro:shiro-lang:1.4.0 (*)
|    |    +--- commons-beanutils:commons-beanutils:1.9.3
|    |    |    \--- commons-collections:commons-collections:3.2.2
|    |    \--- org.slf4j:slf4j-api:1.7.21 -> 1.7.25
|    \--- org.apache.shiro:shiro-event:1.4.0 (*)
\--- commons-logging:commons-logging:1.2

  • dependencyCheckAnalyzeを実行
    • 脆弱性は検出されない。


> Task :dependencyCheckAnalyze
Verifying dependencies for project JavaSample
Checking for updates and analyzing dependencies for vulnerabilities
Generating report for project JavaSample
Found 0 vulnerabilities in project JavaSample

BUILD SUCCESSFUL in 41s
1 actionable task: 1 executed
10:00:36: Task execution finished 'dependencyCheckAnalyze'.

  • build/reports/dependency-check-report.html

dependency-check-report.html2

4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?