Skip to content

Commit deefd57

Browse files
committed
more cleanup on lookup object.
remove confidence, impact, and risk_score from the tags field in prep for integration with the RBA changes PR
1 parent e7eb947 commit deefd57

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

contentctl/objects/detection_tags.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ class DetectionTags(BaseModel):
4141
analytic_story: list[Story] = Field(...)
4242
asset_type: AssetType = Field(...)
4343
group: list[str] = []
44-
confidence: NonNegativeInt = Field(...,le=100)
45-
impact: NonNegativeInt = Field(...,le=100)
46-
@computed_field
47-
@property
48-
def risk_score(self) -> int:
49-
return round((self.confidence * self.impact)/100)
5044

5145
@computed_field
5246
@property
@@ -80,9 +74,6 @@ def severity(self)->RiskSeverity:
8074

8175
# enrichment
8276
mitre_attack_enrichments: List[MitreAttackEnrichment] = Field([], validate_default=True)
83-
confidence_id: Optional[PositiveInt] = Field(None, ge=1, le=3)
84-
impact_id: Optional[PositiveInt] = Field(None, ge=1, le=5)
85-
evidence_str: Optional[str] = None
8677

8778
@computed_field
8879
@property

contentctl/objects/lookup.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ def app_filename(self)->FilePath:
131131
2. Only apply the datetime stamp if it is version > 1. This makes the code a small fraction
132132
more complicated, but preserves longstanding CSV that have not been modified in a long time
133133
'''
134-
return pathlib.Path(f"{self.filename.stem}_{self.date.year}{self.date.month:02}{self.date.day:02}.{self.lookup_type}") #type: ignore
134+
if self.version > 1:
135+
return pathlib.Path(f"{self.filename.stem}.{self.lookup_type}") #type: ignore
136+
else:
137+
return pathlib.Path(f"{self.filename.stem}_{self.date.year}{self.date.month:02}{self.date.day:02}.{self.lookup_type}") #type: ignore
135138

136139
class CSVLookup(FileBackedLookup):
137140
lookup_type:Literal[Lookup_Type.csv]
@@ -187,15 +190,14 @@ def ensure_correct_csv_structure(self)->Self:
187190

188191
class KVStoreLookup(Lookup):
189192
lookup_type: Literal[Lookup_Type.kvstore]
190-
collection: str = Field(description="Name of the KVStore Collection. Note that collection MUST equal the name. This is a duplicate field, so it will be removed eventually.")
191193
fields: list[str] = Field(description="The names of the fields/headings for the KVStore.", min_length=1)
192194

193-
194-
@model_validator(mode="after")
195-
def validate_collection(self)->Self:
196-
if self.collection != self.name:
197-
raise ValueError("Collection MUST be the same as Name of the lookup, but they do not match")
198-
return self
195+
@field_validator("fields", mode='after')
196+
@classmethod
197+
def ensure_key(cls, values: list[str]):
198+
if values[0] != "_key":
199+
raise ValueError(f"fields MUST begin with '_key', not '{values[0]}'")
200+
return values
199201

200202
@model_serializer
201203
def serialize_model(self):

0 commit comments

Comments
 (0)