Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dcb6bc5

Browse files
committedJan 29, 2025
Update create_json_files.py
1 parent c67a032 commit dcb6bc5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎_utils/create_json_files.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ def sanitize_filename(name):
1313
reader = csv.DictReader(f)
1414
# Iterate over the rows
1515
for row in reader:
16+
keyword = row['keyword'].strip()
17+
if not keyword: # Skip empty keyword rows
18+
continue
19+
1620
tool_name = sanitize_filename(row['metadata_tool'])
17-
keyword = row['keyword']
1821

1922
# Create a dictionary for this tool if it doesn't exist
2023
if tool_name not in tools:
@@ -51,12 +54,14 @@ def sanitize_filename(name):
5154
tool_directory = 'greyware_tools'
5255
elif tool_data["type"] == "signature_keyword":
5356
tool_directory = 'signatures'
57+
else:
58+
continue # Skip if type is unrecognized
5459

5560
os.makedirs(os.path.join('..', 'sigma_rules', tool_directory, tool_name), exist_ok=True)
5661

5762
# Remove duplicates
5863
deduped_tool_data = [dict(t) for t in set(tuple(d.items()) for d in tool_data["data"])]
59-
64+
6065
# Write out the data to a JSON file inside the tool's directory in sigma_rules
6166
with open(os.path.join('..', 'sigma_rules', tool_directory, tool_name, f'{tool_name}.json'), 'w') as f:
62-
json.dump(deduped_tool_data, f, indent=4)
67+
json.dump(deduped_tool_data, f, indent=4)

0 commit comments

Comments
 (0)
Please sign in to comment.