taranis-models 1.2.0.dev4__tar.gz → 1.2.0.dev5__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 (22) hide show
  1. {taranis_models-1.2.0.dev4/taranis_models.egg-info → taranis_models-1.2.0.dev5}/PKG-INFO +1 -1
  2. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/admin.py +1 -0
  3. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/types.py +41 -1
  4. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5/taranis_models.egg-info}/PKG-INFO +1 -1
  5. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/.dockerignore +0 -0
  6. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/.gitignore +0 -0
  7. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/LICENSE.md +0 -0
  8. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/README.md +0 -0
  9. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/__init__.py +0 -0
  10. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/assess.py +0 -0
  11. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/base.py +0 -0
  12. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/cache.py +0 -0
  13. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/dashboard.py +0 -0
  14. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/product.py +0 -0
  15. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/models/report.py +0 -0
  16. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/pyproject.toml +0 -0
  17. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/setup.cfg +0 -0
  18. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/taranis_models.egg-info/SOURCES.txt +0 -0
  19. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/taranis_models.egg-info/dependency_links.txt +0 -0
  20. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/taranis_models.egg-info/requires.txt +0 -0
  21. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/taranis_models.egg-info/top_level.txt +0 -0
  22. {taranis_models-1.2.0.dev4 → taranis_models-1.2.0.dev5}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: taranis-models
3
- Version: 1.2.0.dev4
3
+ Version: 1.2.0.dev5
4
4
  Summary: Taranis AI Models
5
5
  Maintainer-email: AIT <benjamin.akhras@ait.ac.at>
6
6
  License-Expression: EUPL-1.2
@@ -100,6 +100,7 @@ class Role(TaranisBaseModel):
100
100
  _core_endpoint = "/config/roles"
101
101
  _model_name = "role"
102
102
  _search_fields = ["name", "description"]
103
+ _pretty_name = "Role"
103
104
 
104
105
  id: int | None = None
105
106
  name: str = ""
@@ -1,4 +1,5 @@
1
- from enum import StrEnum, auto, IntEnum
1
+ from enum import StrEnum, auto, IntEnum, nonmember
2
+ import contextlib
2
3
 
3
4
 
4
5
  class TLPLevel(StrEnum):
@@ -8,6 +9,45 @@ class TLPLevel(StrEnum):
8
9
  AMBER = "amber"
9
10
  RED = "red"
10
11
 
12
+ _ACCESSIBLE_NAMES = nonmember(
13
+ {
14
+ "RED": ["RED", "AMBER_STRICT", "AMBER", "GREEN", "CLEAR"],
15
+ "AMBER_STRICT": ["AMBER_STRICT", "AMBER", "GREEN", "CLEAR"],
16
+ "AMBER": ["AMBER", "GREEN", "CLEAR"],
17
+ "GREEN": ["GREEN", "CLEAR"],
18
+ "CLEAR": ["CLEAR"],
19
+ }
20
+ )
21
+
22
+ def get_accessible_levels(self) -> list[str]:
23
+ """
24
+ Return the list of TLPLevel members this level can access.
25
+ """
26
+ names = type(self)._ACCESSIBLE_NAMES.get(self.name, [])
27
+ return [type(self)[nm].value for nm in names]
28
+
29
+ @classmethod
30
+ def get_most_restrictive_tlp(cls, tlp_levels: list["TLPLevel"]) -> "TLPLevel":
31
+ """
32
+ Get the most restrictive TLP level from a list of TLP levels.
33
+ If the list is empty, return the default TLP level (CLEAR).
34
+ """
35
+ if not tlp_levels:
36
+ return cls.CLEAR
37
+
38
+ provided = {tlp.name for tlp in tlp_levels}
39
+
40
+ return next(
41
+ (cls[level_name] for level_name in cls._ACCESSIBLE_NAMES.keys() if level_name in provided),
42
+ cls.CLEAR,
43
+ )
44
+
45
+ @classmethod
46
+ def get_tlp_level(cls, tlp_level: str) -> "TLPLevel | None":
47
+ with contextlib.suppress(ValueError):
48
+ return TLPLevel(tlp_level)
49
+ return None
50
+
11
51
 
12
52
  class ItemType(StrEnum):
13
53
  OSINT_SOURCE = auto()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: taranis-models
3
- Version: 1.2.0.dev4
3
+ Version: 1.2.0.dev5
4
4
  Summary: Taranis AI Models
5
5
  Maintainer-email: AIT <benjamin.akhras@ait.ac.at>
6
6
  License-Expression: EUPL-1.2