Skip to content

Commit

Permalink
CPG Console (#435)
Browse files Browse the repository at this point in the history
* ++

* Added CPG console plugins

* Added value resolver

* starting out of bounds check

* byName now supports a simple nested level

* Shorter, more concise toString() output for console

* Fixed test

* Simple Nullpointer detection

* Fixed go tests

* Code cleanup. Added CouldNotResolve class

* nice formatting of NPE

* First attempt at code coloring

* First integration of syntax highlighting in console

* Added more coloring

* Even more syntax highlighting

* Tutorial

* added tutorial

* tutorial ++, but needs more shortcut functions

* Playing around with formatting

* Fixed stuff

* ++

* ++

* ++

* ++

* better tostring

* ++

* Deactivate go as default language

* Revert "Deactivate go as default language"

This reverts commit a0be96c.

* Some cleanup

* Removing addition of experimental language

Co-authored-by: Konrad Weiss <[email protected]>
  • Loading branch information
oxisto and konradweiss authored Jun 22, 2021
1 parent 856e233 commit 866e599
Show file tree
Hide file tree
Showing 56 changed files with 2,125 additions and 142 deletions.
6 changes: 6 additions & 0 deletions cpg-console/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

5 changes: 5 additions & 0 deletions cpg-console/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
17 changes: 17 additions & 0 deletions cpg-console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CPG Console

```bash
../gradlew installDist
build/install/cpg-console/bin/cpg-console
```

The following example snippet can be used:

```kotlin
:a src/test/resources/array.cpp
var tu = result.translationUnits.first()
var main = tu.byName<FunctionDeclaration>("main")
:code main?
var decl = main?.body<DeclarationStatement>(0)
var v = decl?.singleDeclaration as? VariableDeclaration
```
63 changes: 63 additions & 0 deletions cpg-console/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2021, 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.
*
* $$$$$$\ $$$$$$$\ $$$$$$\
* $$ __$$\ $$ __$$\ $$ __$$\
* $$ / \__|$$ | $$ |$$ / \__|
* $$ | $$$$$$$ |$$ |$$$$\
* $$ | $$ ____/ $$ |\_$$ |
* $$ | $$\ $$ | $$ | $$ |
* \$$$$$ |$$ | \$$$$$ |
* \______/ \__| \______/
*
*/
plugins {
application
}

application {
mainClass.set("de.fraunhofer.aisec.cpg.console.CpgConsole")
}

tasks.withType<Test> {
useJUnitPlatform {
if (!project.hasProperty("integration")) {
excludeTags("integration")
}
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8" // important, since ki is 1.8 and otherwise inlining wont work
}

val versions = mapOf(
"junit5" to "5.6.0"
)

dependencies {
// CPG
api(project(":cpg-library"))
api(project(":cpg-neo4j"))

// JUnit
testImplementation("org.junit.jupiter", "junit-jupiter-api", versions["junit5"])
testImplementation("org.junit.jupiter", "junit-jupiter-params", versions["junit5"])
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", versions["junit5"])

implementation("org.jline:jline:3.20.0")

implementation("org.jetbrains.kotlinx:ki-shell:0.3.3")
}
Loading

0 comments on commit 866e599

Please sign in to comment.