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

Skip to content

Support for local STIX objects#11

Merged
Cyb3rWard0g merged 2 commits into
OTRF:masterfrom
rubinatorz:ruben
Dec 23, 2019
Merged

Support for local STIX objects#11
Cyb3rWard0g merged 2 commits into
OTRF:masterfrom
rubinatorz:ruben

Conversation

@rubinatorz

Copy link
Copy Markdown
Contributor

Added constructor and local_path parameter to attack_client class in order to support the use of local STIX objects. Implemented some checks to verify if the given local path exists and is indeed a local STIX directory with ATT&CK objects (see https://github.com/mitre/cti). If the checks fail, it falls back to the content of the online TAXII server.

…order to support the use of local STIX objects.

@Cyb3rWard0g Cyb3rWard0g left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hey @rubinatorz ! Thank you again for this awesome addition to the library. I agree with this 💯 ! It will help during migration to sub-techniques 😉

Comment thread attackcti/attack_api.py Outdated
Comment thread attackcti/attack_api.py
if local_path is not None and os.path.isdir(os.path.join(local_path, ENTERPRISE_ATTCK_LOCAL_DIR)) \
and os.path.isdir(os.path.join(local_path, PRE_ATTCK_LOCAL_DIR)) \
and os.path.isdir(os.path.join(local_path, MOBILE_ATTCK_LOCAL_DIR)):
self.TC_ENTERPRISE_SOURCE = FileSystemSource(os.path.join(local_path, ENTERPRISE_ATTCK_LOCAL_DIR))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we need the additional self. on this line and LINE (39,40,49,50,51,53,54) Because it does not call methods or attributes of those libraries. All the script is doing in those steps is setting variables and initializing Collection objects and Composite Data Source objects.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can't leave the self. because that's the reference to the class (object) variables. Because I added the constructor, I need to reference to the variables with self. just like you do in the rest of your code. When I remove the self., the variables become local variables of the constructor and the class variables remain None. Or do I misunderstand you?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

mmmm. the current code does not have the self. in the references to the class objects and the objects work fine right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's true, in the current code you are using the variables on class level right away without a constructor. In that case you declare and initialise the variables at class level and there you don't need the self.. In the current code you already reference to the variables with self. within a function to reference to the class level variables. I added a constructor the the class to make it possible to instantiate an object from the attack_client class using the local_path parameter. And because the constructor is a function, you need to use self. to reference to the class level variables.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome! Thank you man for the additional information 👍

@Cyb3rWard0g Cyb3rWard0g merged commit 9463d2f into OTRF:master Dec 23, 2019
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.

2 participants