Skip to content

Commit f840d0f

Browse files
authored
feat(ocsf): adapt models to version 1.3.0 (#123)
1 parent df90186 commit f840d0f

File tree

9 files changed

+107
-90
lines changed

9 files changed

+107
-90
lines changed

examples/detection_finding.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@
150150
name="Account 1", type="Account", type_id="3", uid="123", labels=["Label 1"]
151151
),
152152
zone="Zone 1",
153-
org=Organization(name="Organization 1", ou_id="123", ou_name="OU 1", uid="123"),
153+
org=Organization(
154+
name="Organization 1", ou_uid="123", ou_name="OU 1", uid="123"
155+
),
154156
project_uid="123",
155157
provider="Provider 1",
156158
region="Region 1",
@@ -177,10 +179,9 @@
177179
size=123,
178180
uid="123",
179181
),
180-
namespace_pid=123,
181182
count=123,
182183
duration=123,
183-
event_time=datetime.now(),
184+
time=datetime.now(),
184185
evidences=[
185186
EvidenceArtifacts(
186187
api=API(

py_ocsf_models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
OCSF_VERSION = "1.2.0"
1+
OCSF_VERSION = "1.3.0"

py_ocsf_models/events/findings/detection_finding.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from py_ocsf_models.events.findings.finding import Finding
88
from py_ocsf_models.objects.api import API
99
from py_ocsf_models.objects.cloud import Cloud
10-
from py_ocsf_models.objects.container import Container
1110
from py_ocsf_models.objects.evidence_artifacts import EvidenceArtifacts
1211
from py_ocsf_models.objects.remediation import Remediation
1312
from py_ocsf_models.objects.resource_details import ResourceDetails
@@ -122,10 +121,10 @@ class DetectionFinding(Finding, BaseModel):
122121
- Class (class_name) [Optional]: The event class name, as defined by class_uid value: Detection Finding.
123122
- Class ID (class_uid): The unique identifier of a class. A Class describes the attributes available in an event.
124123
- Cloud (cloud) [Optional]: Describes details about the Cloud environment where the event was originally created or logged.
125-
- Container (container) [Optional]: Describes the container details.
126124
- Count (count) [Optional]: Number of times similar events occurred within a specified timeframe.
127125
- Duration (duration) [Optional]: Time span of the event, from start to end, in milliseconds.
128126
- Event Time (time) [Required]: The standardized time when the event occurred or the finding was created.
127+
- Event Time (time_dt) [Optional]: The standardized time when the event occurred or the finding was created, in datetime format.
129128
- Evidence Artifacts (evidences) [Optional]: Artifacts related to the security detection activities.
130129
- Impact (impact) [Optional]: The impact, normalized to the caption of the impact_id value. In the case of 'Other', it is defined by the event source.
131130
- Impact Score (impact_score) [Optional]: The impact of the finding, valid range 0-100.
@@ -135,32 +134,26 @@ class DetectionFinding(Finding, BaseModel):
135134
- Risk Level ID (risk_level_id) [Optional]: The normalized risk level id.
136135
- Risk Score (risk_score) [Optional]: The risk score as reported by the event source.
137136
- Risk Details (risk_details) [Optional]: Additional details about the risk.
137+
- Status ID (status_id) [Optional]: The normalized identifier of the event/finding severity.
138138
- Timezone Offset (timezone_offset) [Optional]: Difference in minutes from UTC.
139139
- Type ID (type_uid): The event/finding type ID. It identifies the event's semantics and structure. The value is calculated by the logging system as: class_uid * 100 + activity_id.
140140
- Type Name (type_name) [Optional]: The event/finding type name, as defined by the type_uid.
141141
- Vulnerabilities (vulnerabilities) [Optional]: Vulnerabilities identified in the finding.
142142
143143
If the Cloud profile is needed:
144144
- API Details (api) [Optional]: Describes details about a typical API (Application Programming Interface) call.
145-
- Cloud (cloud): Describes details about the Cloud environment where the event was originally created or logged.
146-
147-
If the Container profile is needed:
148-
- Container (container) [Recommended]: The information describing an instance of a container. A container is a prepackaged, portable system image that runs isolated on an existing system using a container runtime like containerd.
149-
- Namespace PID (namespace_pid) [Recommended]: If running under a process namespace (such as in a container), the process identifier within that process namespace.
145+
- Cloud (cloud): Describes details about the Cloud environment where the event was originally created or logged
150146
"""
151147

152148
resources: Optional[list[ResourceDetails]]
153149
category_name: str = CategoryUID.Findings.name
154150
category_uid: int = CategoryUID.Findings.value
155-
class_name: Optional[str] = ClassUID.DetectionFinding.name
151+
class_name: Optional[str] = "Detection Finding"
156152
class_uid: int = ClassUID.DetectionFinding.value
157153
cloud: Optional[Cloud]
158154
api: Optional[API]
159-
container: Optional[Container]
160-
namespace_pid: Optional[int]
161155
count: Optional[int]
162156
duration: Optional[int]
163-
event_time: datetime
164157
evidences: Optional[list[EvidenceArtifacts]]
165158
impact: Optional[str]
166159
impact_score: Optional[int]
@@ -171,6 +164,8 @@ class DetectionFinding(Finding, BaseModel):
171164
risk_score: Optional[int]
172165
risk_details: Optional[str]
173166
status_id: Optional[StatusID] # type: ignore
167+
time: int
168+
time_dt: Optional[datetime]
174169
timezone_offset: Optional[int]
175170
type_uid: TypeID
176171
type_name: Optional[str]

py_ocsf_models/events/findings/finding.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ class FindingInformation(BaseModel):
7979
Attributes:
8080
- Analytic (analytic) [Recommended]: The analytic technique used to analyze and derive insights from the data or information that led to the finding or conclusion.
8181
- Created Time (created_time) [Optional]: The time when the finding was created.
82+
- Created Time DT (created_time_dt) [Optional]: The time when the finding was created in datetime format.
8283
- Data Sources (data_sources) [Optional]: A list of data sources utilized in generation of the finding.
8384
- Description (desc) [Optional]: The description of the reported finding.
84-
- First Seen (first_seen_time) [Optional]: The time when the finding was first observed. It can differ from the created_time datetime, which reflects the time this finding was created.
85+
- First Seen (first_seen_time) [Optional]: The time when the finding was first observed.
86+
- First Seen DT (first_seen_time_dt) [Optional]: The time when the finding was first observed in datetime format.
8587
- Kill Chain (kill_chain) [Optional]: The Cyber Kill Chain® provides a detailed description of each phase and its associated activities within the broader context of a cyber attack.
86-
- Last Seen (last_seen_time) [Optional]: The time when the finding was most recently observed. It can differ from the modified_time datetime, which reflects the time this finding was last modified.
88+
- Last Seen (last_seen_time) [Optional]: The time when the finding was last observed.
89+
- Last Seen DT (last_seen_time_dt) [Optional]: The time when the finding was last observed in datetime format.
8790
- MITRE ATT&CK® Details (attacks) [Optional]: The MITRE ATT&CK® technique and associated tactics related to the finding.
8891
- Modified Time (modified_time) [Optional]: The time when the finding was last modified.
92+
- Modified Time DT (modified_time_dt) [Optional]: The time when the finding was last modified in datetime format.
8993
- Product Identifier (product_uid) [Optional]: The unique identifier of the product that reported the finding.
9094
- Related Analytics (related_analytics) [Optional]: Other analytics related to this finding.
9195
- Related Events (related_events) [Optional]: Describes events and/or other findings related to the finding as identified by the security product.
@@ -96,14 +100,18 @@ class FindingInformation(BaseModel):
96100
"""
97101

98102
analytic: Optional[Analytic]
99-
created_time: Optional[datetime]
103+
created_time: Optional[int]
104+
created_time_dt: Optional[datetime]
100105
data_sources: Optional[List[str]]
101106
desc: Optional[str]
102-
first_seen_time: Optional[datetime]
107+
first_seen_time: Optional[int]
108+
first_seen_time_dt: Optional[datetime]
103109
kill_chain: Optional[List[KillChainPhase]]
104-
last_seen_time: Optional[datetime]
110+
last_seen_time: Optional[int]
111+
last_seen_time_dt: Optional[datetime]
105112
attacks: Optional[List[MITREAttack]]
106-
modified_time: Optional[datetime]
113+
modified_time: Optional[int]
114+
modified_time_dt: Optional[datetime]
107115
product_uid: Optional[str]
108116
related_analytics: Optional[List[Analytic]]
109117
related_events: Optional[List[RelatedEvent]]
@@ -161,9 +169,11 @@ class Finding(BaseEvent, BaseModel):
161169
- Confidence (confidence) [Optional]: The confidence, normalized to the caption of the confidence_id value. In the case of 'Other', it is defined by the event source.
162170
- Confidence ID (confidence_id) [Optional]: Represents the accuracy of the detection rule. A low confidence indicates a broad finding scope that may include benign events.
163171
- Confidence Score (confidence_score) [Optional]: The confidence score as reported by the event source.
164-
- End Time (end_time) [Optional]: datetime of the most recent event included in the finding.
172+
- End Time (end_time) [Optional]: Time of the latest event included in the finding.
173+
- End Time DT (end_time_dt) [Optional]: Time of the latest event included in the finding in datetime format.
165174
- Finding Information (finding_info) [Required]: Describes the supporting information about a generated finding.
166175
- Start Time (start_time) [Optional]: Time of the earliest event included in the finding.
176+
- Start Time DT (start_time_dt) [Optional]: Time of the earliest event included in the finding in datetime
167177
168178
"""
169179

@@ -173,6 +183,8 @@ class Finding(BaseEvent, BaseModel):
173183
confidence: Optional[str]
174184
confidence_id: Optional[ConfidenceID]
175185
confidence_score: Optional[int]
176-
end_time: Optional[datetime]
186+
end_time: Optional[int]
187+
end_time_dt: Optional[datetime]
177188
finding_info: FindingInformation
178-
start_time: Optional[datetime]
189+
start_time: Optional[int]
190+
start_time_dt: Optional[datetime]

py_ocsf_models/objects/kb_article.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class KBArticle(BaseModel):
1515
1616
Attributes:
1717
- classification: Vendor's classification of the KB article.
18-
- created_time: Release date of the KB article.
18+
- created_time: Time the KB article was created.
19+
- created_time_dt: Time the KB article was created in datetime
1920
- os: Operating system the KB article applies to.
2021
- bulletin: Bulletin identifier of the KB article.
2122
- product: Product details the KB article applies to.
@@ -28,7 +29,8 @@ class KBArticle(BaseModel):
2829
"""
2930

3031
classification: Optional[str]
31-
created_time: Optional[datetime]
32+
created_time: Optional[int]
33+
created_time_dt: Optional[datetime]
3234
os: OperatingSystem
3335
bulletin: Optional[str]
3436
product: Optional[Product]

py_ocsf_models/objects/organization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class Organization(BaseModel):
1515
"""
1616

1717
name: Optional[str]
18-
ou_id: Optional[str]
18+
ou_uid: Optional[str]
1919
ou_name: Optional[str]
2020
uid: Optional[str]

py_ocsf_models/objects/vulnerability_details.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ class VulnerabilityDetails(BaseModel):
1919
- Description (desc) [Optional]: The description of the vulnerability.
2020
- Exploit Availability (is_exploit_available) [Optional]: Indicates if an exploit or a PoC (proof-of-concept) is available for the reported vulnerability.
2121
- First Seen (first_seen_time) [Optional]: The time when the vulnerability was first observed.
22+
- First Seen (first_seen_time_dt) [Optional]: The time when the vulnerability was first observed in datetime format.
2223
- Knowledgebase Articles (kb_article_list) [Optional]: A list of KB articles or patches related to an endpoint. A KB Article contains metadata that describes the patch or an update.
2324
- Last Seen (last_seen_time) [Optional]: The time when the vulnerability was most recently observed.
25+
- Last Seen (last_seen_time_dt) [Optional]: The time when the vulnerability was most recently observed in datetime format.
2426
- References (references) [Recommended]: A list of reference URLs with additional information about the vulnerability.
2527
- Related Vulnerabilities (related_vulnerabilities) [Optional]: List of vulnerabilities that are related to this vulnerability.
2628
- Remediation Guidance (remediation) [Optional]: The remediation recommendations on how to mitigate the identified vulnerability.
@@ -36,9 +38,11 @@ class VulnerabilityDetails(BaseModel):
3638
# cwe: Optional[CWE]
3739
desc: Optional[str]
3840
is_exploit_available: Optional[bool]
39-
first_seen_time: Optional[datetime]
41+
first_seen_time: Optional[int]
42+
first_seen_time_dt: Optional[datetime]
4043
kb_article_list: Optional[List[KBArticle]]
41-
last_seen_time: Optional[datetime]
44+
last_seen_time: Optional[int]
45+
last_seen_time_dt: Optional[datetime]
4246
references: Optional[List[str]]
4347
related_vulnerabilities: Optional[List[str]]
4448
remediation: Optional[Remediation]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ packages = [
2525
{include = "py_ocsf_models"}
2626
]
2727
readme = "README.md"
28-
version = "0.1.1"
28+
version = "0.2.0"
2929

3030
[tool.poetry.dependencies]
3131
cryptography = "43.0.1"

0 commit comments

Comments
 (0)