-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into dave/c#/call-nodes
- Loading branch information
Showing
29 changed files
with
356 additions
and
216 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
52 changes: 52 additions & 0 deletions
52
...lowengineoss/src/test/scala/io/joern/dataflowengineoss/testfixtures/SemanticTestCpg.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,52 @@ | ||
package io.joern.dataflowengineoss.testfixtures | ||
|
||
import io.joern.dataflowengineoss.DefaultSemantics | ||
import io.joern.dataflowengineoss.layers.dataflows.{OssDataFlow, OssDataFlowOptions} | ||
import io.joern.dataflowengineoss.queryengine.EngineContext | ||
import io.joern.dataflowengineoss.semanticsloader.{FlowSemantic, Semantics} | ||
import io.joern.x2cpg.testfixtures.TestCpg | ||
import io.shiftleft.semanticcpg.layers.LayerCreatorContext | ||
|
||
/** Extends the capabilities of the test CPG to handle the configuration of data-flow enhancements. | ||
*/ | ||
trait SemanticTestCpg { this: TestCpg => | ||
|
||
protected var _withOssDataflow = false | ||
protected var _extraFlows = List.empty[FlowSemantic] | ||
protected implicit var context: EngineContext = EngineContext() | ||
|
||
/** Allows one to enable data-flow analysis capabilities to the TestCpg. | ||
*/ | ||
def withOssDataflow(value: Boolean = true): this.type = { | ||
_withOssDataflow = value | ||
this | ||
} | ||
|
||
/** Allows one to add additional semantics to the engine context during PDG creation. | ||
*/ | ||
def withExtraFlows(value: List[FlowSemantic] = List.empty): this.type = { | ||
_extraFlows = value | ||
this | ||
} | ||
|
||
/** Some frontends require OSS data-flow to execute after post-processing, so we choose to expose this method without | ||
* defining where it's executed. | ||
*/ | ||
def applyOssDataFlow(): Unit = { | ||
if (_withOssDataflow) { | ||
val context = new LayerCreatorContext(this) | ||
val options = new OssDataFlowOptions(extraFlows = _extraFlows) | ||
new OssDataFlow(options).run(context) | ||
this.context = EngineContext(Semantics.fromList(DefaultSemantics().elements ++ _extraFlows)) | ||
} | ||
} | ||
|
||
} | ||
|
||
/** Allows the tests to make use of the data-flow engine and any additional semantics. | ||
*/ | ||
trait SemanticCpgTestFixture(extraFlows: List[FlowSemantic] = List.empty) { | ||
|
||
implicit val context: EngineContext = EngineContext(Semantics.fromList(DefaultSemantics().elements ++ extraFlows)) | ||
|
||
} |
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
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
Oops, something went wrong.