Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external distribution of Juliet test suite #155

Merged
merged 7 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ allprojects {

repositories {
mavenCentral()
maven("https://jitpack.io")
maven("https://s01.oss.sonatype.org/content/repositories/orgunittestbotsoot-1004/")
maven("https://plugins.gradle.org/m2")
maven("https://www.jetbrains.com/intellij-repository/releases")
Expand Down
15 changes: 15 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ object Versions {
const val jmh = "1.21"
const val joda_time = "2.12.5"
const val jooq = "3.14.16"
const val juliet = "1.3.2"
const val junit = "5.9.2"
const val kotlin = "1.7.21"
const val kotlin_logging = "1.8.3"
Expand Down Expand Up @@ -265,6 +266,20 @@ object Libs {
name = "asm-util",
version = Versions.asm
)

// https://github.com/UnitTestBot/juliet-java-test-suite
val juliet_support = dep(
group = "com.github.UnitTestBot.juliet-java-test-suite",
name = "support",
version = Versions.juliet
)

@Suppress("FunctionName")
fun juliet_cwe(cweNum: Int) = dep(
group = "com.github.UnitTestBot.juliet-java-test-suite",
name = "cwe${cweNum}",
version = Versions.juliet
)
}

object Plugins {
Expand Down
9 changes: 6 additions & 3 deletions jacodb-analysis/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ dependencies {
implementation(Libs.kotlinx_serialization_json)

testImplementation(testFixtures(project(":jacodb-core")))
testImplementation(Libs.javax_servlet_api)
testImplementation(Libs.joda_time)
testImplementation(files("src/test/resources/juliet.jar"))
testImplementation(project(":jacodb-api"))
testImplementation(files("src/test/resources/pointerbench.jar"))
testImplementation(Libs.joda_time)
testImplementation(Libs.juliet_support)
for (cweNum in listOf(89, 476, 563, 690)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to store such settings in gradle.properties

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, only these CWEs are supported by an existing analysis (afaik), so we only depend on them, but in the future the list will probably grow and might even be replaced with a whole suite.

Gradle properties are just Strings, aren't they? The simple listOf in dependencies {} seems to be cleaner than parsing [89, 476, 563, 690] string into a list of ints.

testImplementation(Libs.juliet_cwe(cweNum))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.jacodb.analysis.impl

import juliet.testcasesupport.AbstractTestCase
import juliet.support.AbstractTestCase
import kotlinx.coroutines.runBlocking
import org.jacodb.analysis.engine.VulnerabilityInstance
import org.jacodb.api.JcClassOrInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import java.util.stream.Stream
class SqlInjectionAnalysisTest : BaseAnalysisTest() {
companion object : WithDB(Usages, InMemoryHierarchy) {
@JvmStatic
fun provideClassesForJuliet89(): Stream<Arguments> = provideClassesForJuliet(89, emptyList())
fun provideClassesForJuliet89(): Stream<Arguments> = provideClassesForJuliet(89, listOf(
// Not working yet (#156)
"s03", "s04"
))

private val vulnerabilityType = SqlInjectionAnalyzer.vulnerabilityDescription.ruleId
}
Expand Down
Binary file removed jacodb-analysis/src/test/resources/juliet.jar
Binary file not shown.