diff --git a/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/RuleRunner.kt b/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/RuleRunner.kt index 40792aad08..2c27d19296 100644 --- a/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/RuleRunner.kt +++ b/cpg-analysis/src/main/kotlin/de/fraunhofer/aisec/cpg/query/RuleRunner.kt @@ -25,7 +25,6 @@ */ package de.fraunhofer.aisec.cpg.query -// import de.fraunhofer.aisec.cpg.rules.* import de.fraunhofer.aisec.cpg.TranslationConfiguration import de.fraunhofer.aisec.cpg.TranslationManager import de.fraunhofer.aisec.cpg.TranslationResult @@ -101,6 +100,8 @@ class RuleRunner( } .loadIncludes(loadIncludes) .defaultPasses() + .useParallelFrontends(true) + .useParallelPasses(true) .build() private val result: TranslationResult = @@ -148,7 +149,7 @@ private class Cli : Runnable { return try { Language.valueOf(value!!.uppercase()) } catch (_: Exception) { - throw CommandLine.ParameterException(CommandLine(this), "Invalid language: $value") + throw CommandLine.ParameterException(CommandLine(this), "Invalid language:$value") } // TODO: maybe ignore or just warn } } @@ -192,14 +193,16 @@ private class Cli : Runnable { // TODO: add functionality // -> Pass-related options from the neo4j app - // -> don't hardcode rules but load them dynamically (may be similar to the pass system in the neo4j app) + // -> don't hardcode rules but load them dynamically (may be similar to the pass system in the + // neo4j app) /** * Runs the rules on the given compilation database and reports the results. * - * The rules are currently built into the application and cannot be changed without modifying the source code. - * The output is a SARIF file because currently the only [Reporter] is the [SarifReporter]. - * The report's path is determined by the [Reporter.getDefaultPath] method of the respective [Reporter]. + * The rules are currently built into the application and cannot be changed without modifying + * the source code. The output is a SARIF file because currently the only [Reporter] is the + * [SarifReporter]. The report's path is determined by the [Reporter.getDefaultPath] method of + * the respective [Reporter]. */ override fun run() { val runner = diff --git a/cpg-console/src/main/kotlin/de/fraunhofer/aisec/cpg/console/CpgConsole.kt b/cpg-console/src/main/kotlin/de/fraunhofer/aisec/cpg/console/CpgConsole.kt index 08b43d467a..697522de16 100644 --- a/cpg-console/src/main/kotlin/de/fraunhofer/aisec/cpg/console/CpgConsole.kt +++ b/cpg-console/src/main/kotlin/de/fraunhofer/aisec/cpg/console/CpgConsole.kt @@ -149,10 +149,10 @@ enum class Language { @CommandLine.Command( name = "cpg-analysis", description = - [ - "Either specify no arguments to start an interactive shell or specify a compilation database and rules to run" + + [ + "Either specify no arguments to start an interactive shell or specify a compilation database and rules to run" + " like a normal CLI tool." - ] + ] ) private class Cli : Runnable { @CommandLine.Option( @@ -195,22 +195,22 @@ private class Cli : Runnable { @CommandLine.Option( names = ["-o", "--output"], description = - [ - "Path to write the output to. If unspecified, a default path is used. Used to determine the " + + [ + "Path to write the output to. If unspecified, a default path is used. Used to determine the " + "report type (currently only SARIF). The default is SARIF." - ], + ], paramLabel = "FILE", ) var outputPath: File = Path.of( - "reports", - "report-${ + "reports", + "report-${ LocalDateTime.now().format( DateTimeFormatter.ofPattern ("yyyy-MM-dd-HH-mm-ss") ) }.sarif" - ) + ) .toFile() @CommandLine.Option( @@ -294,9 +294,11 @@ private class Cli : Runnable { // create the report results.add(reportPlugin.execute(":report ${outputPath.absolutePath} $minify")) - // the following code is a copy of parts of the org.jetbrains.kotlinx.ki.shell.Shell.doRun() method + // the following code is a copy of parts of the + // org.jetbrains.kotlinx.ki.shell.Shell.doRun() method // of the kotlin-interactive-shell licensed under the Apache License 2.0. - // This is necessary because we want to run the shell headless which isn't directly supported. + // This is necessary because we want to run the shell headless which isn't directly + // supported. // COPY START var blankLines = 0 fun evalSnippet(line: String) { @@ -318,7 +320,6 @@ private class Cli : Runnable { repl.incompleteLines.clear() repl.handleError(result.result, result.isCompiled) } - ResultWrapper.Status.SUCCESS -> { repl.incompleteLines.clear() repl.handleSuccess(result.result as ResultWithDiagnostics.Success<*>)