Skip to content
Open
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 @@ -57,5 +57,18 @@ query predicate problems(
// the trailing port or slash makes the prefix-check safe
check instanceof StringOps::StartsWith and
target.regexpMatch(".*(:[0-9]+|/)")
or
// Checks on a parsed URL's host or hostname property are safe,
// since the host is already isolated from path/query components.
exists(DataFlow::PropRead hostRead |
hostRead.getPropertyName() in ["host", "hostname"] and
(
check.(StringOps::EndsWith).getBaseString().getALocalSource() = hostRead
or
check.(StringOps::Includes).getBaseString().getALocalSource() = hostRead
or
check.(StringOps::StartsWith).getBaseString().getALocalSource() = hostRead
)
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: majorAnalysis
---
* The `js/incomplete-url-substring-sanitization` query no longer flags substring checks performed on a parsed URL's `.host` or `.hostname` property (e.g., `new URL(x).host.endsWith("github.com")`), since the hostname is already isolated from path and query components, making such checks safe.
Loading