Skip to content
Open
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 @@ -315,9 +315,10 @@ fn looks_like_url(token: &str) -> bool {
Lazy::new(|| Regex::new(r#"^[ "'\(\s]*([^\s"'\);]+)[\s;\)]*$"#).ok());
// If the token embeds a URL alongside other text (e.g., Start-Process('https://...'))
// as a single shlex token, grab the substring starting at the first URL prefix.
let urlish = token
let lowercase_token = token.to_ascii_lowercase();
let urlish = lowercase_token
.find("https://")
.or_else(|| token.find("http://"))
.or_else(|| lowercase_token.find("http://"))
.map(|idx| &token[idx..])
.unwrap_or(token);

Expand Down Expand Up @@ -434,6 +435,19 @@ mod tests {
])));
}

#[test]
fn powershell_start_process_mixed_case_urls_are_dangerous() {
for script in [
"Start-Process('HTTP://example.com');",
"Start-Process('hTtPs://example.com');",
] {
assert!(
is_dangerous_command_windows(&vec_str(&["powershell", "-Command", script])),
"{script}"
);
}
}

#[test]
fn powershell_start_process_local_is_not_flagged() {
assert!(!is_dangerous_command_windows(&vec_str(&[
Expand Down
Loading