From 24118380d402a4bb9064611a356ac3b070139db5 Mon Sep 17 00:00:00 2001 From: David Baker Effendi Date: Wed, 16 Mar 2022 19:53:47 +0200 Subject: [PATCH] :bookmark: Release v1.1.2 --- CHANGELOG.md | 6 +++++ build.sbt | 2 +- .../com/github/plume/oss/Jimple2Cpg.scala | 24 ++++++++++--------- .../github/plume/oss/PlumeStatistics.scala | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c064fde..127c65dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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/). +## [1.1.2] - 2022-03-16 + +### Added + +- Two new metrics that are tracked: `PROGRAM_CLASSES` and `PROGRAM_METHODS`. + ## [1.1.1] - 2022-03-16 ### Added diff --git a/build.sbt b/build.sbt index b9fac3a8..98f0d073 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ name := "Plume" inThisBuild( List( organization := "com.github.plume-oss", - version := "1.1.1", + version := "1.1.2", scalaVersion := "2.13.7", crossScalaVersions := Seq("2.13.7", "3.1.1"), resolvers ++= Seq( diff --git a/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala b/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala index 85642b18..69dd0cbf 100644 --- a/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala +++ b/src/main/scala/com/github/plume/oss/Jimple2Cpg.scala @@ -32,7 +32,7 @@ import soot.{G, PhaseOptions, Scene, SootClass} import java.io.{File => JFile} import java.nio.file.Paths -import scala.jdk.CollectionConverters.CollectionHasAsScala +import scala.jdk.CollectionConverters.{CollectionHasAsScala, IteratorHasAsScala} object Jimple2Cpg { val language: String = "PLUME" @@ -122,14 +122,18 @@ class Jimple2Cpg { logger.debug(s"Source files are: $sourceFileNames") // Load classes into Soot - loadClassesIntoSoot(sourceFileNames) + val allSootClasses = loadClassesIntoSoot(sourceFileNames) if (sootOnlyBuild) return cpg val codeToProcess = new PlumeDiffPass(sourceFileNames, driver).createAndApply() + // Record statistics for experimental purposes + PlumeStatistics.setMetric(PlumeStatistics.PROGRAM_CLASSES, allSootClasses.size) + PlumeStatistics.setMetric( + PlumeStatistics.PROGRAM_METHODS, + allSootClasses.map(_.getMethodCount).sum + ) if (codeToProcess.isEmpty) { logger.info("No files have changed since last update. Exiting...") - PlumeStatistics.setMetric(PlumeStatistics.CHANGED_CLASSES, 0L) - PlumeStatistics.setMetric(PlumeStatistics.CHANGED_METHODS, 0L) return cpg } else { val numChangedMethods = codeToProcess @@ -142,10 +146,7 @@ class Jimple2Cpg { s"($numChangedMethods new or changed methods)" ) PlumeStatistics.setMetric(PlumeStatistics.CHANGED_CLASSES, codeToProcess.size) - PlumeStatistics.setMetric( - PlumeStatistics.CHANGED_METHODS, - numChangedMethods - ) + PlumeStatistics.setMetric(PlumeStatistics.CHANGED_METHODS, numChangedMethods) } // After the diff pass any changed types are removed. Remaining types should be black listed to avoid duplicates @@ -207,14 +208,15 @@ class Jimple2Cpg { ).distinct } - private def loadClassesIntoSoot(sourceFileNames: List[String]): Unit = { - sourceFileNames + private def loadClassesIntoSoot(sourceFileNames: List[String]): Seq[SootClass] = { + val sootClasses = sourceFileNames .map(getQualifiedClassPath) - .foreach { cp => + .map { cp => Scene.v().addBasicClass(cp) Scene.v().loadClassAndSupport(cp) } Scene.v().loadNecessaryClasses() + sootClasses } private def basePasses( diff --git a/src/main/scala/com/github/plume/oss/PlumeStatistics.scala b/src/main/scala/com/github/plume/oss/PlumeStatistics.scala index e9385da1..2b5b1e55 100644 --- a/src/main/scala/com/github/plume/oss/PlumeStatistics.scala +++ b/src/main/scala/com/github/plume/oss/PlumeStatistics.scala @@ -11,7 +11,7 @@ object PlumeStatistics extends Enumeration { type PlumeStatistic = Value val TIME_OPEN_DRIVER, TIME_CLOSE_DRIVER, TIME_EXTRACTION, TIME_REACHABLE_BY_QUERYING, - CHANGED_CLASSES, CHANGED_METHODS = Value + CHANGED_CLASSES, CHANGED_METHODS, PROGRAM_CLASSES, PROGRAM_METHODS = Value private val statistics: mutable.Map[PlumeStatistic, Long] = PlumeStatistics.values.map((_, 0L)).to(collection.mutable.Map)