From a44688c501df524f28dc85c7342c6f060ced0b04 Mon Sep 17 00:00:00 2001 From: Janik Besendorf Date: Tue, 8 Oct 2024 15:49:03 +0200 Subject: [PATCH] change recursive search for indicator files from os.walk to glob.glob --- mvt/common/indicators.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mvt/common/indicators.py b/mvt/common/indicators.py index 389e9f0..0fdf2b2 100644 --- a/mvt/common/indicators.py +++ b/mvt/common/indicators.py @@ -3,6 +3,7 @@ # Use of this software is governed by the MVT License 1.1 that can be found at # https://license.mvt.re/1.1/ +import glob import json import logging import os @@ -50,13 +51,11 @@ class Indicators: 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)) + for file in glob.glob(os.path.join(path, "**", "*.stix2", recursive=True)): + self.parse_stix2(file) else: self.log.error( - "Path specified with env MVT_STIX2 is not a valid file: %s", path + "Path specified with env MVT_STIX2 is not a valid path: %s", path ) def _new_collection(