Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy mlfiles along #67

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions contentctl/input/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,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