howler-api 3.1.0.dev388__py3-none-any.whl → 3.1.0.dev391__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.
@@ -377,10 +377,10 @@ class ESCollection(Generic[ModelType]):
377
377
  elasticsearch.exceptions.AuthenticationException,
378
378
  ) as e:
379
379
  if not isinstance(e, SearchRetryException):
380
- logger.warning(
380
+ logger.exception(
381
381
  f"No connection to Elasticsearch server(s): "
382
382
  f"{' | '.join(self.datastore.get_hosts(safe=True))}"
383
- f", because [{e}] retrying {func.__name__}..."
383
+ f", because [{str(e)}] retrying {func.__name__}..." # noqa: TRY401
384
384
  )
385
385
 
386
386
  time.sleep(min(retries, self.MAX_RETRY_BACKOFF))
howler/datastore/store.py CHANGED
@@ -4,18 +4,28 @@ import logging
4
4
  import os
5
5
  import re
6
6
  from os import environ
7
+ from pathlib import Path
7
8
  from typing import Any, Optional, cast
8
9
  from urllib.parse import urlparse
9
10
 
10
11
  import elasticsearch
11
12
  import elasticsearch.client
12
13
 
14
+ from howler.common.logging.format import HWL_DATE_FORMAT, HWL_LOG_FORMAT
13
15
  from howler.datastore.collection import ESCollection
14
16
  from howler.datastore.exceptions import DataStoreException
15
17
  from howler.odm.models.config import Config
16
18
  from howler.odm.models.config import config as _config
17
19
 
18
20
  TRANSPORT_TIMEOUT = int(environ.get("HWL_DATASTORE_TRANSPORT_TIMEOUT", "10"))
21
+ CERTS_PATH = Path(os.environ.get("HWL_CERT_DIRECTORY", "/etc/howler/certs"))
22
+
23
+ logger = logging.getLogger("howler.datastore.store")
24
+ logger.setLevel(logging.INFO)
25
+ console = logging.StreamHandler()
26
+ console.setLevel(logging.INFO)
27
+ console.setFormatter(logging.Formatter(HWL_LOG_FORMAT, HWL_DATE_FORMAT))
28
+ logger.addHandler(console)
19
29
 
20
30
 
21
31
  class ESStore(object):
@@ -58,9 +68,22 @@ class ESStore(object):
58
68
  self._username: Optional[str] = None
59
69
  self._password: Optional[str] = None
60
70
  self._hosts = []
71
+ self._cert: str | None = None
61
72
 
62
73
  for host in config.datastore.hosts:
63
74
  self._hosts.append(str(host))
75
+
76
+ cert = CERTS_PATH / f"{host.name}.crt"
77
+ if cert.exists():
78
+ if self._cert is None:
79
+ self._cert = str(cert)
80
+ else:
81
+ logger.error("Only a single certificate path is supported - ignoring additional paths.")
82
+ logger.error(
83
+ "If you have multiple certificates, bundle them into a single .pem file and specify "
84
+ "it for the first host."
85
+ )
86
+
64
87
  if os.getenv(f"{host.name.upper()}_HOST_APIKEY_ID", None) is not None:
65
88
  self._apikey = (
66
89
  os.environ[f"{host.name.upper()}_HOST_APIKEY_ID"],
@@ -81,6 +104,7 @@ class ESStore(object):
81
104
  if self._apikey is not None:
82
105
  self.client = elasticsearch.Elasticsearch(
83
106
  hosts=self._hosts, # type: ignore
107
+ ca_certs=self._cert, # type: ignore
84
108
  api_key=self._apikey,
85
109
  max_retries=0,
86
110
  request_timeout=TRANSPORT_TIMEOUT,
@@ -88,6 +112,7 @@ class ESStore(object):
88
112
  elif self._username is not None and self._password is not None:
89
113
  self.client = elasticsearch.Elasticsearch(
90
114
  hosts=self._hosts, # type: ignore
115
+ ca_certs=self._cert, # type: ignore
91
116
  basic_auth=(self._username, self._password),
92
117
  max_retries=0,
93
118
  request_timeout=TRANSPORT_TIMEOUT,
@@ -95,6 +120,7 @@ class ESStore(object):
95
120
  else:
96
121
  self.client = elasticsearch.Elasticsearch(
97
122
  hosts=self._hosts, # type: ignore
123
+ ca_certs=self._cert, # type: ignore
98
124
  max_retries=0,
99
125
  request_timeout=TRANSPORT_TIMEOUT,
100
126
  )
@@ -23,7 +23,7 @@ class Comment(odm.Model):
23
23
  )
24
24
 
25
25
 
26
- DEFAULT_TRIAGE = {"skip_rationale": False, "valid_assessments": Assessment.list()}
26
+ DEFAULT_TRIAGE = {"skip_rationale": False, "valid_assessments": Assessment.list(), "rationales": []}
27
27
 
28
28
 
29
29
  @odm.model(index=True, store=True, description="Settings for triaging this analytic.")
@@ -40,6 +40,11 @@ class TriageOptions(odm.Model):
40
40
  dossiers: list[str] = odm.List(
41
41
  odm.Keyword(), description="A list of dossiers to present to the user when triaging alerts.", default=[]
42
42
  )
43
+ rationales: list[str] = odm.List(
44
+ odm.Keyword(),
45
+ default=DEFAULT_TRIAGE["rationales"],
46
+ description="A provided list of rationales that will be suggested when triaging alerts.",
47
+ )
43
48
 
44
49
 
45
50
  @odm.model(index=True, store=True, description="Notebook data")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: howler-api
3
- Version: 3.1.0.dev388
3
+ Version: 3.1.0.dev391
4
4
  Summary: Howler - API server
5
5
  License: MIT
6
6
  Keywords: howler,alerting,gc,canada,cse-cst,cse,cst,cyber,cccs
@@ -53,14 +53,14 @@ howler/cronjobs/view_cleanup.py,sha256=ULWLR1uFcRemRgkEDrMqmBamHiE0dgDvu49VK0qDk
53
53
  howler/datastore/README.md,sha256=ekWl1YJSrHlZpU5PgBkPEzPWjdbTdav6Rd2P0ccIesw,4758
54
54
  howler/datastore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  howler/datastore/bulk.py,sha256=VfolZfiaBD4ZTK3j6IVVVq4GMjVXb5elrsGwwM_nONE,2829
56
- howler/datastore/collection.py,sha256=joi4-lUMWGH1DBO3ag36GriSI7J2n-UpIfb1-KaBdTU,91191
56
+ howler/datastore/collection.py,sha256=1VuWTShCVIo3afye9gM7uSpAvSGvqm7j6w0ZOUEX9N8,91214
57
57
  howler/datastore/constants.py,sha256=x7ODomtOQmDjmXoAxly4onPAnUkq4BLZ1TBg-UgpU1g,2415
58
58
  howler/datastore/exceptions.py,sha256=yZvQXRI4mR50ltGFHbdZAD4TIbhdKJku6LLTPQ0JZRk,955
59
59
  howler/datastore/howler_store.py,sha256=kW7FKM-tILcfTmrjSB1yZm-ZnumPS_tiQEZUDaQoDkg,2915
60
60
  howler/datastore/migrations/fix_process.py,sha256=J0FxqcXbQ161sgmQ5teyEcPuX7WYB9wqs0CO8m1jk0U,1218
61
61
  howler/datastore/operations.py,sha256=5WdJBewXRIG71ZexQcYASv0IYoDi1m9ia8332u5mXSs,3919
62
62
  howler/datastore/schemas.py,sha256=kuxqYVWMgqnrdU-ypkDxoSzEtECUrRCKXjU_R5Kg7X4,3158
63
- howler/datastore/store.py,sha256=MzIvZy8deMgpnKR-TKTTcttH6kkYy4EBSYMCh0Q-J0E,7055
63
+ howler/datastore/store.py,sha256=GXBXqubhALd6fWjFqoM_YqbZOC1YnMA1hSaXsS7F3ak,8187
64
64
  howler/datastore/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  howler/datastore/support/build.py,sha256=iBVfWophzoPlx6rvR5w3Axb6gjqLuDeDBpKj7lO-1l0,7877
66
66
  howler/datastore/support/schemas.py,sha256=kuxqYVWMgqnrdU-ypkDxoSzEtECUrRCKXjU_R5Kg7X4,3158
@@ -90,7 +90,7 @@ howler/odm/helper.py,sha256=EELMg3pvE7Kb9VDeKSYJQHiq6uCO2YuS095CPRgWrEM,13927
90
90
  howler/odm/howler_enum.py,sha256=JzRK3_adlhvfkoGdMZD1jgOwlneZs8-x7OxGEj3zcpY,768
91
91
  howler/odm/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
92
  howler/odm/models/action.py,sha256=V9tgMCg1ewu8mOngTcA6QAPwaR0NIT71VHglpRFYmS4,1235
93
- howler/odm/models/analytic.py,sha256=HCDpGCBVsnqs0q51982Lfy7zupgNU5o3GpiEoboO7js,3910
93
+ howler/odm/models/analytic.py,sha256=msj-VhpE_0Gw0XLnakeSGehRS4RdGqR3Mzns9A5nlxU,4139
94
94
  howler/odm/models/assemblyline.py,sha256=_wcTiX3A6bhA2SGlK9tDF0v-uwLpIabXE8j2Fw91dGY,1596
95
95
  howler/odm/models/aws.py,sha256=pJVadJqubdgT27riCfp7bEKVP4XsMZB0ZUnKAbmCMd0,895
96
96
  howler/odm/models/azure.py,sha256=o7MZMMo9jh1SB8xXCajl_YSKP2nnnWsjx_DPT6LnQKg,710
@@ -192,7 +192,7 @@ howler/utils/path.py,sha256=DfOU4i4zSs4wchHoE8iE7aWVLkTxiC_JRGepF2hBYBk,690
192
192
  howler/utils/socket_utils.py,sha256=nz1SklC9xBHUSfHyTJjpq3mbozX1GDf01WzdGxfaUII,2212
193
193
  howler/utils/str_utils.py,sha256=HE8Hqh2HlOLaj16w0H9zKOyDJLp-f1LQ50y_WeGZaEk,8389
194
194
  howler/utils/uid.py,sha256=p9dsqyvZ-lpiAuzZWCPCeEM99kdk0Ly9czf04HNdSuw,1341
195
- howler_api-3.1.0.dev388.dist-info/METADATA,sha256=8nWH9IU5aZjLqoE50uV42fTlXnnYfszd7oc0hJx7Ma8,2804
196
- howler_api-3.1.0.dev388.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
197
- howler_api-3.1.0.dev388.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
198
- howler_api-3.1.0.dev388.dist-info/RECORD,,
195
+ howler_api-3.1.0.dev391.dist-info/METADATA,sha256=LLMThjzPzat64TGPdYt_t382kN-82sBrCB9eWaO_Rjs,2804
196
+ howler_api-3.1.0.dev391.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
197
+ howler_api-3.1.0.dev391.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
198
+ howler_api-3.1.0.dev391.dist-info/RECORD,,