Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Better transformation of informational rules #105

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 12 additions & 4 deletions sigma/backends/elasticsearch/elasticsearch_eql.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,22 @@ def finalize_query_siem_rule_ndjson(
},
"max_signals": 100,
"risk_score": (
self.severity_risk_mapping[rule.level.name]
0
if rule.level is not None
else 21
and str(rule.level.name).lower() == "informational"
else (
self.severity_risk_mapping[rule.level.name]
if rule.level is not None
else 21
)
),
"risk_score_mapping": [],
"severity": (
str(rule.level.name).lower() if rule.level is not None else "low"
"low"
if rule.level is None
or str(rule.level.name).lower() == "informational"
else str(rule.level.name).lower()
),
"risk_score_mapping": [],
"severity_mapping": [],
"threat": list(self.finalize_output_threat_model(rule.tags)),
"tags": [f"{n.namespace}-{n.name}" for n in rule.tags],
Expand Down
14 changes: 11 additions & 3 deletions sigma/backends/elasticsearch/elasticsearch_esql.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,20 @@ def finalize_query_siem_rule_ndjson(
rule.description if rule.description is not None else "No description"
),
"risk_score": (
self.severity_risk_mapping[rule.level.name]
0
if rule.level is not None
else 21
and str(rule.level.name).lower() == "informational"
else (
self.severity_risk_mapping[rule.level.name]
if rule.level is not None
else 21
)
),
"severity": (
str(rule.level.name).lower() if rule.level is not None else "low"
"low"
if rule.level is None
or str(rule.level.name).lower() == "informational"
else str(rule.level.name).lower()
),
"note": "",
"license": "DRL",
Expand Down
14 changes: 11 additions & 3 deletions sigma/backends/elasticsearch/elasticsearch_lucene.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,21 @@ def finalize_query_siem_rule(
},
"maxSignals": 100,
"riskScore": (
self.severity_risk_mapping[rule.level.name]
0
if rule.level is not None
else 21
and str(rule.level.name).lower() == "informational"
else (
self.severity_risk_mapping[rule.level.name]
if rule.level is not None
else 21
)
),
"riskScoreMapping": [],
"severity": (
str(rule.level.name).lower() if rule.level is not None else "low"
"low"
if rule.level is None
or str(rule.level.name).lower() == "informational"
else str(rule.level.name).lower()
),
"severityMapping": [],
"threat": list(self.finalize_output_threat_model(rule.tags)),
Expand Down