refactor: JSON data column for findings, code snippets captured and displayed

This commit is contained in:
Marker689
2026-05-09 05:52:10 +03:00
parent e83167a938
commit e577f1944c
11 changed files with 60 additions and 57 deletions

View File

@@ -147,18 +147,21 @@ def guarddog_normalized_flagged():
"severity": "WARNING",
"message": "Package contains URL to suspicious domain",
"location": "setup.py:15",
"code": "url = 'http://evil.com'",
},
{
"rule": "exec-base64",
"severity": "WARNING",
"message": "Base64-encoded code execution detected",
"location": "core.py:42",
"code": "exec(base64.b64decode(...))",
},
{
"rule": "empty_information",
"severity": "WARNING",
"message": "Package description is empty",
"location": "",
"code": "",
},
],
"errors": [],

View File

@@ -43,6 +43,12 @@ async def test_harvest_new_package(db_session, guarddog_normalized_flagged):
.all()
)
assert len(findings) == 3
rules = {f.data["rule"] for f in findings}
assert "shady-links" in rules
# Check code is preserved
for f in findings:
if f.data["rule"] == "shady-links":
assert f.data["code"] == "url = 'http://evil.com'"
@pytest.mark.asyncio