Skip to content

Commit

Permalink
commit simple changes so that
Browse files Browse the repository at this point in the history
we can get this feature working
now.  Eventually the more
robust changes will be merged
from a separate branch
  • Loading branch information
pyth0n1c committed Oct 9, 2024
1 parent 5488ca6 commit b12383e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
10 changes: 6 additions & 4 deletions contentctl/actions/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,11 @@ def check_detection_metadata(self, config: inspect) -> None:
validation_errors[rule_name] = []
# No detections should be removed from build to build
if rule_name not in current_build_conf.detection_stanzas:
validation_errors[rule_name].append(DetectionMissingError(rule_name=rule_name))
if config.suppress_missing_content_exceptions:
print(f"[SUPPRESSED] {DetectionMissingError(rule_name=rule_name).long_message}")
else:
validation_errors[rule_name].append(DetectionMissingError(rule_name=rule_name))
continue

# Pull out the individual stanza for readability
previous_stanza = previous_build_conf.detection_stanzas[rule_name]
current_stanza = current_build_conf.detection_stanzas[rule_name]
Expand Down Expand Up @@ -335,7 +337,7 @@ def check_detection_metadata(self, config: inspect) -> None:
)

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

# Report failure/success
print("\nDetection Metadata Validation:")
Expand All @@ -355,4 +357,4 @@ def check_detection_metadata(self, config: inspect) -> None:
raise ExceptionGroup(
"Validation errors when comparing detection stanzas in current and previous build:",
validation_error_list
)
)
18 changes: 11 additions & 7 deletions contentctl/objects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ def getApp(self, config:test, stage_file=True)->str:
verbose_print=True)
return str(destination)



# TODO (#266): disable the use_enum_values configuration
class Config_Base(BaseModel):
model_config = ConfigDict(use_enum_values=True,validate_default=True, arbitrary_types_allowed=True)
Expand Down Expand Up @@ -288,7 +286,6 @@ def getAPIPath(self)->pathlib.Path:

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



class StackType(StrEnum):
Expand All @@ -311,6 +308,16 @@ class inspect(build):
"should be enabled."
)
)
suppress_missing_content_exceptions: bool = Field(
default=False,
description=(
"Suppress exceptions during metadata validation if a detection that existed in "
"the previous build does not exist in this build. This is to ensure that content "
"is not accidentally removed. In order to support testing both public and private "
"content, this warning can be suppressed. If it is suppressed, it will still be "
"printed out as a warning."
)
)
enrichments: bool = Field(
default=True,
description=(
Expand Down Expand Up @@ -952,7 +959,6 @@ def check_environment_variable_for_config(cls, v:List[Infrastructure]):
index+=1



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


# return self


# return self

0 comments on commit b12383e

Please sign in to comment.