Compare commits

...
2 changed files with 9 additions and 1 deletions

No files matched your search

+7 -1
View File
@@ -25,6 +25,10 @@ pub struct BlockedPackage {
pub version: Option<String>,
pub filter: &'static str,
pub reason: String,
/// Flagged as malware, not just held back for being new.
pub malicious: bool,
/// Malware is never allowed, and a new package only by version. Saves each app the rule.
pub trustable: bool,
}
struct Blocks {
@@ -96,9 +100,11 @@ fn record(
version: pkg.version.clone(),
filter,
reason: reason.to_owned(),
malicious: filter != "age",
trustable: filter == "age" && pkg.version.is_some(),
};
push(&mut blocks.unsent, block.clone());
if filter != "age" {
if block.malicious {
return None;
}
let (wake, allowed) = watch::channel(false);
+2
View File
@@ -16,6 +16,8 @@ async fn allowing_once_releases_the_held_download() {
let id = loop {
let blocks: serde_json::Value = serde_json::from_str(&answer(&firewall, config, "blocks")).unwrap();
if let Some(id) = blocks[0]["id"].as_u64() {
assert_eq!(blocks[0]["malicious"], false);
assert_eq!(blocks[0]["trustable"], true);
break id;
}
tokio::time::sleep(Duration::from_millis(10)).await;