Skip to content

Commit

Permalink
Merge branch 'main' into migrate_ba_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
patel-bhavin authored Oct 23, 2023
2 parents c04f3cb + 15d950f commit 12406a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions contentctl/input/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ def execute(self, input_dto: DirectorInputDto) -> None:


def createSecurityContent(self, type: SecurityContentType) -> None:
objects = []
if type == SecurityContentType.ssa_detections:
files = Utils.get_all_yml_files_from_directory(os.path.join(self.input_dto.input_path, 'ssa_detections'))
files = Utils.get_all_yml_files_from_directory(os.path.join(self.input_dto.input_path, 'ssa_detections'))
elif type == SecurityContentType.unit_tests:
files = Utils.get_all_yml_files_from_directory(os.path.join(self.input_dto.input_path, 'tests'))
else:
Expand Down
9 changes: 6 additions & 3 deletions contentctl/output/conf_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,20 @@ def writeObjects(self, objects: list, type: SecurityContentType = None) -> None:
'transforms.j2',
self.config, objects)

#import code
#code.interact(local=locals())

if self.input_path is None:
raise(Exception(f"input_path is required for lookups, but received [{self.input_path}]"))

files = glob.iglob(os.path.join(self.input_path, 'lookups', '*.csv'))
#we want to copy all *.mlmodel files as well, not just csvs
files = list(glob.iglob(os.path.join(self.input_path, 'lookups', '*.csv'))) + list(glob.iglob(os.path.join(self.input_path, 'lookups', '*.mlmodel')))
lookup_folder = self.output_path/"lookups"
if lookup_folder.exists():
# Remove it since we want to remove any previous lookups that are not
# currently part of the app
if lookup_folder.is_dir():
shutil.rmtree(lookup_folder)
else:
#it's a file, but there should not be a file called lookups
lookup_folder.unlink()

# Make the new folder for the lookups
Expand All @@ -136,6 +137,8 @@ def writeObjects(self, objects: list, type: SecurityContentType = None) -> None:
if lookup_path.is_file():
lookup_target_path = self.output_path/"lookups"/lookup_path.name
shutil.copy(lookup_path, lookup_target_path)
else:
raise(Exception(f"Error copying lookup/mlmodel file. Path {lookup_path} does not exist or is not a file."))

elif type == SecurityContentType.macros:
ConfWriter.writeConfFile(self.output_path/'default/macros.conf',
Expand Down

0 comments on commit 12406a3

Please sign in to comment.