stidantic 0.1.3__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.

@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: stidantic
3
+ Version: 0.1.3
4
+ Summary: A Pydantic-based Python library for parsing, validating, and creating STIX 2.1 cyber threat intelligence data.
5
+ Project-URL: Homepage, https://github.com/nicocti/stidantic
6
+ Project-URL: Bug Tracker, https://github.com/nicocti/stidantic/issues
7
+ Author-email: nicocti <nicocti@users.noreply.github.com>
8
+ Maintainer-email: nicocti <nicocti@users.noreply.github.com>
9
+ License-File: LICENSE
10
+ Keywords: cti,pydantic,stix,stix2,stix2.1
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Information Technology
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Security
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: annotated-types>=0.6.0
24
+ Requires-Dist: pydantic>=2.12
25
+ Requires-Dist: typing-extensions>=4.14.1
26
+ Description-Content-Type: text/markdown
27
+
28
+ # stidantic [WIP]
29
+
30
+ **This is work in progress, compliant but untested.**
31
+
32
+ A Pydantic-based Python library for parsing, validating, and creating STIX 2.1 cyber threat intelligence data.
33
+
34
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
35
+ [![Pydantic v2](https://img.shields.io/badge/pydantic-v2.12+-green.svg)](https://docs.pydantic.dev/)
36
+ [![STIX v2.1](https://img.shields.io/badge/stix-v2.1+-red.svg)](https://oasis-open.github.io/cti-documentation/stix/intro)
37
+
38
+ ## Overview
39
+
40
+ **stidantic** provides a type-safe, Pythonic way to work with [STIX 2.1](https://oasis-open.github.io/cti-documentation/stix/intro) (Structured Threat Information Expression) objects.
41
+
42
+ This library leverages [Pydantic](https://docs.pydantic.dev/) to provide:
43
+
44
+ - 🔒 **Strong type validation** for all STIX objects
45
+ - 📝 **IDE auto-completion** and type hints
46
+ - ✅ **Automatic validation** of STIX specification constraints
47
+ - 🔄 **Easy JSON serialization/deserialization**
48
+ - ❄️ **Immutable models** with frozen Pydantic configurations
49
+ - 🎯 **Discriminated unions** for polymorphic STIX object handling
50
+
51
+ ## Installation
52
+
53
+ ### Requirements
54
+
55
+ - Python 3.12 or later (uses PEP 695 type statements)
56
+ - Pydantic >= 2.12
57
+
58
+ ## Quick Start
59
+
60
+ ### Parsing a STIX Bundle
61
+
62
+ ```python
63
+ from stidantic.bundle import StixBundle
64
+
65
+ # Load from JSON file
66
+ with open("threat_data.json", "r") as f:
67
+ bundle = StixBundle.model_validate_json(f.read())
68
+
69
+ # Access objects
70
+ print(f"Bundle contains {len(bundle.objects)} objects")
71
+ for obj in bundle.objects:
72
+ print(f"- {obj.type}: {obj.id}")
73
+ ```
74
+
75
+ ### Creating STIX Objects
76
+
77
+ ```python
78
+ from datetime import datetime
79
+ from stidantic.sdo import Campaign
80
+ from stidantic.types import Identifier
81
+
82
+ campaign = Campaign(
83
+ id=Identifier("campaign--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f"),
84
+ created=datetime.now(),
85
+ modified=datetime.now(),
86
+ name="Operation Stealth",
87
+ description="A sophisticated campaign targeting financial institutions",
88
+ objective="Financial gain through wire fraud"
89
+ )
90
+
91
+ # Export to JSON
92
+ json_output = campaign.model_dump_json(indent=2, exclude_none=True, by_alias=True)
93
+ print(json_output)
94
+ ```
95
+
96
+ ### Handling property extensions
97
+
98
+ ```python
99
+ from stidantic.marking import MarkingDefinition
100
+ from stidantic.extensions.pap import PAPExtensionDefinition, PAPExtension
101
+
102
+ MarkingDefinition.register_new_extension(PAPExtensionDefinition, PAPExtension)
103
+ data = {
104
+ "id": "marking-definition--c43594d1-4b11-4c59-93ab-1c9b14d53ce9",
105
+ "type": "marking-definition",
106
+ "spec_version": "2.1",
107
+ "extensions": {
108
+ "extension-definition--f8d78575-edfd-406e-8e84-6162a8450f5b": {
109
+ "extension_type": "property-extension",
110
+ "pap": "green",
111
+ }
112
+ },
113
+ "created": "2022-10-01T00:00:00Z",
114
+ "name": "PAP:GREEN",
115
+ }
116
+
117
+ pap_green = MarkingDefinition.model_validate(data)
118
+ if isinstance(pap_green.extensions[PAPExtensionDefinition.id], PAPExtension):
119
+ print("Extension was parsed & validated by Pydantic.")
120
+ ```
121
+
122
+ ## Implemented STIX Objects
123
+
124
+ ### STIX Domain Objects (SDOs)
125
+ - ✅ `AttackPattern` - Ways adversaries attempt to compromise targets
126
+ - ✅ `Campaign` - Grouping of adversarial behaviors over time
127
+ - ✅ `Course of Action` - Action taken to prevent or respond to an attack
128
+ - ✅ `Grouping` - Explicitly asserts that STIX Objects have a shared context
129
+ - ✅ `Identity` - Actual individuals, organizations, or groups
130
+ - ✅ `Incident` - A stub object representing a security incident
131
+ - ✅ `Indicator` - Pattern that can be used to detect suspicious or malicious activity
132
+ - ✅ `Infrastructure` - Systems, software services, and associated resources
133
+ - ✅ `Intrusion Set` - A grouped set of adversarial behaviors and resources
134
+ - ✅ `Location` - A geographic location
135
+ - ✅ `Malware` - A type of TTP that represents malicious code
136
+ - ✅ `Malware Analysis` - The results of a malware analysis
137
+ - ✅ `Note` - Analyst-created content and context
138
+ - ✅ `Observed Data` - Information about cyber security related entities
139
+ - ✅ `Opinion` - An assessment of the correctness of a STIX Object
140
+ - ✅ `Report` - Collections of threat intelligence
141
+ - ✅ `Threat Actor` - Actual individuals, groups, or organizations
142
+ - ✅ `Tool` - Legitimate software that can be used by threat actors
143
+ - ✅ `Vulnerability` - A mistake in software that can be used to compromise a system
144
+
145
+ ### STIX Cyber-observable Objects (SCOs)
146
+ - ✅ `Artifact` - Binary or file-like objects
147
+ - ✅ `AutonomousSystem` - Autonomous System (AS) information
148
+ - ✅ `Directory` - A directory on a file system
149
+ - ✅ `Domain Name` - A network domain name
150
+ - ✅ `Email Address` - An email address
151
+ - ✅ `Email Message` - An email message
152
+ - ✅ `File` - A computer file
153
+ - ✅ `IPv4 Address` - An IPv4 address
154
+ - ✅ `IPv6 Address` - An IPv6 address
155
+ - ✅ `MAC Address` - A Media Access Control (MAC) address
156
+ - ✅ `Mutex` - A mutual exclusion object
157
+ - ✅ `Network Traffic` - A network traffic flow
158
+ - ✅ `Process` - A running process
159
+ - ✅ `Software` - A software product
160
+ - ✅ `URL` - A Uniform Resource Locator (URL)
161
+ - ✅ `User Account` - A user account on a system
162
+ - ✅ `Windows Registry Key` - A key in the Windows registry
163
+ - ✅ `X.509 Certificate` - An X.509 certificate
164
+
165
+ ### STIX Relationship Objects (SROs)
166
+ - ✅ `Relationship` - Connections between STIX objects
167
+ - ✅ `Sighting` - Observations of threat intelligence in the wild
168
+
169
+ ### Meta Objects
170
+ - ✅ `MarkingDefinition` - Data markings (includes TLP)
171
+ - ✅ `LanguageContent` - Translations and internationalization
172
+ - ✅ `ExtensionDefinition` - Custom STIX extensions
173
+
174
+ ### Bundle
175
+ - ✅ `StixBundle` - Container for STIX objects
176
+
177
+ ## Roadmap
178
+
179
+ - ~~**Full STIX 2.1 Compliance**~~
180
+ - **Python packaging**
181
+ - **Extensive Testing**
182
+ - Mind the datetime datatype serializer to follow the specification (convert to UTC).
183
+ - Implement auto deterministic UUIv5 generation for STIX Identifiers.
184
+ - Implement a Indicator to Observable export method (and the other way round ?).
185
+ - Add Generics validation for Identifier properties that must be of some type.
186
+ - Better STIX Extension Support: Develop a robust and user-friendly mechanism for defining, parsing, and validating custom STIX extensions.
187
+ - TAXII 2.1 Server: Build a TAXII 2.1 compliant server using FastAPI.
188
+ - OCA Standard Extensions: Implement STIX extensions from the [Open Cybersecurity Alliance (OCA)](https://github.com/opencybersecurityalliance/stix-extensions) and [stix-common-objects](https://github.com/oasis-open/cti-stix-common-objects) repositories.
189
+ - Performance Tuning: Profile and optimize parsing and serialization.
190
+
191
+ ## Resources
192
+
193
+ - [STIX 2.1 Specification](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)
194
+ - [STIX 2.1 Introduction](https://oasis-open.github.io/cti-documentation/stix/intro)
195
+ - [Pydantic Documentation](https://docs.pydantic.dev/)
196
+
197
+ ## License
198
+
199
+ stidantic is released under the [MIT License](https://opensource.org/licenses/MIT).
200
+
201
+ ## Acknowledgments
202
+
203
+ This project implements the STIX 2.1 specification edited by Bret Jordan, Rich Piazza, and Trey Darley, published by the OASIS Cyber Threat Intelligence (CTI) Technical Committee.
@@ -0,0 +1,15 @@
1
+ stidantic/bundle.py,sha256=Tg_62VhPfHE9LwSzC-qRy7yHnSyB1jeDRmb4ayxkj-U,768
2
+ stidantic/extension.py,sha256=bGJSxyKRbZkyK1d3dhfmoaQ77w_-epCpuOrPbStyXmc,7909
3
+ stidantic/language.py,sha256=ICPyx5bjOC-YP5bkpxoubJU9rEr25hbKwdFoPLq8u6s,2728
4
+ stidantic/marking.py,sha256=wydmsm-HrYO-osEKmhEAQ71IMSSzllKvttIm3GZVeoU,5521
5
+ stidantic/sco.py,sha256=8P1C_bVUaCnZdwErxIi8O3iQ6Pst1ObhxIKQq1CZk1k,75804
6
+ stidantic/sdo.py,sha256=RbjaqcU9qb9oE-JkAuKq68S_0yE0DHXZgkb78yTzsM8,56041
7
+ stidantic/sro.py,sha256=scntuescZ2Ukb5bcx7d3LCfvqys03DLU6_leT8F5p94,10617
8
+ stidantic/types.py,sha256=W0_Xw-LNNKJ5phxCncO3J6XYQXPkZEfkOzKyPP2q8aQ,21772
9
+ stidantic/validators.py,sha256=P_t1S8pSx1VCD9JNsB49s0p17Zj0_jtoUMc2gcGw56g,657
10
+ stidantic/vocab.py,sha256=dB1vWf27A0bn167KuzcLhgYHXZOKgjb23SsOHfrHuwo,18948
11
+ stidantic/extensions/pap.py,sha256=dJfwgt8HcW81gdpxXsG8EF1ucX0ZsM6C0YJ1yw9WbKw,2652
12
+ stidantic-0.1.3.dist-info/METADATA,sha256=dFEGfj7KyQQe4APeIDFUHrtIg1b0KE9t9wR6iQk6nfY,8311
13
+ stidantic-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ stidantic-0.1.3.dist-info/licenses/LICENSE,sha256=1Dm2uJzOTe6wtfCrm-OnmztCLqNrpyF8flo5fmVVpbM,1064
15
+ stidantic-0.1.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 nicocti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.