Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marirs committed Feb 17, 2024
1 parent 8020372 commit c8955e1
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,27 @@ impl FileCapabilities {
}
}

if let Some(namespace) = rule.meta.get(&Yaml::String("namespace".to_string())) {
if let Yaml::String(s) = namespace {
self.capability_namespaces
.insert(rule.name.clone(), s.clone());
let first_non_zero_address = caps
.iter()
.find(|&&(addr, _)| addr != 0)
.map(|&(addr, _)| addr)
.unwrap_or(0);

let _ = self
.capabilities_associations
.entry(rule.name.clone())
.or_insert_with(|| CapabilityAssociation {
attack: local_attacks_set.clone(),
mbc: local_mbc_set.clone(),
namespace: s.clone(),
name: rule.name.clone(),
address: first_non_zero_address as usize,
});
}
if let Some(Yaml::String(s)) = rule.meta.get(&Yaml::String("namespace".to_string())) {
self.capability_namespaces
.insert(rule.name.clone(), s.clone());
let first_non_zero_address = caps
.iter()
.find(|&&(addr, _)| addr != 0)
.map(|&(addr, _)| addr)
.unwrap_or(0);

let _ = self
.capabilities_associations
.entry(rule.name.clone())
.or_insert_with(|| CapabilityAssociation {
attack: local_attacks_set.clone(),
mbc: local_mbc_set.clone(),
namespace: s.clone(),
name: rule.name.clone(),
address: first_non_zero_address as usize,
});
}

#[cfg(feature = "verbose")]
{
for &(addr, _) in caps {
Expand Down

0 comments on commit c8955e1

Please sign in to comment.