attck/mitre_id.rs
1use stix::ExternalReference;
2
3/// Check if an external reference is to MITRE ATT&CK.
4pub fn is_mitre_reference(xr: &ExternalReference) -> bool {
5 xr.source_name == "mitre-attack"
6}
7
8/// Get the MITRE ATT&CK ID from an external reference, if the external reference
9/// is of the correct type.
10pub fn get_mitre_id(xr: &ExternalReference) -> Option<&str> {
11 if is_mitre_reference(xr) {
12 xr.external_id.as_ref().map(|s| s.as_str())
13 } else {
14 None
15 }
16}