also search for STIX2 files in directories in MVT_STIX2

This commit is contained in:
Janik Besendorf
2024-09-03 20:20:46 +02:00
parent efe46d7b49
commit 287a11a2ee

View File

@@ -40,15 +40,20 @@ class Indicators:
def _check_stix2_env_variable(self) -> None:
"""
Checks if a variable MVT_STIX2 contains path to a STIX files.
Checks if a variable MVT_STIX2 contains path to a STIX file. Also recursively searches through dirs in MVT_STIX2
"""
if "MVT_STIX2" not in os.environ:
return
paths = os.environ["MVT_STIX2"].split(":")
for path in paths:
if os.path.isfile(path):
if os.path.isfile(path) and path.lower().endswith(".stix2"):
self.parse_stix2(path)
if os.path.isdir(path):
for root, dirs, files in os.walk(path):
for filename in files:
if filename.lower().endswith(".stix2"):
self.parse_stix2(os.path.join(root, filename))
else:
self.log.error(
"Path specified with env MVT_STIX2 is not a valid file: %s", path