howler-sentinel-plugin 0.2.0.dev103__tar.gz → 0.2.0.dev105__tar.gz

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.
Files changed (16) hide show
  1. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/PKG-INFO +1 -1
  2. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/pyproject.toml +1 -1
  3. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/actions/azure_emit_hash.py +38 -13
  4. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/actions/send_to_sentinel.py +3 -1
  5. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/LICENSE +0 -0
  6. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/README.md +0 -0
  7. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/__init__.py +0 -0
  8. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/actions/update_defender_xdr_alert.py +0 -0
  9. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/mapping/sentinel_incident.py +0 -0
  10. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/mapping/xdr_alert.py +0 -0
  11. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/mapping/xdr_alert_evidence.py +0 -0
  12. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/odm/hit.py +0 -0
  13. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/odm/models/sentinel.py +0 -0
  14. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/routes/__init__.py +0 -0
  15. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/routes/ingest.py +0 -0
  16. {howler_sentinel_plugin-0.2.0.dev103 → howler_sentinel_plugin-0.2.0.dev105}/sentinel/utils/tenant_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: howler-sentinel-plugin
3
- Version: 0.2.0.dev103
3
+ Version: 0.2.0.dev105
4
4
  Summary: A howler plugin for integration with Microsoft's Sentinel API
5
5
  License: MIT
6
6
  Author: CCCS
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "howler-sentinel-plugin"
3
- version = "0.2.0.dev103"
3
+ version = "0.2.0.dev105"
4
4
  description = "A howler plugin for integration with Microsoft's Sentinel API"
5
5
  authors = [{ name = "CCCS", email = "analysis-development@cyber.gc.ca" }]
6
6
  license = { text = "MIT" }
@@ -1,12 +1,15 @@
1
1
  import os
2
- from typing import Optional
2
+ from typing import Any, Optional
3
3
 
4
4
  import requests
5
5
  from howler.common.loader import datastore
6
+ from howler.common.logging import get_logger
6
7
  from howler.odm.models.action import VALID_TRIGGERS
7
8
  from howler.odm.models.hit import Hit
8
9
  from pydash import get
9
10
 
11
+ logger = get_logger(__file__)
12
+
10
13
  OPERATION_ID = "azure_emit_hash"
11
14
 
12
15
 
@@ -15,7 +18,7 @@ def execute(
15
18
  url: Optional[str] = os.environ.get("SHA256_LOGIC_APP_URL", None),
16
19
  field: str = "file.hash.sha256",
17
20
  **kwargs,
18
- ):
21
+ ) -> list[dict[str, Any]]:
19
22
  "Emit hashes to sentinel"
20
23
  result = datastore().hit.search(query, rows=1)
21
24
  hits = result["items"]
@@ -56,17 +59,36 @@ def execute(
56
59
  for hit in hits:
57
60
  hash_value = get(hit, field)
58
61
  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
- )
62
+ try:
63
+ requests.post(
64
+ url, # noqa: F821
65
+ json={
66
+ "indicator": hash_value,
67
+ "type": "FileSha256",
68
+ "description": "Sent from Howler",
69
+ "action": "alert",
70
+ "severity": "high",
71
+ },
72
+ timeout=5.0,
73
+ )
74
+ report.append(
75
+ {
76
+ "query": f"howler.id:{hit.howler.id}",
77
+ "outcome": "success",
78
+ "title": "Webhook Triggered",
79
+ "message": f"Field {field} from alert {hit.howler.id} was successfully sent to url {url}.",
80
+ }
81
+ )
82
+ except Exception:
83
+ logger.exception("Exception on network call for alert %s", hit.howler.id)
84
+ report.append(
85
+ {
86
+ "query": f"howler.id:{hit.howler.id}",
87
+ "outcome": "error",
88
+ "title": "Network error on execution",
89
+ "message": "Alert processing failed due to network errors.",
90
+ }
91
+ )
70
92
  else:
71
93
  report.append(
72
94
  {
@@ -77,6 +99,8 @@ def execute(
77
99
  }
78
100
  )
79
101
 
102
+ return report
103
+
80
104
 
81
105
  def specification():
82
106
  "Specify various properties of the action, such as title, descriptions, permissions and input steps."
@@ -93,6 +117,7 @@ def specification():
93
117
  {
94
118
  "args": {"url": [], "field": []},
95
119
  "options": {"field": [field for field in Hit.flat_fields().keys() if field.endswith("sha256")]},
120
+ "validation": {"warn": {"query": "-_exists_:$field"}},
96
121
  }
97
122
  ],
98
123
  "triggers": VALID_TRIGGERS,
@@ -1,3 +1,5 @@
1
+ from typing import Any
2
+
1
3
  import requests
2
4
  from howler.common.exceptions import HowlerRuntimeError
3
5
  from howler.common.loader import datastore
@@ -12,7 +14,7 @@ logger = get_logger(__file__)
12
14
  OPERATION_ID = "send_to_sentinel"
13
15
 
14
16
 
15
- def execute(query: str, **kwargs):
17
+ def execute(query: str, **kwargs) -> list[dict[str, Any]]:
16
18
  """Send hit to Microsoft Sentinel.
17
19
 
18
20
  Args: