howler-sentinel-plugin 0.2.0.dev97__py3-none-any.whl → 0.2.0.dev99__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: howler-sentinel-plugin
3
- Version: 0.2.0.dev97
3
+ Version: 0.2.0.dev99
4
4
  Summary: A howler plugin for integration with Microsoft's Sentinel API
5
5
  License: MIT
6
6
  Author: CCCS
@@ -1,8 +1,7 @@
1
1
  sentinel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- sentinel/actions/ingestion.py,sha256=_t7wrmozhoT_MmktDmNxYiXrA1Q0LCiDt0rTwHBkwbc,1669
3
- sentinel/actions/send_to_sentinel.py,sha256=sg3LyP7IGApMftBU1TTZSUmCGtUI9PwvmI7UBj1Jrf0,3714
4
- sentinel/actions/synchronization.py,sha256=g5c34410zINWb4fSEzj94drnk5alRj_ju9xMrB39z0s,1818
5
- sentinel/actions/update_defender_xdr_alert.py,sha256=_Dtsi2pR5xN8ltzYGpCn9JbYnK731l6LSrGtERVfym4,6398
2
+ sentinel/actions/azure_emit_hash.py,sha256=yEO8ZjFTUjNm03fJfHRVER3xf0v5o0qdU8GnqwZtMTM,2938
3
+ sentinel/actions/send_to_sentinel.py,sha256=rfIJk02iAACvb8bfKv9MEkSDILDnvXlxt49hQVyvvQ4,3734
4
+ sentinel/actions/update_defender_xdr_alert.py,sha256=OjNXM8DixURYdl7fHLCS81I0izQVtQgFkw9Iteeklwg,6418
6
5
  sentinel/mapping/sentinel_incident.py,sha256=3QBnP6qFpJgE3pHvx5VvFnB3m2TVOoWxs8OysDlJVV8,9547
7
6
  sentinel/mapping/xdr_alert.py,sha256=UPoqdZsjUXmJz0dCf_qMlh9Jr0D2HcSNOFvbg8lE4wY,18250
8
7
  sentinel/mapping/xdr_alert_evidence.py,sha256=q622G4eZwFR3TCj418ZCpE83DGVicrWIQZo8Gkj_3FM,31323
@@ -11,8 +10,8 @@ sentinel/odm/models/sentinel.py,sha256=XT3XdT92uoCV5vmY9dT1jmcxRyuu9vp1gE8AwZdKB
11
10
  sentinel/routes/__init__.py,sha256=JYmKRwIfEsiPos1XuMQ2mlGDbxk6TN_cVEM0K_RNze4,130
12
11
  sentinel/routes/ingest.py,sha256=_9OdOw_9nBJseKIBnmHDLjnqZ_bDdM4wfLpLrek4-ak,7018
13
12
  sentinel/utils/tenant_utils.py,sha256=W7kBtxYNhs3vcgMf78eIRqiTpDtqjzEI2H2d0papQ_Q,1224
