Skip to content

Commit

Permalink
Run black to fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Mar 9, 2024
1 parent 4027873 commit 56c2ccc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions training/test_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

@pytest.fixture
def model():

# Load dataset
data = pd.read_csv("dataset/sqli_dataset.csv")

Expand All @@ -26,15 +25,22 @@ def model():
return {"tokenizer": tokenizer, "sqli_model": sqli_model}


@pytest.mark.parametrize("sample",
@pytest.mark.parametrize(
"sample",
[
("select * from users where id='1' or 1=1--", [92.02]),
("select * from users", [0.077]),
("select * from users where id=10000", [14.83]),
("select '1' union select 'a'; -- -'", [99.99]),
("select '' union select 'malicious php code' \g /var/www/test.php; -- -';", [99.99]),
("select '' || pg_sleep((ascii((select 'a' limit 1)) - 32) / 2); -- -';", [99.99])
]
(
"select '' union select 'malicious php code' \g /var/www/test.php; -- -';",
[99.99],
),
(
"select '' || pg_sleep((ascii((select 'a' limit 1)) - 32) / 2); -- -';",
[99.99],
),
],
)
def test_sqli_model(model, sample):
# Vectorize the sample
Expand All @@ -45,6 +51,4 @@ def test_sqli_model(model, sample):
predictions = model["sqli_model"].predict(sample_vec)

# Scale up to 100
assert predictions * 100 == pytest.approx(
np.array([sample[1]]), 0.1
)
assert predictions * 100 == pytest.approx(np.array([sample[1]]), 0.1)

0 comments on commit 56c2ccc

Please sign in to comment.