-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Also search for STIX2 files in directories in MVT_STIX2 #527
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! thanks
mvt/common/indicators.py
Outdated
| if os.path.isdir(path): | ||
| for root, dirs, files in os.walk(path): | ||
| for filename in files: | ||
| if filename.lower().endswith(".stix2"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocker: we might have some examples of using glob that could condense this into one for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to change that if you can show me an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think he means something like this using the glob library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think he means something like this using the glob library
Yes exactly. The glob makes it easier to rationalise about what the code is doing IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the code to use glob.glob instead.
note: this is case-sensitive now. Case insensitivity with glob was only added in python3.12
* also search for STIX2 files in directories in MVT_STIX2 * update datetime deprecations * add variable declaration in __init__ * add str to return typed in cmd_download_apks.py * change dictionary creations to dictionary literals * replace call to set() with set literal * fix incorrect docstrings * remove whitespace according to PEP8: E203 * remove whitespace according to PEP8: E203 * remove unreachable return statement * use Union[] instead of | operator for python 3.8/9 compatability * Fix ruff formating of files * Revert "also search for STIX2 files in directories in MVT_STIX2" This reverts commit 287a11a. We have this change as a seperate PR in #527. --------- Co-authored-by: Janik Besendorf <[email protected]> Co-authored-by: Donncha Ó Cearbhaill <[email protected]>
The old version of this method only accepted paths to files in MVT_STIX2. This new version checks whether a variable in MVT_STIX2 is a file or a dir and then recursively searches for .stix2 files in those dirs.
A change I made is that it only processes .stix2 files which I thought is a reasonably check.