Skip to content

Commit e9c20c2

Browse files
committed
feat(datasets): pass artifact arguments to benchmark commands
1 parent 0f12e7e commit e9c20c2

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

codesectools/datasets/BenchmarkJava/dataset.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class BenchmarkJava(PrebuiltFileDataset):
5454
Attributes:
5555
name (str): The name of the dataset, "BenchmarkJava".
5656
supported_languages (list[str]): A list of supported programming languages.
57+
license (str): The license under which the dataset is distributed.
58+
license_url (str): A URL to the full text of the license.
59+
build_command (str): The command to build the Java project.
60+
prebuilt_expected (tuple): A tuple defining the path and glob pattern for expected build artifacts.
61+
artefacts_arg (str): The argument to specify the location of build artifacts for SAST tools.
5762
5863
"""
5964

@@ -64,6 +69,7 @@ class BenchmarkJava(PrebuiltFileDataset):
6469

6570
build_command = "mvn clean compile"
6671
prebuilt_expected = (Path("target/classes/org/owasp/benchmark/testcode"), "*.class")
72+
artefacts_arg = "."
6773

6874
def __init__(self, lang: None | str = None) -> None:
6975
"""Initialize the BenchmarkJava dataset.

codesectools/datasets/core/dataset.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,19 @@ def list_dataset_full_names(cls) -> list[str]:
150150

151151

152152
class PrebuiltDatasetMixin:
153-
"""Provide functionality for datasets that require a build step."""
153+
"""Provide functionality for datasets that require a build step.
154+
155+
Attributes:
156+
build_command (str): The command required to build the dataset.
157+
prebuilt_expected (tuple[Path, str]): A tuple containing the path and glob pattern
158+
to find the built artifacts.
159+
artefacts_arg (str): The argument to pass to the SAST tool command template.
160+
161+
"""
154162

155163
build_command: str
156164
prebuilt_expected: tuple[Path, str]
165+
artefacts_arg: str
157166

158167
def is_built(self) -> bool:
159168
"""Check if the dataset has been built."""
@@ -271,15 +280,7 @@ def save(self, dir: Path) -> None:
271280

272281

273282
class FileDataset(Dataset):
274-
"""Abstract base class for datasets composed of individual files.
275-
276-
Attributes:
277-
directory (Path): The directory path for the dataset.
278-
lang (str): The programming language of the dataset.
279-
full_name (str): The full name of the dataset, including the language.
280-
files (list[File]): A list of `File` objects loaded from the dataset.
281-
282-
"""
283+
"""Abstract base class for datasets composed of individual files."""
283284

284285
def __init__(self, lang: str) -> None:
285286
"""Initialize a FileDataset instance.

codesectools/sasts/core/sast/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ def analyze_files(
374374
)
375375
return
376376

377-
self.run_analysis(dataset.lang, dataset.directory, result_path)
377+
self.run_analysis(
378+
dataset.lang,
379+
dataset.directory,
380+
result_path,
381+
artifacts=dataset.artefacts_arg,
382+
)
378383

379384

380385
class PrebuiltBuildlessSAST(PrebuiltSAST, BuildlessSAST):

0 commit comments

Comments
 (0)