This repository was archived by the owner on Oct 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify and document running of scanners (#10)
* Remove `-` from plugin name + work on install.sh * Fix install script * Update README. * Basic output routine for findings * Test install and scanning * Fix pr.yml * Fix pr.yml * Fix yml? * Fix pr build? * Fix? * test * test again * Remove lihayou deps * Remove debug lines.
- Loading branch information
Showing
14 changed files
with
196 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/scala/io/joern/scanners/c/vulnscan/HeapBasedOverflow.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/scala/io/joern/scanners/language/ScannerStarters.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.joern.scanners.language | ||
|
||
import io.shiftleft.codepropertygraph.Cpg | ||
import io.shiftleft.codepropertygraph.generated.{NodeTypes, nodes} | ||
import overflowdb.traversal._ | ||
|
||
class ScannerStarters(val cpg: Cpg) extends AnyVal { | ||
|
||
def finding: Traversal[nodes.Finding] = | ||
cpg.graph.nodes(NodeTypes.FINDING).cast[nodes.Finding] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.joern.scanners | ||
|
||
import io.shiftleft.codepropertygraph.Cpg | ||
import io.shiftleft.codepropertygraph.generated.{NodeTypes, nodes} | ||
import overflowdb.traversal._ | ||
import io.shiftleft.semanticcpg.language._ | ||
|
||
package object language { | ||
|
||
implicit def toScannerStarters(cpg: Cpg): ScannerStarters = | ||
new ScannerStarters(cpg) | ||
|
||
object FindingKeys { | ||
val title = "title" | ||
val description = "description" | ||
val score = "score" | ||
} | ||
|
||
implicit class ScannerFindingStep(val traversal: Traversal[nodes.Finding]) | ||
extends AnyRef { | ||
|
||
def title: Traversal[String] = traversal.map(_.title) | ||
|
||
def description: Traversal[String] = traversal.map(_.description) | ||
|
||
def score: Traversal[Double] = traversal.map(_.score) | ||
|
||
} | ||
|
||
implicit class ScannerFindingExtension(val node: nodes.Finding) | ||
extends AnyRef { | ||
|
||
def title: String = getValue(FindingKeys.title) | ||
|
||
def description: String = getValue(FindingKeys.description) | ||
|
||
def score: Double = getValue(FindingKeys.score).toDouble | ||
|
||
protected def getValue(key: String, default: String = ""): String = | ||
node.keyValuePairs.find(_.key == key).map(_.value).getOrElse(default) | ||
|
||
} | ||
|
||
def finding(evidence: nodes.StoredNode, | ||
title: String, | ||
description: String, | ||
score: Double): nodes.NewFinding = { | ||
nodes.NewFinding( | ||
evidence = List(evidence), | ||
keyValuePairs = List( | ||
nodes.NewKeyValuePair(FindingKeys.title, title), | ||
nodes.NewKeyValuePair(FindingKeys.description, description), | ||
nodes.NewKeyValuePair(FindingKeys.score, score.toString) | ||
) | ||
) | ||
} | ||
|
||
def outputFindings(cpg: Cpg): Unit = { | ||
cpg.finding.sortBy(_.score.toInt).foreach { finding => | ||
val evidence = finding.evidence.headOption | ||
.map { e => | ||
s"${e.location.filename}:${e.location.lineNumber.getOrElse(0)}:${e.location.methodFullName}" | ||
} | ||
.getOrElse("") | ||
println(s"Result: ${finding.score} : ${finding.title}: $evidence") | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.