Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@besendorf
Copy link
Collaborator

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.

Copy link
Contributor

@roaree roaree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! thanks

Comment on lines 52 to 55
if os.path.isdir(path):
for root, dirs, files in os.walk(path):
for filename in files:
if filename.lower().endswith(".stix2"):
Copy link
Contributor

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

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.

Copy link
Collaborator Author

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

DonnchaC added a commit that referenced this pull request Oct 16, 2024
* 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]>
@DonnchaC DonnchaC merged commit a44688c into mvt-project:main Oct 16, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants