From bf6aaef5e272391db39ba7d6b523cd7cf1c5ee19 Mon Sep 17 00:00:00 2001 From: David Baker Effendi Date: Sun, 13 Mar 2022 22:43:25 +0200 Subject: [PATCH] Minor Soot + File Fixes (#243) * Minor soot fixes * Don't do application class --- CHANGELOG.md | 7 +++++++ src/main/scala/com/github/plume/oss/Jimple2Cpg.scala | 11 +++++------ .../github/plume/oss/util/ProgramHandlingUtil.scala | 1 - 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65d40aa9..cae9a3d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Fixed + +- No longer set `deleteOnExit` for files in temp dir since they get cleaned via try-final call already. +- Set Soot to non-application mode and non-whole program mode for efficiency. + ## [1.0.20] - 2022-03-11 ### Fixed diff --git a/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala b/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala index 850748cc..9c2d8c3d 100644 --- a/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala +++ b/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala @@ -197,12 +197,10 @@ class Jimple2Cpg { sourceFileNames .map(getQualifiedClassPath) .foreach { cp => - Scene.v().addBasicClass(cp, SootClass.BODIES) - Scene.v().loadClassAndSupport(cp).setApplicationClass() + Scene.v().addBasicClass(cp) + Scene.v().loadClassAndSupport(cp) } - Scene.v().loadDynamicClasses() Scene.v().loadNecessaryClasses() - Scene.v().addBasicClass("soot.dummy.InvokeDynamic", SootClass.SIGNATURES) } private def basePasses( @@ -238,9 +236,10 @@ class Jimple2Cpg { ).collect { case pass: CpgPassBase with PlumeCpgPassBase => pass } private def configureSoot(): Unit = { + logger.info("Configuring Soot") // set application mode - Options.v().set_app(true) - Options.v().set_whole_program(true) + Options.v().set_app(false) + Options.v().set_whole_program(false) // make sure classpath is configured correctly Options.v().set_soot_classpath(ProgramHandlingUtil.TEMP_DIR.toString) Options.v().set_prepend_classpath(true) diff --git a/src/main/scala/com/github/plume/oss/util/ProgramHandlingUtil.scala b/src/main/scala/com/github/plume/oss/util/ProgramHandlingUtil.scala index 97556099..4c4eb265 100644 --- a/src/main/scala/com/github/plume/oss/util/ProgramHandlingUtil.scala +++ b/src/main/scala/com/github/plume/oss/util/ProgramHandlingUtil.scala @@ -93,7 +93,6 @@ object ProgramHandlingUtil { Using.resource(zip.getInputStream(entry)) { input => Files.copy(input, destFile.toPath) } - destFile.deleteOnExit() Option(destFile.getAbsolutePath) } catch { case e: Exception =>