IntelliJのgradleプロジェクトにowasp dependency checkを導入する
概要
- 開発段階で、依存ライブラリに脆弱性が見つかる場合が多々あるが、自動的に検出したい。
- gradleプラグインの「owasp dependency check」は、依存ライブラリを、NISTが主催するNVD(National Vulnerability Database)のデータと照合し、既知の脆弱をレポート(CVSSスコア、CVE区分など)する。
- IntelliJのgradleプロジェクトに「owasp dependency check」を導入し、依存ライブラリの脆弱性を検出するタスクを実践してみる。
- 設定はbuild.gradleのみ、実行もgradleタスクなので、他のIDE(eclipse)でも同様に導入可能。
環境
- OWASP dependency-check-gradle plugin 3.3.1
- gradle: 4.8
- IntelliJ IDEA 2018.2.2 (Community Edition) Build #IC-182.4129.33, built on August 21, 2018
- macOS 10.13.4
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-gradle plugin 3.3.1
- gradle: 4.8
- IntelliJ IDEA 2018.2.2 (Community Edition) Build #IC-182.4129.33, built on August 21, 2018
- macOS 10.13.4
gradleへのプラグイン追加
- build.gradleへのプラグイン定義追加
plugins {
id 'java'
// ↓の一行の追加のみでOK
id "org.owasp.dependencycheck" version "3.3.1"
}
- gradleプロジェクトツールウィンドウで「Refresh all Gradle projects」を実行すると、以下の「owasp dependency-check」タスクフォルダが現れる。
plugins {
id 'java'
// ↓の一行の追加のみでOK
id "org.owasp.dependencycheck" version "3.3.1"
}
プロジェクト構成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)が出力されます。
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
- 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'.
プロジェクト構成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
- 依存する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
- 脆弱性は検出されない。
> 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'.
Author And Source
この問題について(IntelliJのgradleプロジェクトにowasp dependency checkを導入する), 我々は、より多くの情報をここで見つけました https://qiita.com/thetsuthetsu/items/180775fe1d4db22f0c85著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .