INNER CODE UNIT · Python
filter_for_term_relationships
mitre-attack/attack-scripts · scripts/technique_mappings_to_csv.py:39
def filter_for_term_relationships(src, relationship_type, object_id, target=True):
"""Filters data source by type, relationship_type and source or target"""
filters = [
Filter("type", "=", "relationship"),
Filter("relationship_type", "=", relationship_type),
]
if target:
filters.append(Filter("target_ref", "=", object_id))
else:
filters.append(Filter("source_ref", "=", object_id))
results = src.query(filters)
return remove_deprecated(results)
def filter_by_type_and_id(src, object_type, object_id, source_name):
"""Filters data source by id and type"""
filters = [