(&mut self)
| 226 | } |
| 227 | |
| 228 | fn encode_credentials(&mut self) { |
| 229 | let hosts: HashSet<String> = self.endpoints.iter().map(|e| e.host.clone()).collect(); |
| 230 | |
| 231 | for host in &hosts { |
| 232 | let creds = self.credentials.credentials_for_host(host); |
| 233 | let api = self.credentials.api_for_host(host); |
| 234 | |
| 235 | let mut has_write = false; |
| 236 | let mut has_destructive = false; |
| 237 | |
| 238 | for cred in &creds { |
| 239 | if let Some(api) = api { |
| 240 | if !api.write_actions_for_scopes(&cred.scopes).is_empty() { |
| 241 | has_write = true; |
| 242 | } |
| 243 | if !api.destructive_actions_for_scopes(&cred.scopes).is_empty() { |
| 244 | has_destructive = true; |
| 245 | } |
| 246 | } else if !cred.scopes.is_empty() { |
| 247 | has_write = true; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | let cw_var = Bool::new_const(format!("credential_has_write_{host}")); |
| 252 | if has_write { |
| 253 | self.solver.assert(&cw_var); |
| 254 | } else { |
| 255 | self.solver.assert(&!cw_var.clone()); |
| 256 | } |
| 257 | self.credential_has_write.insert(host.clone(), cw_var); |
| 258 | |
| 259 | let destructive_var = Bool::new_const(format!("credential_has_destructive_{host}")); |
| 260 | if has_destructive { |
| 261 | self.solver.assert(&destructive_var); |
| 262 | } else { |
| 263 | self.solver.assert(&!destructive_var.clone()); |
| 264 | } |
| 265 | self.credential_has_destructive |
| 266 | .insert(host.clone(), destructive_var); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | fn encode_filesystem(&mut self) { |
| 271 | for path in self.policy.filesystem_policy.readable_paths() { |
no test coverage detected