Skip to content

Commit c006777

Browse files
committed
Simplify PathAssignmentBarrier
1 parent 6d6852f commit c006777

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

go/ql/lib/semmle/go/security/OpenUrlRedirectCustomizations.qll

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,18 @@ module OpenUrlRedirect {
7575
}
7676
}
7777

78-
bindingset[var, w]
79-
pragma[inline_late]
80-
private predicate useIsDominated(SsaWithFields var, Write w, DataFlow::ReadNode sanitizedRead) {
81-
w.dominatesNode(sanitizedRead.asInstruction()) and
82-
sanitizedRead = var.getAUse()
83-
}
84-
8578
/**
86-
* An access to a variable that is preceded by an assignment to its `Path` field.
79+
* An assignment of a safe value to the field `Path`, considered as a barrier for sanitizing
80+
* untrusted URLs.
8781
*
8882
* This is overapproximate; this will currently remove flow through all `Url.Path` assignments
8983
* which contain a substring that could sanitize data.
9084
*/
91-
class PathAssignmentBarrier extends Barrier, Read {
85+
class PathAssignmentBarrier extends Barrier {
9286
PathAssignmentBarrier() {
93-
exists(Write w, SsaWithFields var |
94-
hasHostnameSanitizingSubstring(w.getRhs()) and
95-
w.writesFieldPreUpdate(var.getAUse(), any(Field f | f.getName() = "Path"), _) and
96-
useIsDominated(var, w, this)
87+
exists(Write w, DataFlow::Node rhs |
88+
hasHostnameSanitizingSubstring(rhs) and
89+
w.writesFieldPreUpdate(this, any(Field f | f.getName() = "Path"), rhs)
9790
)
9891
}
9992
}

0 commit comments

Comments
 (0)