14
- howler_sentinel_plugin-0.2.0.dev97.dist-info/LICENSE,sha256=Wg2luVnxEkP2NSn11nh1US6W_nFFbICBAVTG9iG3t5M,1091
15
- howler_sentinel_plugin-0.2.0.dev97.dist-info/METADATA,sha256=x3hPU9xXhV3PXUjvFkolFYrXimd1VvhWk96rky6mcpA,748
16
- howler_sentinel_plugin-0.2.0.dev97.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
- howler_sentinel_plugin-0.2.0.dev97.dist-info/entry_points.txt,sha256=4IJyMY0V49s3Wp659ngN_7U8g66-czeKxI-_dNAFP5g,60
18
- howler_sentinel_plugin-0.2.0.dev97.dist-info/RECORD,,
13
+ howler_sentinel_plugin-0.2.0.dev99.dist-info/LICENSE,sha256=Wg2luVnxEkP2NSn11nh1US6W_nFFbICBAVTG9iG3t5M,1091
14
+ howler_sentinel_plugin-0.2.0.dev99.dist-info/METADATA,sha256=QZH7YTqc7odZI8KwzX9IeOU_C2quRyThuIHqiKjdyaM,748
15
+ howler_sentinel_plugin-0.2.0.dev99.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
16
+ howler_sentinel_plugin-0.2.0.dev99.dist-info/entry_points.txt,sha256=4IJyMY0V49s3Wp659ngN_7U8g66-czeKxI-_dNAFP5g,60
17
+ howler_sentinel_plugin-0.2.0.dev99.dist-info/RECORD,,
@@ -0,0 +1,100 @@
1
+ import os
2
+ from typing import Optional
3
+
4
+ import requests
5
+ from howler.common.loader import datastore
6
+ from howler.odm.models.action import VALID_TRIGGERS
7
+ from howler.odm.models.hit import Hit
8
+ from pydash import get
9
+
10
+ OPERATION_ID = "azure_emit_hash"
11
+
12
+
13
+ def execute(
14
+ query: str,
15
+ url: Optional[str] = os.environ.get("SHA256_LOGIC_APP_URL", None),
16
+ field: str = "file.hash.sha256",
17
+ **kwargs,
18
+ ):
19
+ "Emit hashes to sentinel"
20
+ result = datastore().hit.search(query, rows=1)
21
+ hits = result["items"]
22
+
23
+ if not url:
24
+ return [
25
+ {
26
+ "query": query,
27
+ "outcome": "error",
28
+ "title": "Action is not properly configured",
29
+ "message": "url argument cannot be empty.",
30
+ }
31
+ ]
32
+
33
+ if len(hits) < 1:
34
+ return [
35
+ {
36
+ "query": query,
37
+ "outcome": "error",
38
+ "title": "No alert found",
39
+ "message": "No alerts exist in this query.",
40
+ }
41
+ ]
42
+
43
+ report = []
44
+ hit = hits[0]
45
+
46
+ if result["total"] > 1:
47
+ report.append(
48
+ {
49
+ "query": f"{query} AND -howler.id:{hit.howler.id}",
50
+ "outcome": "skipped",
51
+ "title": "Action applies to a single alert",
52
+ "message": "This action supports execution against a single alert at once, not bulk execution.",
53
+ }
54
+ )
55
+
56
+ for hit in hits:
57
+ hash_value = get(hit, field)
58
+ if hash_value:
59
+ requests.post(
60
+ url, # noqa: F821
61
+ json={
62
+ "indicator": hash_value,
63
+ "type": "FileSha256",
64
+ "description": "Sent from Howler",
65
+ "action": "alert",
66
+ "severity": "high",
67
+ },
68
+ timeout=5.0,
69
+ )
70
+ else:
71
+ report.append(
72
+ {
73
+ "query": f"howler.id:{hit.howler.id}",
74
+ "outcome": "error",
75
+ "title": "Hash does not exist on alert",
76
+ "message": f"The specified alert does not have a valid sha256 hash at path {field}.",
77
+ }
78
+ )
79
+
80
+
81
+ def specification():
82
+ "Specify various properties of the action, such as title, descriptions, permissions and input steps."
83
+ return {
84
+ "id": OPERATION_ID,
85
+ "title": "Emit sha256 hash to Sentinel",
86
+ "priority": 8,
87
+ "i18nKey": "operations.add_label",
88
+ "description": {
89
+ "short": "Add a label to a hit",
90
+ "long": execute.__doc__,
91
+ },
92
+ "roles": ["automation_basic"],
93
+ "steps": [
94
+ {
95
+ "args": {"url": [], "field": []},
96
+ "options": {"field": [field for field in Hit.flat_fields().keys() if field.endswith("sha256")]},
97
+ }
98
+ ],
99
+ "triggers": VALID_TRIGGERS,
100
+ }
@@ -34,10 +34,11 @@ def execute(query: str, **kwargs):
34
34
  return report
35
35
 
36
36
  for hit in hits:
37
- tenant_id = hit.azure.tenant_id
38
- if not tenant_id and hit.organization.id:
37
+ if hit.azure and hit.azure.tenant_id:
38
+ tenant_id = hit.azure.tenant_id
39
+ elif hit.organization.id:
39
40
  tenant_id = hit.organization.id
