Skip to content

Commit

Permalink
Merge branch 'main' into clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
fwendland committed Apr 5, 2024
2 parents d28ef74 + 0cd0f2e commit cda722b
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 947 deletions.
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/code-quality.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ tasks.jacocoTestReport {
// a merged report
tasks.withType<Detekt>().configureEach {
basePath = "${rootProject.projectDir.absolutePath}"
config.setFrom(files("$rootDir/detekt.yml"))
buildUponDefaultConfig = true
config.setFrom(rootDir.resolve("detekt.yml"))
}

// custom task for fixing formatting issues
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repositories {

// Eclipse CDT repo --> needed for CPG
ivy {
setUrl("https://download.eclipse.org/tools/cdt/releases/11.0/cdt-11.0.0/plugins")
setUrl("https://download.eclipse.org/tools/cdt/releases/11.3/cdt-11.3.1/plugins")
metadataSources {
artifact()
}
Expand Down
2 changes: 1 addition & 1 deletion code-coverage-report/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {

// Eclipse CDT repo --> needed when adding the CPG as an included build
ivy {
setUrl("https://download.eclipse.org/tools/cdt/releases/11.0/cdt-11.0.0/plugins")
setUrl("https://download.eclipse.org/tools/cdt/releases/11.3/cdt-11.3.1/plugins")
metadataSources {
artifact()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ open class CPGBackend(config: BackendConfiguration) : Backend {
.processAnnotations(processAnnotations)
.failOnError(failOnError)
.useParallelFrontends(useParallelFrontends)
.typeSystemActiveInFrontend(typeSystemActiveInFrontend)
.sourceLocations(source.map { (it.toFile()) })
.symbols(symbols)
.useUnityBuild(useUnityBuild)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ private val logger = KotlinLogging.logger {}
data class CPGConfiguration(
val source: List<Path>,
val useUnityBuild: Boolean,
val typeSystemActiveInFrontend: Boolean,
val debugParser: Boolean,
val disableCleanup: Boolean,
val codeInNodes: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ class CPGOptionGroup : BackendOptions(helpName = "CPG Backend Options") {
help = "Enables unity builds (C++ only) for files in the path."
)
.flag("--no-unity", "--disable-unity", default = false)
val typeSystemActiveInFrontend: Boolean by option(
"--type-system-in-frontend",
help = "If deactivated, the type listener system starts after the frontends " +
"are done building the initial AST structure."
)
.flag(
"--no-type-system-in-frontend",
"--disable-type-system-in-frontend",
default = true,
defaultForHelp = "enable"
)
val debugParser: Boolean by option("--debug-parser", help = "Generate debug output for the cpg parser.")
.flag("--no-debug-parser", default = false)
val disableCleanup: Boolean by option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class BaseCpgBackendCommand : BackendCommand<CPGBackend>("cpg") {
CPGConfiguration(
source = source,
useUnityBuild = useUnityBuild,
typeSystemActiveInFrontend = typeSystemActiveInFrontend,
debugParser = debugParser,
disableCleanup = disableCleanup,
codeInNodes = codeInNodes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CokoCpgBackendCommand : BackendCommand<CokoBackend>("cokoCpg") {
CPGConfiguration(
source = source,
useUnityBuild = useUnityBuild,
typeSystemActiveInFrontend = typeSystemActiveInFrontend,
debugParser = debugParser,
disableCleanup = disableCleanup,
codeInNodes = codeInNodes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import de.fraunhofer.aisec.codyze.specificationLanguages.coko.core.dsl.Order
import de.fraunhofer.aisec.codyze.specificationLanguages.coko.core.ordering.*
import de.fraunhofer.aisec.cpg.graph.*
import de.fraunhofer.aisec.cpg.graph.declarations.VariableDeclaration
import de.fraunhofer.aisec.cpg.graph.statements.expressions.DeclaredReferenceExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.Reference
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlin.reflect.full.createType
import kotlin.reflect.full.declaredMemberFunctions
Expand Down Expand Up @@ -164,7 +164,7 @@ class OrderEvaluator(val baseNodes: Collection<Node>, val order: Order) : Evalua
nodeToRelevantMethod = nodesToOp,
consideredBases = baseNodes.flatMap { node ->
node.followNextDFGEdgesUntilHit { next ->
next is VariableDeclaration || next is DeclaredReferenceExpression
next is VariableDeclaration || next is Reference
}.fulfilled.mapNotNull { path ->
path.lastOrNull()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CPGConfigurationTest {
val expectedCpgConfiguration = CPGConfiguration(
source = listOf(),
useUnityBuild = true,
typeSystemActiveInFrontend = false,
debugParser = false,
disableCleanup = false,
codeInNodes = true,
Expand All @@ -46,7 +45,6 @@ class CPGConfigurationTest {
val cpgConfiguration = CPGConfiguration(
source = listOf(),
useUnityBuild = true,
typeSystemActiveInFrontend = false,
debugParser = false,
disableCleanup = false,
codeInNodes = true,
Expand Down Expand Up @@ -74,7 +72,6 @@ class CPGConfigurationTest {
val expectedCpgConfiguration = CPGConfiguration(
source = listOf(),
useUnityBuild = false,
typeSystemActiveInFrontend = false,
debugParser = false,
disableCleanup = false,
codeInNodes = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import com.github.ajalt.clikt.core.MultiUsageError
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.parameters.groups.provideDelegate
import de.fraunhofer.aisec.codyze.core.config.combineSources
import de.fraunhofer.aisec.cpg.passes.CallResolver
import de.fraunhofer.aisec.cpg.passes.EdgeCachePass
import de.fraunhofer.aisec.cpg.passes.FilenameMapper
import de.fraunhofer.aisec.cpg.passes.Pass
import de.fraunhofer.aisec.cpg.passes.*
import io.github.oshai.kotlinlogging.KotlinLogging
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Test
Expand All @@ -33,10 +30,7 @@ import org.junit.jupiter.params.provider.MethodSource
import java.nio.file.Files
import java.nio.file.Path
import java.util.stream.Stream
import kotlin.io.path.Path
import kotlin.io.path.absolute
import kotlin.io.path.div
import kotlin.io.path.isRegularFile
import kotlin.io.path.*
import kotlin.streams.asSequence
import kotlin.test.*

Expand Down Expand Up @@ -86,7 +80,7 @@ class CpgOptionGroupTest {
fun passesTest() {
val edgeCachePassName = EdgeCachePass::class.qualifiedName
val filenameMapperName = FilenameMapper::class.qualifiedName
val callResolverName = CallResolver::class.qualifiedName
val callResolverName = SymbolResolver::class.qualifiedName
assertNotNull(edgeCachePassName)
assertNotNull(filenameMapperName)
assertNotNull(callResolverName)
Expand All @@ -106,7 +100,7 @@ class CpgOptionGroupTest {
)

val expectedPassesNames =
listOf(EdgeCachePass::class, FilenameMapper::class, CallResolver::class).map { p ->
listOf(EdgeCachePass::class, FilenameMapper::class, SymbolResolver::class).map { p ->
p.qualifiedName
}
val actualPassesNames = cli.cpgOptions.passes.map { p -> p.qualifiedName }
Expand Down Expand Up @@ -226,19 +220,19 @@ class CpgOptionGroupTest {
val topTestDirResource =
CpgOptionGroupTest::class.java.classLoader.getResource("cli-test-directory")
assertNotNull(topTestDirResource)
topTestDir = Path(topTestDirResource.path)
topTestDir = topTestDirResource.toURI().toPath()
assertNotNull(topTestDir) // TODO: why is this necessary

val testDir1Resource =
CpgOptionGroupTest::class.java.classLoader.getResource("cli-test-directory/dir1")
assertNotNull(testDir1Resource)
testDir1 = Path(testDir1Resource.path)
testDir1 = testDir1Resource.toURI().toPath()
assertNotNull(testDir1)

val testDir2Resource =
CpgOptionGroupTest::class.java.classLoader.getResource("cli-test-directory/dir2")
assertNotNull(testDir2Resource)
testDir2 = Path(testDir2Resource.path)
testDir2 = testDir2Resource.toURI().toPath()
assertNotNull(testDir2)

val testFile1Resource =
Expand All @@ -247,7 +241,7 @@ class CpgOptionGroupTest {
.classLoader
.getResource("cli-test-directory/file1.java")
assertNotNull(testFile1Resource)
testFile1 = Path(testFile1Resource.path)
testFile1 = testFile1Resource.toURI().toPath()
assertNotNull(testFile1)

allFiles = Files.walk(topTestDir).asSequence().filter { it.isRegularFile() }.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class FollowsEvaluationTest {

val testFileResource = classLoader.getResource("FollowsEvaluationTest/SimpleFollows.java")
assertNotNull(testFileResource)
testFile = Path(testFileResource.path)
testFile = testFileResource.toURI().toPath()

val fooInstance = FooModel()
val barInstance = BarModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import de.fraunhofer.aisec.codyze.specificationLanguages.coko.core.dsl.op
import de.fraunhofer.aisec.codyze.specificationLanguages.coko.core.dsl.signature
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import kotlin.io.path.Path
import kotlin.io.path.toPath
import kotlin.test.assertEquals
import kotlin.test.assertNotNull

Expand Down Expand Up @@ -94,7 +94,7 @@ class ImplementationDslTest {

val testFileResource = classLoader.getResource("ImplementationDslTest/SimpleJavaFile.java")
assertNotNull(testFileResource)
val testFile = Path(testFileResource.path)
val testFile = testFileResource.toURI().toPath()
backend = CokoCpgBackend(config = createCpgConfiguration(testFile))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ class NeverEvaluationTest {

val violationFileResource = classLoader.getResource("NeverEvaluationTest/NeverViolation.java")
assertNotNull(violationFileResource)
violationFile = Path(violationFileResource.path)
violationFile = violationFileResource.toURI().toPath()

val passFileResource = classLoader.getResource("NeverEvaluationTest/NeverPass.java")
assertNotNull(passFileResource)
passFile = Path(passFileResource.path)
passFile = passFileResource.toURI().toPath()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class OnlyEvaluationTest {

val testFileResource = classLoader.getResource("OnlyEvaluationTest/SimpleOnly.java")
assertNotNull(testFileResource)
testFile = Path(testFileResource.path)
testFile = testFileResource.toURI().toPath()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ fun createCpgConfiguration(vararg sourceFile: Path) =
CPGConfiguration(
source = listOf(*sourceFile),
useUnityBuild = false,
typeSystemActiveInFrontend = true,
debugParser = false,
disableCleanup = false,
codeInNodes = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CodyzeCliTest : KoinTest {
val pathConfigFileResource =
CodyzeCliTest::class.java.classLoader.getResource("config-files/path-config.json")
assertNotNull(pathConfigFileResource)
pathConfigFile = Path(pathConfigFileResource.path)
pathConfigFile = pathConfigFileResource.toURI().toPath()
assertTrue(pathConfigFile.exists())

val correctConfigFileResource =
Expand All @@ -121,19 +121,19 @@ class CodyzeCliTest : KoinTest {
.classLoader
.getResource("config-files/correct-config.json")
assertNotNull(correctConfigFileResource)
correctConfigFile = Path(correctConfigFileResource.path)
correctConfigFile = correctConfigFileResource.toURI().toPath()
assertTrue(correctConfigFile.exists())

val specMarkResource =
CodyzeCliTest::class.java.classLoader.getResource("config-files/spec/spec.mark")
assertNotNull(specMarkResource)
specMark = Path(specMarkResource.path)
specMark = specMarkResource.toURI().toPath()
assertTrue(specMark.exists())

val specMark2Resource =
CodyzeCliTest::class.java.classLoader.getResource("config-files/spec2.mark")
assertNotNull(specMark2Resource)
spec2Mark = Path(specMark2Resource.path)
spec2Mark = specMark2Resource.toURI().toPath()
assertTrue(spec2Mark.exists())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ class CokoCpgIntegrationTest {
.getResource("IntegrationTests/CokoCpg/Main.java"),
CokoCpgIntegrationTest::class.java.classLoader
.getResource("IntegrationTests/CokoCpg/SimpleOrder.java")
).map { Path(it.path) }.also { assertEquals(2, it.size) }
).map { it.toURI().toPath() }.also { assertEquals(2, it.size) }

val cpgConfiguration =
CPGConfiguration(
source = sourceFiles,
useUnityBuild = false,
typeSystemActiveInFrontend = true,
debugParser = false,
disableCleanup = false,
codeInNodes = true,
Expand Down Expand Up @@ -73,7 +72,7 @@ class CokoCpgIntegrationTest {
.getResource("IntegrationTests/CokoCpg/orderFull.codyze.kts"),
CokoCpgIntegrationTest::class.java.classLoader
.getResource("IntegrationTests/CokoCpg/followedByFull.codyze.kts")
).map { Path(it.path) }.also { assertEquals(2, it.size) }
).map { it.toURI().toPath() }.also { assertEquals(2, it.size) }

val cokoConfiguration =
CokoConfiguration(
Expand Down Expand Up @@ -103,7 +102,7 @@ class CokoCpgIntegrationTest {
.getResource("IntegrationTests/CokoCpg/followedByTwoFiles/followedByImplementations.codyze.kts"),
CokoCpgIntegrationTest::class.java.classLoader
.getResource("IntegrationTests/CokoCpg/followedByTwoFiles/followedByModels.codyze.kts")
).map { Path(it.path) }.also { assertEquals(2, it.size) }
).map { it.toURI().toPath() }.also { assertEquals(2, it.size) }

val cokoConfiguration =
CokoConfiguration(
Expand Down Expand Up @@ -132,6 +131,7 @@ class CokoCpgIntegrationTest {
@MethodSource("threeFiles")
fun `test coko with cpg backend and permutation of three dependent spec files`(
specFiles: List<Path>,
@Suppress("detekt:style:UnusedParameter") // used for parameterized test names
fileNames: List<String>
) {
assertEquals(3, specFiles.size)
Expand Down Expand Up @@ -161,6 +161,7 @@ class CokoCpgIntegrationTest {
@MethodSource("fourFiles")
fun `test coko with cpg backend and permutation of four dependent spec files`(
specFiles: List<Path>,
@Suppress("detekt:style:UnusedParameter") // used for parameterized test names
fileNames: List<String>
) {
assertEquals(4, specFiles.size)
Expand Down Expand Up @@ -192,6 +193,7 @@ class CokoCpgIntegrationTest {
@MethodSource("fiveFiles")
fun `test coko with cpg backend and permutation of five dependent spec files`(
specFiles: List<Path>,
@Suppress("detekt:style:UnusedParameter") // used for parameterized test names
fileNames: List<String>
) {
assertEquals(5, specFiles.size)
Expand Down Expand Up @@ -219,7 +221,7 @@ class CokoCpgIntegrationTest {
fun `test coko with cpg backend without good findings`() {
val specFiles = listOfNotNull(
CokoCpgIntegrationTest::class.java.classLoader.getResource("IntegrationTests/CokoCpg/orderFull.codyze.kts"),
).map { Path(it.path) }.also { assertEquals(1, it.size) }
).map { it.toURI().toPath() }.also { assertEquals(1, it.size) }

val cokoConfiguration =
CokoConfiguration(
Expand Down Expand Up @@ -250,7 +252,7 @@ class CokoCpgIntegrationTest {
)
val permutations = fileMap.permutate()
for (p in permutations) {
val (specFiles, fileNames) = p.map { Path(it.path) }.map { it to it.fileName }.unzip()
val (specFiles, fileNames) = p.map { it.toURI().toPath() }.map { it to it.fileName }.unzip()
stream.add(
Arguments.of(
specFiles,
Expand All @@ -276,7 +278,7 @@ class CokoCpgIntegrationTest {
)
val permutations = fileMap.permutate()
for (p in permutations) {
val (specFiles, fileNames) = p.map { Path(it.path) }.map { it to it.fileName }.unzip()
val (specFiles, fileNames) = p.map { it.toURI().toPath() }.map { it to it.fileName }.unzip()
stream.add(
Arguments.of(
specFiles,
Expand Down Expand Up @@ -304,7 +306,7 @@ class CokoCpgIntegrationTest {
)
val permutations = fileMap.permutate()
for (p in permutations) {
val (specFiles, fileNames) = p.map { Path(it.path) }.map { it to it.fileName }.unzip()
val (specFiles, fileNames) = p.map { it.toURI().toPath() }.map { it to it.fileName }.unzip()
stream.add(
Arguments.of(
specFiles,
Expand Down
Loading

0 comments on commit cda722b

Please sign in to comment.