Skip to content

Commit b12383e

Browse files
committed
commit simple changes so that
we can get this feature working now. Eventually the more robust changes will be merged from a separate branch
1 parent 5488ca6 commit b12383e

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

contentctl/actions/inspect.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,11 @@ def check_detection_metadata(self, config: inspect) -> None:
297297
validation_errors[rule_name] = []
298298
# No detections should be removed from build to build
299299
if rule_name not in current_build_conf.detection_stanzas:
300-
validation_errors[rule_name].append(DetectionMissingError(rule_name=rule_name))
300+
if config.suppress_missing_content_exceptions:
301+
print(f"[SUPPRESSED] {DetectionMissingError(rule_name=rule_name).long_message}")
302+
else:
303+
validation_errors[rule_name].append(DetectionMissingError(rule_name=rule_name))
301304
continue
302-
303305
# Pull out the individual stanza for readability
304306
previous_stanza = previous_build_conf.detection_stanzas[rule_name]
305307
current_stanza = current_build_conf.detection_stanzas[rule_name]
@@ -335,7 +337,7 @@ def check_detection_metadata(self, config: inspect) -> None:
335337
)
336338

337339
# Convert our dict mapping to a flat list of errors for use in reporting
338-
validation_error_list = [x for inner_list in validation_errors.values() for x in inner_list]
340+
validation_error_list = [x for inner_list in validation_errors.values() for x in inner_list]
339341

340342
# Report failure/success
341343
print("\nDetection Metadata Validation:")
@@ -355,4 +357,4 @@ def check_detection_metadata(self, config: inspect) -> None:
355357
raise ExceptionGroup(
356358
"Validation errors when comparing detection stanzas in current and previous build:",
357359
validation_error_list
358-
)
360+
)

contentctl/objects/config.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ def getApp(self, config:test, stage_file=True)->str:
159159
verbose_print=True)
160160
return str(destination)
161161

162-
163-
164162
# TODO (#266): disable the use_enum_values configuration
165163
class Config_Base(BaseModel):
166164
model_config = ConfigDict(use_enum_values=True,validate_default=True, arbitrary_types_allowed=True)
@@ -288,7 +286,6 @@ def getAPIPath(self)->pathlib.Path:
288286

289287
def getAppTemplatePath(self)->pathlib.Path:
290288
return self.path/"app_template"
291-
292289

293290

294291
class StackType(StrEnum):
@@ -311,6 +308,16 @@ class inspect(build):
311308
"should be enabled."
312309
)
313310
)
311+
suppress_missing_content_exceptions: bool = Field(
312+
default=False,
313+
description=(
314+
"Suppress exceptions during metadata validation if a detection that existed in "
315+
"the previous build does not exist in this build. This is to ensure that content "
316+
"is not accidentally removed. In order to support testing both public and private "
317+
"content, this warning can be suppressed. If it is suppressed, it will still be "
318+
"printed out as a warning."
319+
)
320+
)
314321
enrichments: bool = Field(
315322
default=True,
316323
description=(
@@ -952,7 +959,6 @@ def check_environment_variable_for_config(cls, v:List[Infrastructure]):
952959
index+=1
953960

954961

955-
956962
class release_notes(Config_Base):
957963
old_tag:Optional[str] = Field(None, description="Name of the tag to diff against to find new content. "
958964
"If it is not supplied, then it will be inferred as the "
@@ -1034,6 +1040,4 @@ def ensureNewTagOrLatestBranch(self):
10341040
# raise ValueError("The latest_branch '{self.latest_branch}' was not found in the repository")
10351041

10361042

1037-
# return self
1038-
1039-
1043+
# return self

0 commit comments

Comments
 (0)