Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ManifestWatcher: @unchecked Sendable {
private var debounceWork: DispatchWorkItem?
private static let debounceInterval: TimeInterval = 0.05

var isWatching: Bool { source != nil }
var isWatching: Bool { queue.sync { source != nil } }

init(path: String, onChange: @escaping @MainActor @Sendable () -> Void) {
self.path = path
Expand Down
4 changes: 2 additions & 2 deletions crates/pu-cli/src/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub async fn run_bench(
}
}

output::print_response(&resp, json);
output::print_response(&resp, json)?;
Ok(())
}

Expand All @@ -75,6 +75,6 @@ pub async fn run_play(socket: &Path, agent_id: &str, json: bool) -> Result<(), C
)
.await?;
let resp = output::check_response(resp, json)?;
output::print_response(&resp, json);
output::print_response(&resp, json)?;
Ok(())
}
2 changes: 1 addition & 1 deletion crates/pu-cli/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ mod tests {
#[test]
fn given_empty_suspend_result_should_not_panic() {
let resp = Response::SuspendResult { suspended: vec![] };
print_response(&resp, false);
print_response(&resp, false).unwrap();
}

#[test]
Expand Down
9 changes: 8 additions & 1 deletion crates/pu-core/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn validate_name(name: &str) -> Result<(), std::io::Error> {
format!("name must not start with '.': {name}"),
));
}
if name.contains('/') || name.contains('\\') || name.contains("..") {
if trimmed.contains('/') || trimmed.contains('\\') || trimmed.contains("..") {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("name contains invalid characters: {name}"),
Expand Down Expand Up @@ -54,6 +54,13 @@ mod tests {
assert!(validate_name("..").is_err());
}

#[test]
fn given_whitespace_padded_traversal_should_reject() {
assert!(validate_name(" ../evil").is_err());
assert!(validate_name("foo/../bar ").is_err());
assert!(validate_name(" /root").is_err());
}

#[test]
fn given_empty_should_reject() {
assert!(validate_name("").is_err());
Expand Down
Loading