refactor: JSON data column for findings, code snippets captured and displayed
This commit is contained in:
@@ -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": [],
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user