2
1

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.

【Gradle】Kotlin DSLで依存ライブラリの脆弱性を解析する

Last updated at Posted at 2019-08-09

この記事ではorg.owasp.dependencycheck 5.2.1を使ってGradle.ktsで依存ライブラリの脆弱性を解析します。

やり方

今回はIntellij IDEAのSpring Initializrで生成したSpring-Bootプロジェクトのbuild.gradle.ktsに追記してorg.owasp.dependencycheckを導入します。

導入結果

早速ですが、以下が導入結果です。
追加部分はコメントのとおりです。

公式にKotlin DSLでの記法も載っているので、コピペして貼り付けるだけで動きます。

build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// 追加
buildscript {
    repositories {
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
    dependencies {
        classpath("org.owasp:dependency-check-gradle:5.2.1")
    }
}

// 追加
apply(plugin = "org.owasp.dependencycheck")

plugins {
    id("org.owasp.dependencycheck") version "5.2.1" // 追加
    id("org.springframework.boot") version "2.1.7.RELEASE"
    id("io.spring.dependency-management") version "1.0.7.RELEASE"
    kotlin("jvm") version "1.2.71"
    kotlin("plugin.spring") version "1.2.71"
}

group = "com.wrongwrong"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}

実行

Gradle -> Tasks -> owasp dependency-check -> dependencyCheckAnalyzeで実行します。
image.png

すると、チェック結果がbuild/reports/dependency-checck-report.htmlが出力されます。
image.png

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?