Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Fix default windows interceptor list (#3549)
Browse files Browse the repository at this point in the history
* Fix allowlist extend

* Fix broken tests

* Rename function to convey behavior

* fmt

* docs
  • Loading branch information
tevoinea authored Oct 5, 2023
1 parent 78f9049 commit f9f26b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/agent/coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ impl AllowList {
self.allow.is_match(path) && !self.deny.is_match(path)
}

/// Build a new `Allowlist` that adds the allow and deny rules of `other` to `self`.
pub fn extend(&self, other: &Self) -> Self {
/// Modifies the AllowList by adding the allow and deny rules of `other` to `self`.
pub fn extend_in_place(&mut self, other: &Self) {
let allow = add_regexsets(&self.allow, &other.allow);
let deny = add_regexsets(&self.deny, &other.deny);

AllowList::new(allow, deny)
self.allow = allow;
self.deny = deny;
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/agent/coverage/src/allowlist/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn test_allow_glob_extension() -> Result<()> {
fn test_allowlist_extend() -> Result<()> {
let baseline_text = "! bad/*
other/*";
let baseline = AllowList::parse(baseline_text)?;
let mut baseline = AllowList::parse(baseline_text)?;

assert!(!baseline.is_allowed("bad/a"));
assert!(!baseline.is_allowed("bad/b"));
Expand All @@ -144,20 +144,20 @@ bad/*
assert!(!provided.is_allowed("other/a"));
assert!(!provided.is_allowed("other/b"));

let extended = baseline.extend(&provided);
baseline.extend_in_place(&provided);

// Deny rules from `baseline` should not be overridden by `provided`, but
// allow rules should be.
//
// A provided allowlist can deny patterns that are baseline-allowed, but
// cannot allow patterns that are baseline-denied.
assert!(!extended.is_allowed("bad/a"));
assert!(!extended.is_allowed("bad/b"));
assert!(extended.is_allowed("good/a"));
assert!(extended.is_allowed("good/b"));
assert!(extended.is_allowed("good/bad/c"));
assert!(!extended.is_allowed("other/a"));
assert!(!extended.is_allowed("other/b"));
assert!(!baseline.is_allowed("bad/a"));
assert!(!baseline.is_allowed("bad/b"));
assert!(baseline.is_allowed("good/a"));
assert!(baseline.is_allowed("good/b"));
assert!(baseline.is_allowed("good/bad/c"));
assert!(!baseline.is_allowed("other/a"));
assert!(!baseline.is_allowed("other/b"));

Ok(())
}
Expand Down
4 changes: 3 additions & 1 deletion src/agent/onefuzz-task/src/tasks/coverage/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ impl CoverageTask {
// process startup functions. Setting software breakpoints in these functions breaks
// interceptor init, and causes test case execution to diverge.
let interceptor_denylist = AllowList::parse(WINDOWS_INTERCEPTOR_DENYLIST)?;
allowlist.source_files.extend(&interceptor_denylist);
allowlist
.source_files
.extend_in_place(&interceptor_denylist);
}

Ok(allowlist)
Expand Down

0 comments on commit f9f26b9

Please sign in to comment.