From 287a11a2ee53c25a9a73e84f4cde84ebaeb48725 Mon Sep 17 00:00:00 2001 From: Janik Besendorf Date: Tue, 3 Sep 2024 20:20:46 +0200 Subject: [PATCH] also search for STIX2 files in directories in MVT_STIX2 --- mvt/common/indicators.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mvt/common/indicators.py b/mvt/common/indicators.py index 19dc6a2..389e9f0 100644 --- a/mvt/common/indicators.py +++ b/mvt/common/indicators.py @@ -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