diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2eff8cc..c9ded5b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -47,6 +47,7 @@ jobs: mv workspace/thorat.zip thorat.zip mv workspace/defects4j.zip defects4j.zip mv workspace/bugs_in_py.zip bugs_in_py.zip + mv workspace/securibench-micro-js.zip securibench-micro-js.zip - name: Set next release version id: taggerFinal uses: anothrNick/github-tag-action@1.61.0 @@ -63,4 +64,5 @@ jobs: securibench-micro-JAVASRC.zip thorat.zip defects4j.zip - bugs_in_py.zip \ No newline at end of file + bugs_in_py.zip + securibench-micro-js.zip \ No newline at end of file diff --git a/README.md b/README.md index b88c9e0..e2d9b84 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,12 @@ A repository for building snapshots of datasets used by `joern-benchmarks`. sbt stage ./joern-benchmarks-datasets --help joern-benchmark v0.0.1 -Usage: joern-benchmark [options] benchmark +Usage: joern-benchmark-datasets [options] benchmark A benchmark downloader tool for Joern benchmarks -h, --help --version Prints the version - benchmark The benchmark to download. Available [ALL,SECURIBENCH_MICRO_SRC,SECURIBENCH_MICRO_JAVA,ICHNAEA_JSSRC,THORAT_PYSRC,BUGS_IN_PY,DEFECTS4J] + benchmark The benchmark to download. Available [ALL,SECURIBENCH_MICRO_SRC,SECURIBENCH_MICRO_JAVA,SECURIBENCH_MICRO_JS,ICHNAEA,THORAT,BUGS_IN_PY,DEFECTS4J] -d, --dataset-dir - The dataset directory where benchmarks will be downloaded to. Default is `./workspace` + The dataset directory where benchmarks will be downloaded to. Default is `./workspace`. ``` diff --git a/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDataset.scala b/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDataset.scala index 51c7769..785969d 100644 --- a/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDataset.scala +++ b/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDataset.scala @@ -8,6 +8,7 @@ import io.joern.benchmarks.datasets.runner.{ Defects4jDownloader, IchnaeaDownloader, SecuribenchMicroDownloader, + SecuribenchMicroJsDownloader, ThoratDownloader } import org.slf4j.LoggerFactory @@ -38,6 +39,7 @@ object BenchmarkDataset { x => new SecuribenchMicroDownloader(x.datasetDir, JavaCpgTypes.JAVASRC) ), (AvailableBenchmarks.SECURIBENCH_MICRO_JAVA, x => new SecuribenchMicroDownloader(x.datasetDir, JavaCpgTypes.JAVA)), + (AvailableBenchmarks.SECURIBENCH_MICRO_JS, x => new SecuribenchMicroJsDownloader(x.datasetDir)), (AvailableBenchmarks.ICHNAEA, x => new IchnaeaDownloader(x.datasetDir)), (AvailableBenchmarks.THORAT, x => new ThoratDownloader(x.datasetDir)), (AvailableBenchmarks.BUGS_IN_PY, x => new BugsInPyDownloader(x.datasetDir)), diff --git a/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDatasetConfig.scala b/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDatasetConfig.scala index 984d00e..8922da4 100644 --- a/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDatasetConfig.scala +++ b/src/main/scala/io/joern/benchmarks/datasets/BenchmarkDatasetConfig.scala @@ -10,9 +10,9 @@ case class BenchmarkDatasetConfig( object AvailableBenchmarks extends Enumeration { val ALL = Value - // Joern val SECURIBENCH_MICRO_SRC = Value val SECURIBENCH_MICRO_JAVA = Value + val SECURIBENCH_MICRO_JS = Value val ICHNAEA = Value val THORAT = Value val BUGS_IN_PY = Value diff --git a/src/main/scala/io/joern/benchmarks/datasets/Main.scala b/src/main/scala/io/joern/benchmarks/datasets/Main.scala index affd209..c7b6fa6 100644 --- a/src/main/scala/io/joern/benchmarks/datasets/Main.scala +++ b/src/main/scala/io/joern/benchmarks/datasets/Main.scala @@ -6,7 +6,6 @@ import scopt.OptionParser import scala.util.{Failure, Success} -/** Example program that makes use of Joern as a library */ object Main { def main(args: Array[String]): Unit = { diff --git a/src/main/scala/io/joern/benchmarks/datasets/runner/SecuribenchMicroJsDownloader.scala b/src/main/scala/io/joern/benchmarks/datasets/runner/SecuribenchMicroJsDownloader.scala new file mode 100644 index 0000000..5151ffd --- /dev/null +++ b/src/main/scala/io/joern/benchmarks/datasets/runner/SecuribenchMicroJsDownloader.scala @@ -0,0 +1,36 @@ +package io.joern.benchmarks.datasets.runner + +import better.files.File +import io.joern.benchmarks.* +import io.joern.benchmarks.datasets.JavaCpgTypes +import org.slf4j.LoggerFactory + +import java.net.{URI, URL} +import scala.util.{Failure, Success, Try} + +class SecuribenchMicroJsDownloader(datasetDir: File) extends DatasetDownloader(datasetDir) with SingleFileDownloader { + + private val logger = LoggerFactory.getLogger(getClass) + + override val benchmarkName = s"securibench-micro.js v1.0.0" + + override protected val benchmarkUrl: URL = URI( + "https://github.com/DavidBakerEffendi/securibench-micro.js/archive/refs/tags/v1.0.0.zip" + ).toURL + override protected val benchmarkFileName: String = "securibench-micro.js-1.0.0" + override protected val benchmarkBaseDir: File = datasetDir / benchmarkFileName + + override def initialize(): Try[File] = { + val target = datasetDir / "securibench-micro-js.zip" + if !target.exists then downloadFile(benchmarkUrl, datasetDir / "securibench-micro-js.zip") + else Success(target) + } + + override def run(): Unit = { + initialize() match { + case Failure(exception) => + logger.error(s"Unable to initialize benchmark '$getClass'", exception) + case Success(_) => + } + } +}