Feature/#304 duplicate attack ids#306
Merged
Merged
Conversation
isaisabel
suggested changes
Jun 1, 2021
isaisabel
left a comment
Contributor
There was a problem hiding this comment.
Proposed a performance improvement, but I like the overall approach taken currently. Should hopefully not be to hard to adapt to the proposed improvement.
Closed
isaisabel
approved these changes
Jun 2, 2021
Comment on lines
+224
to
+249
| def get_domain_resources(types): | ||
| # Returns sorted list by name of domain resources by given type list | ||
| # Builds list from unique ATT&CK IDs | ||
|
|
||
| def grab_filtered_list_by_type(domain, stix_type): | ||
| return ms[domain['name']].query([ | ||
| stix2.Filter('type', '=', stix_type), | ||
| stix2.Filter('revoked', '=', False) | ||
| ]) | ||
|
|
||
| # Track objects by STIX ID | ||
| stix_objs = {} | ||
| # Track objects by ATT&CK ID | ||
| attack_id_objs = {} | ||
| for domain in site_config.domains: | ||
| if domain['deprecated']: continue | ||
|
|
||
| for stix_type in types: | ||
| curr_list = grab_filtered_list_by_type(domain, stix_type) | ||
|
|
||
| for val in curr_list: | ||
| add_replace_or_ignore(stix_objs, attack_id_objs, val) | ||
|
|
||
| # Convert into list of values | ||
| resource_list = [attack_id_objs[key] for key in attack_id_objs] | ||
| return sorted(resource_list, key=lambda k: k['name'].lower()) |
Contributor
There was a problem hiding this comment.
This helper function is an excellent addition!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of what has changed
Added support for more than one object with the same STIX or ATT&CK ID on STIX bundles. Website will display the most recently modified object depending on the deprecation status.
Issues addressed by pull request
Closes #304.