Skip to content

Commit

Permalink
🐛 Fixed Invalid Call Edges (#65)
Browse files Browse the repository at this point in the history
* ✨ Improved build dir initialization and clean up

* 🐛 Fixed ampersands in xml

* 🐛 Fixed non-call vertices being sources of calls

* Added fixes to 0.1.7
  • Loading branch information
DavidBakerEffendi authored Feb 11, 2021
1 parent f1d4214 commit cb279e2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- Module not found bug introduced by improper class cleanup in temp dir.
- Fixed instances where CallGraphBuilder would connect non-NewCallBuilder source nodes to methods.
- Fixed GraphML not escaping ampersands

## [0.1.6] - 2021-02-10

Expand Down
6 changes: 5 additions & 1 deletion plume/src/main/kotlin/io/github/plume/oss/Extractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class Extractor(val driver: IDriver) {
private lateinit var programStructure: Graph

init {
File(COMP_DIR).let { f ->
if (f.exists()) f.deleteRecursively()
f.deleteOnExit()
}
checkDriverConnection(driver)
astBuilder = ASTBuilder(driver)
cfgBuilder = CFGBuilder(driver)
Expand Down Expand Up @@ -188,7 +192,7 @@ class Extractor(val driver: IDriver) {
*/
@Throws(PlumeCompileException::class, NullPointerException::class, IOException::class)
fun load(f: File) {
if (!File(COMP_DIR).exists()) File(COMP_DIR).mkdirs()
File(COMP_DIR).let { c -> if (!c.exists()) c.mkdirs() }
if (!f.exists()) {
throw NullPointerException("File '${f.name}' does not exist!")
} else if (f.isDirectory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CallGraphBuilder(private val driver: IDriver) : IGraphBuilder {
// If Soot points to the assignment as the call source then this is most likely from the rightOp. Let's
// hope this is not the source of a bug
val srcUnit = if (unit is AssignStmt) unit.rightOp else unit
getSootAssociation(srcUnit)?.firstOrNull()?.let { srcPlumeVertex ->
getSootAssociation(srcUnit)?.filterIsInstance<NewCallBuilder>()?.firstOrNull()?.let { srcPlumeVertex ->
val tgtPlumeVertex = getSootAssociation(e.tgt.method())?.firstOrNull()
?: constructPhantom(e.tgt.method(), driver)
runCatching {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ object GraphMLWriter {

private fun escape(o: Any) =
when (o) {
is String -> o.replace("<", "&lt;").replace(">", "&gt;")
is String -> o
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace("&", "&amp;")
is `$colon$colon`<*> -> o.head()
is `Nil$` -> ""
else -> o.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class BasicExtractorTest {
extractor.load(validJarFile)
extractor.project()
g = driver.getWholeGraph()
GraphMLWriter.write(g, FileWriter("/tmp/plume/x.xml"))
g = driver.getProgramStructure()
val ns = g.nodes().asSequence().toList()
ns.filterIsInstance<ODBFile>().let { fileList ->
Expand Down

0 comments on commit cb279e2

Please sign in to comment.