Look up a binary, falling back to glob matching, then to a conservative unknown descriptor.
(&self, path: &str)
| 166 | /// Look up a binary, falling back to glob matching, then to a conservative |
| 167 | /// unknown descriptor. |
| 168 | pub fn get_or_unknown(&self, path: &str) -> BinaryCapability { |
| 169 | if let Some(cap) = self.binaries.get(path) { |
| 170 | return cap.clone(); |
| 171 | } |
| 172 | for (reg_path, cap) in &self.binaries { |
| 173 | if reg_path.contains('*') |
| 174 | && let Ok(pattern) = glob::Pattern::new(reg_path) |
| 175 | && pattern.matches(path) |
| 176 | { |
| 177 | return cap.clone(); |
| 178 | } |
| 179 | } |
| 180 | BinaryCapability { |
| 181 | path: path.to_owned(), |
| 182 | description: "Unknown binary — not in registry".to_owned(), |
| 183 | protocols: Vec::new(), |
| 184 | spawns: Vec::new(), |
| 185 | can_exfiltrate: true, |
| 186 | exfil_mechanism: String::new(), |
| 187 | can_construct_http: true, |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | // --------------------------------------------------------------------------- |
no test coverage detected