Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "socketdev"
version = "3.0.6"
version = "3.0.7"
requires-python = ">= 3.9"
dependencies = [
'requests',
Expand Down
24 changes: 16 additions & 8 deletions socketdev/core/dedupe.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def alert_key(alert: dict) -> tuple:
return (
alert["type"],
alert["severity"],
alert["category"],
alert.get("category"),
Dedupe.normalize_file_path(alert.get("file")),
alert.get("start"),
alert.get("end")
Expand All @@ -25,7 +25,7 @@ def alert_identity(alert: dict) -> tuple:
return (
alert["type"],
alert["severity"],
alert["category"],
alert.get("category"),
Dedupe.normalize_file_path(alert.get("file")),
alert.get("start"),
alert.get("end")
Expand All @@ -39,21 +39,29 @@ def alert_identity(alert: dict) -> tuple:

for alert in pkg.get("alerts", []):
identity = alert_identity(alert)
file = Dedupe.normalize_file_path(alert.get("file"))

if identity not in alert_map:
alert_map[identity] = {
# Build alert dict with only fields that exist in the original alert
consolidated_alert = {
"key": alert["key"], # keep the first key seen
"type": alert["type"],
"severity": alert["severity"],
"category": alert["category"],
"file": file,
"start": alert.get("start"),
"end": alert.get("end"),
"releases": [release],
"props": alert.get("props", []),
"action": alert["action"]
}

# Only include optional fields if they exist in the original alert
if "category" in alert:
consolidated_alert["category"] = alert["category"]
if "file" in alert:
consolidated_alert["file"] = Dedupe.normalize_file_path(alert["file"])
if "start" in alert:
consolidated_alert["start"] = alert["start"]
if "end" in alert:
consolidated_alert["end"] = alert["end"]

alert_map[identity] = consolidated_alert
else:
if release not in alert_map[identity]["releases"]:
alert_map[identity]["releases"].append(release)
Expand Down
2 changes: 1 addition & 1 deletion socketdev/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.6"
__version__ = "3.0.7"
Loading