Skip to content

Commit

Permalink
Merge branch 'main' into rh/aggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
fwendland authored Mar 25, 2024
2 parents 3ce89da + 1a09888 commit 56c65b5
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
docker push ghcr.io/fraunhofer-aisec/codyze:latest
- name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
name: ${{ env.version }}
generate_release_notes: true
Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
# Ensure Java installation to run Gradle
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
- name: 'Setup Gradle'
uses: gradle/actions/setup-gradle@v3
- name: 'Build API pages'
run: |
./gradlew dokkaHtmlMultiModule \
-Dorg.gradle.internal.repository.max.tentatives=5 \
-Dorg.gradle.internal.repository.initial.backoff=10000
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: actions/cache@v4
with:
key: ${{ github.ref }}
path: .cache
cache: 'pip'
cache-dependency-path: './docs/mkdocs-material-plugins.txt'
- name: 'Install mkdocs-material and plugins'
run: |
python -m pip install mkdocs-material
python -m pip install -r ./docs/mkdocs-material-plugins.txt
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: 'Build API pages'
run: |
./gradlew
dokkaHtmlMultiModule
-Dorg.gradle.internal.repository.max.tentatives=5
-Dorg.gradle.internal.repository.initial.backoff=10000
- name: 'Build & deploy docs'
run: mkdocs gh-deploy --force
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ val projectProps by tasks.registering(WriteProperties::class) {
description = "Write project properties in a file."

// Set output file to build/project.properties
outputFile = file("$buildDir/codyze.properties")
destinationFile = layout.buildDirectory.file("codyze.properties")
// Default encoding is ISO-8559-1, here we change it.
encoding = "UTF-8"
// Optionally we can specify the header comment.
Expand All @@ -62,7 +62,7 @@ val projectProps by tasks.registering(WriteProperties::class) {
}
}

// configure detekt to combine the results of all submodules into a single sarif file -> for github code scanning
// configure detekt to combine the results of all submodules into a single sarif file -> for GitHub code scanning
val detektReportMergeSarif by tasks.registering(ReportMergeTask::class) {
output.set(rootProject.layout.buildDirectory.file("reports/detekt/detekt.sarif"))
}
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
// Unit tests
testImplementation(kotlin("test"))
testImplementation(libs.junit.params)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

repositories {
Expand All @@ -37,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 BaseCpgBackend : 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 CokoCpgBackend : 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 @@ -116,7 +116,7 @@ class OrderEvaluator(val baseNodes: Collection<Node>, val order: Order) : Evalua
val usedBases =
syntaxTree.filterIsInstanceToList<TerminalOrderNode>().map { it.baseName }.toSet()
if (usedBases.size > 1) {
logger.warn("Order statement contains more than one base. Not supported.")
logger.warn { "Order statement contains more than one base. Not supported." }
return emptySet()
}

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 Down Expand Up @@ -86,7 +83,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 +103,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
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 @@ -37,7 +37,7 @@ object VersionProvider {
if (
!props.containsKey("project.name") || props.getProperty("project.name").lowercase() != "codyze"
) {
logger.warn("Could not find correct version properties file")
logger.warn { "Could not find correct version properties file" }
props.clear()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.fraunhofer.aisec.codyze.core

import org.junit.jupiter.api.Test
import java.io.FileOutputStream
import java.util.Properties
import kotlin.test.assertEquals

class VersionProviderTest {

@Test
fun `test initialisation from properties file with incorrect project name`() {
val properties = Properties()

/* get the property file and load it; we want to fail if we can't find the property file to begin with */
val propFile = VersionProvider::class.java.classLoader.getResource("codyze.properties")!!
propFile.openStream().use {
properties.load(it)
}

// change property s.t. internal check fails
val oldValue = properties.setProperty("project.name", "test") as String
FileOutputStream(propFile.file).use {
properties.store(it, null)
}

// instantiate `VersionProvider` with altered properties -> properties in VersionProvider should now be empty
val vp = VersionProvider

// check empty properties through reflection
val vpProps = vp.javaClass.getDeclaredField("props")
.also { it.trySetAccessible() }
.let { it.get(vp) as Properties }
assertEquals(vpProps.size, 0)

// restore original properties file
properties.setProperty("project.name", oldValue)
FileOutputStream(propFile.file).use {
properties.store(it, null)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class CokoCpgIntegrationTest {
CPGConfiguration(
source = sourceFiles,
useUnityBuild = false,
typeSystemActiveInFrontend = true,
debugParser = false,
disableCleanup = false,
codeInNodes = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-sqlite3 v1.14.14 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
golang.org/x/crypto v0.17.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[versions]
kotlin = "1.9.22"
cpg = "7.1.2"
kotlin = "1.9.23"
cpg = "8.1.2"
koin = "3.5.3"
koin-test = "3.5.3"
detekt = "1.23.5"
spotless = "6.25.0"
dokka = "1.9.10"
dokka = "1.9.20"


[libraries]
sarif4k = { module = "io.github.detekt.sarif4k:sarif4k", version = "0.5.0"} # The code can be found here: https://github.com/detekt/sarif4k. It was generated using https://app.quicktype.io/
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.2"}
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.3"}
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin"}

# CPG official releases
Expand All @@ -29,7 +29,7 @@ cpg-language-java = { module = "de.fraunhofer.aisec:cpg-language-java", version.
#cpg-language-go = { module = "com.github.Fraunhofer-AISEC.cpg:cpg-language-go", version.ref = "cpg"}

kotlin-logging = { module = "io.github.oshai:kotlin-logging-jvm", version = "6.0.3" }
log4j-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version = "2.22.1"}
log4j-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version = "2.23.1"}
clikt = { module = "com.github.ajalt.clikt:clikt", version = "4.2.2"}
koin = { module = "io.insert-koin:koin-core", version.ref = "koin"}
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin-test"}
Expand All @@ -42,7 +42,7 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting",

# test
junit-params = { module = "org.junit.jupiter:junit-jupiter-params", version = "5.10.2"}
mockk = { module = "io.mockk:mockk", version = "1.13.9"}
mockk = { module = "io.mockk:mockk", version = "1.13.10"}

# this is necessary for the plugins to be used in the buildSrc folder
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading

0 comments on commit 56c65b5

Please sign in to comment.