40
- elif not tenant_id:
41
+ else:
41
42
  report.append(
42
43
  {
43
44
  "query": f"howler.id:{hit.howler.id}",
@@ -73,10 +73,11 @@ def execute(query: str, **kwargs):
73
73
  return report
74
74
 
75
75
  for hit in hits:
76
- tenant_id = hit.azure.tenant_id
77
- if not tenant_id and hit.organization.id:
76
+ if hit.azure and hit.azure.tenant_id:
77
+ tenant_id = hit.azure.tenant_id
78
+ elif hit.organization.id:
78
79
  tenant_id = hit.organization.id
79
- elif not tenant_id:
80
+ else:
80
81
  report.append(
81
82
  {
82
83
  "query": f"howler.id:{hit.howler.id}",
@@ -1,59 +0,0 @@
1
- from howler.common.loader import datastore
2
- from howler.datastore.operations import OdmHelper
3
- from howler.odm.models.hit import Hit
4
-
5
- hit_helper = OdmHelper(Hit)
6
-
7
- OPERATION_ID = "sentinel_ingestion"
8
-
9
-
10
- def execute(query: str, **kwargs):
11
- """Handle ingestion of howler alerts into sentinel.
12
-
13
- Args:
14
- query (str): The query specifying alerts to ingest into sentinel.
15
- """
16
- report = [
17
- {
18
- "query": query,
19
- "outcome": "skipped",
20
- "title": "Not Yet Implemented",
21
- "message": "This functionality hasn't been implemented yet.",
22
- }
23
- ]
24
-
25
- ds = datastore()
26
-
27
- skipped_hits = ds.hit.search(
28
- f"({query}) AND _exists_:sentinel.id",
29
- fl="howler.id",
30
- )["items"]
31
-
32
- if len(skipped_hits) > 0:
33
- report.append(
34
- {
35
- "query": f"howler.id:({' OR '.join(h.howler.id for h in skipped_hits)})",
36
- "outcome": "skipped",
37
- "title": "Skipped Hit with matching sentinel alert",
38
- "message": "These hits already have a matching incident in sentinel.",
39
- }
40
- )
41
-
42
- print("Ingest alerts into sentinel that match this query:", query) # noqa: T201
43
-
44
- return report
45
-
46
-
47
- def specification():
48
- """Specify various properties of the action, such as title, descriptions, permissions and input steps."""
49
- return {
50
- "id": OPERATION_ID,
51
- "title": "Ingest into Sentinel",
52
- "priority": 15,
53
- "description": {
54
- "short": "Ingest alerts into sentinel",
55
- "long": execute.__doc__,
56
- },
57
- "roles": ["automation_basic"],
58
- "triggers": ["create"],
59
- }
@@ -1,60 +0,0 @@
1
- from howler.common.loader import datastore
2
- from howler.datastore.operations import OdmHelper
3
- from howler.odm.models.action import VALID_TRIGGERS
4
- from howler.odm.models.hit import Hit
5
-
6
- hit_helper = OdmHelper(Hit)
7
-
8
- OPERATION_ID = "sentinel_synchronization"
9
-
10
-
11
- def execute(query: str, **kwargs):
12
- """Handle synchronization of howler alerts into sentinel.
13
-
14
- Args:
15
- query (str): The query specifying alerts to syncrhonize with sentinel.
16
- """
17
- report = [
18
- {
19
- "query": query,
20
- "outcome": "skipped",
21
- "title": "Not Yet Implemented",
22
- "message": "This functionality hasn't been implemented yet.",
23
- }
24
- ]
25
-
26
- ds = datastore()
27
-
28
- skipped_hits = ds.hit.search(
29
- f"({query}) AND -_exists_:sentinel.id",
30
- fl="howler.id",
31
- )["items"]
32
-
33
- if len(skipped_hits) > 0:
34
- report.append(
35
- {
36
- "query": f"howler.id:({' OR '.join(h.howler.id for h in skipped_hits)})",
37
- "outcome": "skipped",
38
- "title": "No matching sentinel alert",
39
- "message": "These hits do not have a matching incident in sentinel.",
40
- }
41
- )
42
-
43
- print("Update alerts into sentinel that match this query:", f"({query}) AND _exists_:sentinel.id") # noqa: T201
44
-
45
- return report
46
-
47
-
48
- def specification():
49
- """Specify various properties of the action, such as title, descriptions, permissions and input steps."""
50
- return {
51
- "id": OPERATION_ID,
52
- "title": "Synchronize with Sentinel",
53
- "priority": 16,
54
- "description": {
55
- "short": "Synchronize alerts with sentinel",
56
- "long": execute.__doc__,
57
- },
58
- "roles": ["automation_basic"],
59
- "triggers": [trigger for trigger in VALID_TRIGGERS if trigger != "create"],
60
- }