Skip to content

Commit

Permalink
var name code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
clemiller committed Oct 6, 2023
1 parent 7cd52f3 commit c1c099d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions mitreattack/stix20/MitreAttackData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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 []
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit c1c099d

Please sign in to comment.