howler-api 3.4.0.dev955__py3-none-any.whl → 3.4.0.dev970__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.
@@ -1364,6 +1364,43 @@ class ESCollection(Generic[ModelType]):
1364
1364
 
1365
1365
  return res["updated"]
1366
1366
 
1367
+ def _expand_fl(self, fl: str) -> str:
1368
+ """Expand wildcard patterns in a field list string using the model's flat_fields.
1369
+
1370
+ For each comma-separated entry in `fl`, if the entry contains a `*`, it is treated
1371
+ as a glob-style wildcard pattern and matched against all fields returned by
1372
+ ``flat_fields()``. Entries without wildcards are kept as-is.
1373
+
1374
+ Args:
1375
+ fl: Comma-separated list of field names, optionally containing ``*`` wildcards
1376
+ (e.g. ``"howler.*,event.start"``).
1377
+
1378
+ Returns:
1379
+ A comma-separated string of expanded field names. If no model class is
1380
+ associated with this collection the original ``fl`` string is returned
1381
+ unchanged.
1382
+ """
1383
+ if not self.model_class or "*" not in fl:
1384
+ return fl
1385
+
1386
+ all_fields = list(self.model_class.flat_fields().keys())
1387
+ expanded: list[str] = []
1388
+ for pattern in fl.split(","):
1389
+ pattern = pattern.strip()
1390
+ if not pattern:
1391
+ # Skip empty entries (e.g. from trailing commas).
1392
+ continue
1393
+ if "*" not in pattern or pattern == "*":
1394
+ # Exact names and the bare '*' (meaning "all fields") are kept as-is.
1395
+ expanded.append(pattern)
1396
+ else:
1397
+ # Convert the glob-style wildcard to a full regex pattern.
1398
+ # Replace '*' with '.*' and escape all other regex special characters.
1399
+ regex = re.compile("^" + re.escape(pattern).replace(r"\*", ".*") + "$")
1400
+ matched = [f for f in all_fields if regex.match(f)]
1401
+ expanded.extend(matched if matched else [pattern])
1402
+ return ",".join(expanded)
1403
+
1367
1404
  def _format_output(self, result, fields=None, as_obj=True):
1368
1405
  # Getting search document data
1369
1406
  extra_fields = result.get("fields", {})
@@ -1735,6 +1772,7 @@ class ESCollection(Generic[ModelType]):
1735
1772
  ]
1736
1773
 
1737
1774
  if fl:
1775
+ fl = self._expand_fl(fl)
1738
1776
  field_list = fl.split(",")
1739
1777
  args.append(("field_list", field_list))
1740
1778
  else:
@@ -1847,6 +1885,7 @@ class ESCollection(Generic[ModelType]):
1847
1885
  filters.append(access_control)
1848
1886
 
1849
1887
  if fl:
1888
+ fl = self._expand_fl(fl)
1850
1889
  fl = fl.split(",")
1851
1890
 
1852
1891
  query_expression = {
@@ -1896,6 +1935,8 @@ class ESCollection(Generic[ModelType]):
1896
1935
 
1897
1936
  if not fl:
1898
1937
  fl = "howler.id"
1938
+ else:
1939
+ fl = self._expand_fl(fl)
1899
1940
 
1900
1941
  if rows is None:
1901
1942
  rows = 5
@@ -2226,6 +2267,7 @@ class ESCollection(Generic[ModelType]):
2226
2267
  filters.append("%s:*" % group_field)
2227
2268
 
2228
2269
  if fl:
2270
+ fl = self._expand_fl(fl)
2229
2271
  field_list = fl.split(",")
2230
2272
  args.append(("field_list", field_list))
2231
2273
  else:
@@ -1,5 +1,3 @@
1
- from typing import Optional
2
-
3
1
  from howler import odm
4
2
  from howler.odm.models.ecs.code_signature import CodeSignature
5
3
  from howler.odm.models.ecs.elf import ELF
@@ -17,67 +15,69 @@ FILE_TYPE = ["file", "dir", "symlink"]
17
15
  description="A file is defined as a set of information that has been created on, or has existed on a filesystem.",
18
16
  )
19
17
  class File(odm.Model):
