Support for local STIX objects#11
Conversation
…order to support the use of local STIX objects.
Cyb3rWard0g
left a comment
There was a problem hiding this comment.
Hey @rubinatorz ! Thank you again for this awesome addition to the library. I agree with this 💯 ! It will help during migration to sub-techniques 😉
| 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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
mmmm. the current code does not have the self. in the references to the class objects and the objects work fine right?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Awesome! Thank you man for the additional information 👍
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.