From c1c099d56b5ca3fc2ccc7b789dd87283220e8ab7 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:32:46 -0400 Subject: [PATCH] var name code smells --- mitreattack/stix20/MitreAttackData.py | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mitreattack/stix20/MitreAttackData.py b/mitreattack/stix20/MitreAttackData.py index 46a5bb19..5a1c7bce 100644 --- a/mitreattack/stix20/MitreAttackData.py +++ b/mitreattack/stix20/MitreAttackData.py @@ -358,8 +358,8 @@ def get_techniques_by_platform(self, platform: str, remove_revoked_deprecated=Fa list a list of AttackPattern objects under the given platform """ - filter = [Filter("type", "=", "attack-pattern"), Filter("x_mitre_platforms", "contains", platform)] - techniques = self.src.query(filter) + filters = [Filter("type", "=", "attack-pattern"), Filter("x_mitre_platforms", "contains", platform)] + techniques = self.src.query(filters) if remove_revoked_deprecated: techniques = self.remove_revoked_deprecated(techniques) return techniques @@ -524,9 +524,9 @@ def get_object_by_stix_id(self, stix_id: str) -> object: stix2.v20.sdo._DomainObject | CustomStixObject the STIX Domain Object specified by the STIX ID """ - object = self.src.get(stix_id) + sdo = self.src.get(stix_id) - if not object: + if not sdo: raise ValueError(f"{stix_id} not found in {self.stix_filepath}") return StixObjectFactory(object) @@ -557,17 +557,17 @@ def get_object_by_attack_id(self, attack_id: str, stix_type: str) -> object: if stix_type not in self.stix_types: raise ValueError(f"stix_type must be one of {self.stix_types}") - object = self.src.query( + sdo = self.src.query( [ Filter("external_references.external_id", "=", attack_id.upper()), Filter("type", "=", stix_type), ] ) - if not object: + if not sdo: return None - return StixObjectFactory(object[0]) + return StixObjectFactory(sdo[0]) def get_objects_by_name(self, name: str, stix_type: str) -> list: """Retrieve objects by name. @@ -592,8 +592,8 @@ def get_objects_by_name(self, name: str, stix_type: str) -> list: if stix_type not in self.stix_types: raise ValueError(f"stix_type must be one of {self.stix_types}") - filter = [Filter("type", "=", stix_type), Filter("name", "=", name)] - objects = self.src.query(filter) + filters = [Filter("type", "=", stix_type), Filter("name", "=", name)] + objects = self.src.query(filters) if not objects: return [] @@ -616,8 +616,8 @@ def get_groups_by_alias(self, alias: str) -> list: list a list of stix2.v20.sdo.IntrusionSet objects corresponding to the alias """ - filter = [Filter("type", "=", "intrusion-set"), Filter("aliases", "contains", alias)] - return self.src.query(filter) + filters = [Filter("type", "=", "intrusion-set"), Filter("aliases", "contains", alias)] + return self.src.query(filters) def get_campaigns_by_alias(self, alias: str) -> list: """Retrieve the campaigns corresponding to a given alias. @@ -634,8 +634,8 @@ def get_campaigns_by_alias(self, alias: str) -> list: list a list of stix2.v20.sdo.Campaign objects corresponding to the alias """ - filter = [Filter("type", "=", "campaign"), Filter("aliases", "contains", alias)] - return self.src.query(filter) + filters = [Filter("type", "=", "campaign"), Filter("aliases", "contains", alias)] + return self.src.query(filters) def get_software_by_alias(self, alias: str) -> list: """Retrieve the software corresponding to a given alias. @@ -661,7 +661,7 @@ def get_software_by_alias(self, alias: str) -> list: # Get Object Information ################################### - def get_attack_id(self, stix_id: str) -> str: + def get_attack_id(self, stix_id: str) -> str | None: """Get the object's ATT&CK ID. Parameters