Skip to content

Commit

Permalink
fiX formatting errors in CpgConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusAlbrecht committed Oct 6, 2024
1 parent 8680f49 commit b2bca64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -101,6 +100,8 @@ class RuleRunner(
}
.loadIncludes(loadIncludes)
.defaultPasses()
.useParallelFrontends(true)
.useParallelPasses(true)
.build()

private val result: TranslationResult =
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand All @@ -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<*>)
Expand Down

0 comments on commit b2bca64

Please sign in to comment.