20
- accessed: Optional[str] = odm.Optional(odm.Date(description="Last time the file was accessed."))
21
- attributes: Optional[list[str]] = odm.Optional(odm.List(odm.Keyword(), description="Array of file attributes."))
22
- created: Optional[str] = odm.Optional(odm.Date(description="File creation time."))
23
- ctime: Optional[str] = odm.Optional(odm.Date(description="Last time the file attributes or metadata changed."))
24
- device: Optional[str] = odm.Optional(odm.Keyword(description="Device that is the source of the file."))
25
- directory: Optional[str] = odm.Optional(
18
+ accessed: str | None = odm.Optional(odm.Date(description="Last time the file was accessed."))
19
+ attributes: list[str] | None = odm.Optional(odm.List(odm.Keyword(), description="Array of file attributes."))
20
+ created: str | None = odm.Optional(odm.Date(description="File creation time."))
21
+ ctime: str | None = odm.Optional(odm.Date(description="Last time the file attributes or metadata changed."))
22
+ device: str | None = odm.Optional(odm.Keyword(description="Device that is the source of the file."))
23
+ directory: str | None = odm.Optional(
26
24
  odm.Keyword(
27
25
  description="Directory where the file is located. It should include the drive letter, when appropriate."
28
26
  )
29
27
  )
30
- drive_letter: Optional[str] = odm.Optional(
28
+ drive_letter: str | None = odm.Optional(
31
29
  odm.Keyword(description="Drive letter where the file is located. This field is only relevant on Windows.")
32
30
  )
33
- extension: Optional[str] = odm.Optional(odm.Keyword(description="File extension, excluding the leading dot."))
34
- fork_name: Optional[str] = odm.Optional(
31
+ extension: str | None = odm.Optional(odm.Keyword(description="File extension, excluding the leading dot."))
32
+ fork_name: str | None = odm.Optional(
35
33
  odm.Keyword(description="A fork is additional data associated with a filesystem object.")
36
34
  )
37
- gid: Optional[str] = odm.Optional(odm.Keyword(description="Primary group ID (GID) of the file."))
38
- group: Optional[str] = odm.Optional(odm.Keyword(description="Primary group name of the file."))
39
- inode: Optional[str] = odm.Optional(odm.Keyword(description="Inode representing the file in the filesystem."))
40
- mime_type: Optional[str] = odm.Optional(
35
+ gid: str | None = odm.Optional(odm.Keyword(description="Primary group ID (GID) of the file."))
36
+ group: str | None = odm.Optional(odm.Keyword(description="Primary group name of the file."))
37
+ inode: str | None = odm.Optional(odm.Keyword(description="Inode representing the file in the filesystem."))
38
+ mime_type: str | None = odm.Optional(
41
39
  odm.Keyword(
42
40
  description="MIME type should identify the format of the file or stream of "
43
41
  "bytes using IANA official types, where possible."
44
42
  )
45
43
  )
46
- mode: Optional[str] = odm.Optional(odm.Keyword(description="Mode of the file in octal representation."))
47
- mtime: Optional[str] = odm.Optional(odm.Date(description="Last time the file content was modified."))
48
- name: Optional[str] = odm.Optional(
44
+ mode: str | None = odm.Optional(odm.Keyword(description="Mode of the file in octal representation."))
45
+ mtime: str | None = odm.Optional(odm.Date(description="Last time the file content was modified."))
46
+ name: str | None = odm.Optional(
49
47
  odm.Keyword(description="Name of the file including the extension, without the directory.")
50
48
  )
51
- owner: Optional[str] = odm.Optional(odm.Keyword(description="File owner’s username."))
52
- path: Optional[str] = odm.Optional(
49
+ owner: str | None = odm.Optional(odm.Keyword(description="File owner’s username."))
50
+ path: str | None = odm.Optional(
53
51
  odm.Keyword(
54
52
  description="Full path to the file, including the file name. "
55
53
  "It should include the drive letter, when appropriate."
56
54
  )
57
55
  )
58
- size: Optional[int] = odm.Integer(description="File size in bytes.", optional=True)
59
- target_path: Optional[str] = odm.Optional(odm.Keyword(description="Target path for symlinks."))
60
- type: Optional[str] = odm.Optional(odm.Enum(values=FILE_TYPE, description="File type (file, dir, or symlink)."))
61
- uid: Optional[str] = odm.Optional(
56
+ size: int | None = odm.Long(description="File size in bytes.", optional=True)
57
+ target_path: str | None = odm.Optional(odm.Keyword(description="Target path for symlinks."))
58
+ type: str | None = odm.Optional(odm.Enum(values=FILE_TYPE, description="File type (file, dir, or symlink)."))
59
+ uid: str | None = odm.Optional(
62
60
  odm.Keyword(description="The user ID (UID) or security identifier (SID) of the file owner.")
63
61
  )
64
62
 
65
- code_signature: Optional[CodeSignature] = odm.Optional(
63
+ code_signature: CodeSignature | None = odm.Optional(
66
64
  odm.Compound(
67
65
  CodeSignature,
68
66
  description="These fields contain information about binary code signatures.",
69
67
  )
70
68
  )
71
- elf: Optional[ELF] = odm.Optional(
69
+ elf: ELF | None = odm.Optional(
72
70
  odm.Compound(
73
71
  ELF,
74
72
  description="These fields contain Linux Executable Linkable Format (ELF) metadata.",
75
73
  )
76
74
  )
77
- hash: Optional[Hashes] = odm.Optional(
75
+ hash: Hashes | None = odm.Optional(
78
76
  odm.Compound(
79
77
  Hashes,
80
- description="These fields contain Windows Portable Executable (PE) metadata.",
78
+ description="Hashes, usually file hashes.",
81
79
  )
82
80
  )
83
- pe: Optional[PE] = odm.Optional(odm.Compound(PE, description="Hashes, usually file hashes."))
81
+ pe: PE | None = odm.Optional(
82
+ odm.Compound(PE, description="These fields contain Windows Portable Executable (PE) metadata.")
83
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: howler-api
3
- Version: 3.4.0.dev955
3
+ Version: 3.4.0.dev970
4
4
  Summary: Howler - API server
5
5
  License: MIT
6
6
  Keywords: howler,alerting,gc,canada,cse-cst,cse,cst,cyber,cccs
@@ -54,7 +54,7 @@ howler/cronjobs/view_cleanup.py,sha256=-eMfiJmy6W4L3BuZ3PvBIJBIAZjY7wvupxLJucl6c
54
54
  howler/datastore/README.md,sha256=ekWl1YJSrHlZpU5PgBkPEzPWjdbTdav6Rd2P0ccIesw,4758
55
55
  howler/datastore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  howler/datastore/bulk.py,sha256=pMsaAavRkYSDx0dvp_hbc7ftirtJfJRKFFlFoQDTh-Q,3005
57
- howler/datastore/collection.py,sha256=KsHPgXq2Q9Ii5CymRqAN1is6ttivmNkPI7P67AuyU98,99871
57
+ howler/datastore/collection.py,sha256=hVPGftVY_vUMORxJjbkUY7c3ybqtE5Eulia3n0M9DTU,101772
58
58
  howler/datastore/constants.py,sha256=x7ODomtOQmDjmXoAxly4onPAnUkq4BLZ1TBg-UgpU1g,2415
59
59
  howler/datastore/exceptions.py,sha256=yZvQXRI4mR50ltGFHbdZAD4TIbhdKJku6LLTPQ0JZRk,955
60
60
  howler/datastore/howler_store.py,sha256=9rfAx-bbkDRgxo8cDB7R_TxkvgO99td_SPQo-GQ_zhg,3247
@@ -114,7 +114,7 @@ howler/odm/models/ecs/email.py,sha256=sKiws9D4l6Prw4cc9LG_UAmjN4chcmVy201bSmVn-8
114
114
  howler/odm/models/ecs/error.py,sha256=hUogevpLF7VBaetkntezhitMMqguRnksSWuF6JXjxmQ,461
115
115
  howler/odm/models/ecs/event.py,sha256=HuLtLUY_iomrSwjMMt_D2tEJnl68yGLpn5PdfwyN1PI,5020
116
116
  howler/odm/models/ecs/faas.py,sha256=AakHGqY6b-kFs03xxN_HhjNAFWXqtfggai_E8CtE7vE,1229
117
- howler/odm/models/ecs/file.py,sha256=4yg57cANyQoG93iWgA82KL7kBAlY_PvK-lWuYuBnBOU,4054
117
+ howler/odm/models/ecs/file.py,sha256=iim1QclJvjRNO3uokbaMKIUdd5To5Ida9kMtN7uH0Fw,3958
118
118
  howler/odm/models/ecs/geo.py,sha256=R6yKphOQMgrUEC7bnTpM95N40AS5Bi5mjfTrp-2wL1g,1408
119
119
  howler/odm/models/ecs/group.py,sha256=AdK7S7XK3tYJdRlCrzCNfO499aJ0io9VeSe5xFwi4Ns,765
120
120
  howler/odm/models/ecs/hash.py,sha256=X8_M5mPoff3hmESVropUKVCCMK8ZPiBUdjpXYGDdgak,700
@@ -198,7 +198,7 @@ howler/utils/path.py,sha256=DfOU4i4zSs4wchHoE8iE7aWVLkTxiC_JRGepF2hBYBk,690
198
198
  howler/utils/socket_utils.py,sha256=nz1SklC9xBHUSfHyTJjpq3mbozX1GDf01WzdGxfaUII,2212
199
199
  howler/utils/str_utils.py,sha256=HE8Hqh2HlOLaj16w0H9zKOyDJLp-f1LQ50y_WeGZaEk,8389
200
200
  howler/utils/uid.py,sha256=p9dsqyvZ-lpiAuzZWCPCeEM99kdk0Ly9czf04HNdSuw,1341
201
- howler_api-3.4.0.dev955.dist-info/METADATA,sha256=sB-JTliE2zG50he11mruPBhIweCS5V5325Lg0AU8gQ0,2879
202
- howler_api-3.4.0.dev955.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
203
- howler_api-3.4.0.dev955.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
204
- howler_api-3.4.0.dev955.dist-info/RECORD,,
201
+ howler_api-3.4.0.dev970.dist-info/METADATA,sha256=NTuHgaGd9W70dInWb-7af612d1_AkiGe4nulWL5crnQ,2879
202
+ howler_api-3.4.0.dev970.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
203
+ howler_api-3.4.0.dev970.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
204
+ howler_api-3.4.0.dev970.dist-info/RECORD,,