Skip to content

Commit 0a51d00

Browse files
committed
Initial packaging of the project
- Changed project structure to a flat layout - Fixed package data path using importlib.resources.files - Stored result output in the user’s home directory
1 parent d16d4ba commit 0a51d00

32 files changed

Lines changed: 367 additions & 457 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
build/
2+
13
# Python
24
__pycache__/
35
.venv/
6+
*.egg-info
47

58
# Ruff
69
.ruff_cache

data/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

datasets/README.md

Lines changed: 0 additions & 119 deletions
This file was deleted.

datasets/__init__.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

pyproject.toml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
[project]
22
name = "SASTBenchmark"
3-
version = "1.0.0"
4-
description = "A collection of scripts and wrappers around SASTs and datasets for benchmarking and project testing purposes."
3+
version = "1.1.0"
4+
description = "Scripts and wrappers for SASTs and datasets, with abstractions to support integration, benchmarking, and testing."
55
readme = "README.md"
6+
license = "AGPL-3.0-only"
7+
license-files = ["LICENSE"]
68
requires-python = ">=3.12"
9+
authors = [
10+
{name = "Villon Chen"},
11+
]
712
dependencies = [
813
"blessed>=1.21.0",
914
"click>=8.2.1",
@@ -19,6 +24,19 @@ dependencies = [
1924
"xmltodict>=0.14.2",
2025
]
2126

27+
[project.scripts]
28+
sastb = "sastbenchmark.main:cli"
29+
30+
[build-system]
31+
requires = ["setuptools"]
32+
build-backend = "setuptools.build_meta"
33+
34+
[tool.setuptools.packages.find]
35+
include = ["sastbenchmark", "sastbenchmark.*"]
36+
37+
[tool.setuptools]
38+
include-package-data = true
39+
2240
[tool.ruff.lint]
23-
select = ["E", "F", "I", "ANN", "B"]
24-
ignore = ["E501", "ANN101", "ANN102", "ANN204"]
41+
select = ["E", "F", "I", "ANN", "B", "TC"]
42+
ignore = ["E501"]

sastb

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import glob
33
import os
44

5+
from sastbenchmark.utils import PACKAGE_DIR
6+
57
CWE = {}
6-
for file_path in glob.glob(os.path.join("data", "cwe", "CWE_*.csv")):
8+
for file_path in glob.glob(os.path.join(PACKAGE_DIR, "data", "cwe", "CWE_*.csv")):
79
with open(file_path, mode="r", encoding="utf-8") as file:
810
reader = csv.DictReader(file)
911
for row in reader:

datasets/BenchmarkJava/dataset.py renamed to sastbenchmark/datasets/BenchmarkJava/dataset.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import zipfile
44
from typing import Self
55

6-
from datasets._base.dataset import File, FileDataset
6+
from sastbenchmark.datasets._base.dataset import File, FileDataset
77

88

99
class TestFile(File):
@@ -14,7 +14,7 @@ def __init__(
1414
cwe_ids: list[int],
1515
vuln_type: str,
1616
is_real: bool,
17-
):
17+
) -> None:
1818
super().__init__(
1919
filename=filename, content=content, cwe_ids=cwe_ids, is_real=is_real
2020
)
@@ -25,14 +25,16 @@ def __init__(
2525
class BenchmarkJava(FileDataset):
2626
name = "BenchmarkJava"
2727

28-
def __init__(self, lang: None | str = None):
28+
def __init__(self, lang: None | str = None) -> None:
2929
super().__init__(lang)
3030

31-
def __eq__(self, other: str | Self):
31+
def __eq__(self, other: str | Self) -> bool:
3232
if isinstance(other, str):
3333
return self.name == other
3434
elif isinstance(other, self.__class__):
3535
return self.name == other.name
36+
else:
37+
return False
3638

3739
def load_dataset(self) -> list[TestFile]:
3840
files = []
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)