Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Securibench Micro JS #8

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand All @@ -63,4 +64,5 @@ jobs:
securibench-micro-JAVASRC.zip
thorat.zip
defects4j.zip
bugs_in_py.zip
bugs_in_py.zip
securibench-micro-js.zip
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <value>
The dataset directory where benchmarks will be downloaded to. Default is `./workspace`
The dataset directory where benchmarks will be downloaded to. Default is `./workspace`.
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.joern.benchmarks.datasets.runner.{
Defects4jDownloader,
IchnaeaDownloader,
SecuribenchMicroDownloader,
SecuribenchMicroJsDownloader,
ThoratDownloader
}
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -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)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/main/scala/io/joern/benchmarks/datasets/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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(_) =>
}
}
}