stidantic 0.1.3__py3-none-any.whl → 0.2.1__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.

Potentially problematic release.


This version of stidantic might be problematic. Click here for more details.

stidantic/__init__.py ADDED
File without changes
stidantic/bundle.py CHANGED
@@ -1,12 +1,14 @@
1
1
  from typing import Annotated
2
+
2
3
  from pydantic import Field
3
- from stidantic.types import StixCore, Identifier, StixCommon
4
- from stidantic.sdo import SDOs
5
- from stidantic.sco import SCOs
6
- from stidantic.sro import SROs
4
+
5
+ from stidantic.extension import ExtensionDefinition
7
6
  from stidantic.language import LanguageContent
8
7
  from stidantic.marking import MarkingDefinition
9
- from stidantic.extension import ExtensionDefinition
8
+ from stidantic.sco import SCOs
9
+ from stidantic.sdo import SDOs
10
+ from stidantic.sro import SROs
11
+ from stidantic.types import Identifier, StixCommon, StixCore
10
12
 
11
13
 
12
14
  # 8. Stix Bundle
@@ -15,14 +17,7 @@ class StixBundle(StixCore):
15
17
  type: str = "bundle"
16
18
  objects: list[
17
19
  Annotated[
18
- (
19
- SROs
20
- | SDOs
21
- | SCOs
22
- | MarkingDefinition
23
- | LanguageContent
24
- | ExtensionDefinition
25
- ),
20
+ (SROs | SDOs | SCOs | MarkingDefinition | LanguageContent | ExtensionDefinition),
26
21
  Field(discriminator="type"),
27
22
  ]
28
23
  | StixCommon
stidantic/extension.py CHANGED
@@ -1,7 +1,9 @@
1
- from typing import Literal, Annotated, Self
1
+ from typing import Annotated, Literal, Self
2
+
2
3
  from pydantic import Field
3
4
  from pydantic.functional_validators import model_validator
4
- from stidantic.types import StixExtension, ExtensionType, StixProp
5
+
6
+ from stidantic.types import ExtensionType, StixExtension, StixProp
5
7
 
6
8
 
7
9
  # 7.3 Extension Definition
@@ -106,8 +108,7 @@ class ExtensionDefinition(StixExtension):
106
108
  top-level of an existing object.
107
109
  """
108
110
  if (
109
- self.extension_properties
110
- and ExtensionType.toplevel_property_extension not in self.extension_types
111
+ self.extension_properties and ExtensionType.toplevel_property_extension.value not in self.extension_types # pyright: ignore[reportUnnecessaryContains] because of use_enum_value=True
111
112
  ):
112
113
  raise ValueError(
113
114
  "extension_types property can't be used without toplevel-property-extension in extension_types."
File without changes
@@ -1,17 +1,16 @@
1
+ from datetime import UTC, datetime
1
2
  from enum import Enum
2
3
  from typing import Literal
3
- from datetime import datetime, timezone
4
4
 
5
5
  from stidantic.extension import ExtensionDefinition
6
+ from stidantic.marking import MarkingDefinition
6
7
  from stidantic.types import (
7
8
  Extension,
8
9
  ExtensionType,
9
10
  Identifier,
10
11
  )
11
- from stidantic.marking import MarkingDefinition
12
-
13
12
 
14
- STIX_PAP_EXT_CREATION_DATE = datetime(2022, 11, 28, 00, 00, 00, 00, tzinfo=timezone.utc)
13
+ STIX_PAP_EXT_CREATION_DATE = datetime(2022, 11, 28, 00, 00, 00, 00, tzinfo=UTC)
15
14
  CISA = Identifier("identity--b3bca3c2-1f3d-4b54-b44f-dac42c3a8f01")
16
15
 
17
16
  PAPExtensionDefinition = ExtensionDefinition(
@@ -37,30 +36,30 @@ class PAP(Enum):
37
36
  white = MarkingDefinition(
38
37
  id=Identifier("marking-definition--a3bea94c-b469-41dc-9cfe-d6e7daba7730"),
39
38
  name="PAP:WHITE",
40
- created=datetime(2022, 10, 1, 00, 00, 00, 00, tzinfo=timezone.utc),
39
+ created=datetime(2022, 10, 1, 00, 00, 00, 00, tzinfo=UTC),
41
40
  extensions={PAPExtensionDefinition.id: PAPExtension(pap="white")},
42
41
  )
43
42
  clear = MarkingDefinition(
44
43
  id=Identifier("marking-definition--ad15a0cd-55b6-4588-a14c-a66105329b92"),
45
44
  name="PAP:CLEAR",
46
- created=datetime(2022, 10, 1, 00, 00, 00, 00, tzinfo=timezone.utc),
45
+ created=datetime(2022, 10, 1, 00, 00, 00, 00, tzinfo=UTC),
47
46
  extensions={PAPExtensionDefinition.id: PAPExtension(pap="clear")},
48
47
  )
49
48
  green = MarkingDefinition(
50
49
  id=Identifier("marking-definition--c43594d1-4b11-4c59-93ab-1c9b14d53ce9"),
51
50
  name="PAP:GREEN",
52
- created=datetime(2022, 10, 9, 00, 00, 00, 00, tzinfo=timezone.utc),
51
+ created=datetime(2022, 10, 9, 00, 00, 00, 00, tzinfo=UTC),
53
52
  extensions={PAPExtensionDefinition.id: PAPExtension(pap="green")},
54
53
  )
55
54
  red = MarkingDefinition(
56
55
  id=Identifier("marking-definition--740d36e5-7714-4c30-961a-3ae632ceee0e"),
57
56
  name="PAP:RED",
58
- created=datetime(2022, 10, 6, 00, 00, 00, 00, tzinfo=timezone.utc),
57
+ created=datetime(2022, 10, 6, 00, 00, 00, 00, tzinfo=UTC),
59
58
  extensions={PAPExtensionDefinition.id: PAPExtension(pap="red")},
60
59
  )
61
60
  amber = MarkingDefinition(
62
61
  id=Identifier("marking-definition--60f8932b-e51e-4458-b265-a2e8be9a80ab"),
63
62
  name="PAP:AMBER",
64
- created=datetime(2022, 10, 2, 00, 00, 00, 00, tzinfo=timezone.utc),
63
+ created=datetime(2022, 10, 2, 00, 00, 00, 00, tzinfo=UTC),
65
64
  extensions={PAPExtensionDefinition.id: PAPExtension(pap="amber")},
66
65
  )
stidantic/language.py CHANGED
@@ -1,6 +1,8 @@
1
- from datetime import datetime
2
1
  from typing import Literal
3
- from stidantic.types import Identifier, StixLanguage
2
+
3
+ from pydantic.types import JsonValue
4
+
5
+ from stidantic.types import Identifier, StixLanguage, StixTimestamp
4
6
 
5
7
 
6
8
  # 7.1 Language Content
@@ -11,7 +13,7 @@ class LanguageContent(StixLanguage):
11
13
  object_ref: Identifier
12
14
  # The object_modified property identifies the modified time of the object that this Language Content applies to.
13
15
  # It MUST be an exact match for the modified time of the STIX Object being referenced.
14
- object_modified: datetime | None = None
16
+ object_modified: StixTimestamp | None = None
15
17
  # The contents property contains the actual Language Content (translation).
16
18
  # The keys in the dictionary MUST be RFC 5646 language codes for which language content is being provided [RFC5646].
17
19
  # The values each consist of a dictionary that mirrors the properties in the target object
@@ -32,4 +34,4 @@ class LanguageContent(StixLanguage):
32
34
  # with the same key in the original.
33
35
  # The translation object MAY contain only a subset of the translatable fields of the original. Keys that point to
34
36
  # non-translatable properties in the target or to properties that do not exist in the target object MUST be ignored.
35
- contents: dict[str, dict[str, str]]
37
+ contents: dict[str, dict[str, JsonValue]]
stidantic/marking.py CHANGED
@@ -1,12 +1,13 @@
1
- from typing import Literal, Self
1
+ from datetime import UTC, datetime
2
2
  from enum import Enum
3
- from datetime import datetime, timezone
3
+ from typing import Literal, Self
4
4
 
5
5
  from pydantic.functional_validators import model_validator
6
+
6
7
  from stidantic.types import (
8
+ Identifier,
7
9
  StixCore,
8
10
  StixMarking,
9
- Identifier,
10
11
  )
11
12
 
12
13
 
@@ -78,7 +79,7 @@ class MarkingDefinition(StixMarking):
78
79
  return self
79
80
 
80
81
 
81
- STIX_ZERO_DATE = datetime(2017, 1, 20, 00, 00, 00, 00, tzinfo=timezone.utc)
82
+ STIX_ZERO_DATE = datetime(2017, 1, 20, 00, 00, 00, 00, tzinfo=UTC)
82
83
 
83
84
 
84
85
  class TLP(Enum):