Skip to content

Commit

Permalink
Include changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
porcupineyhairs committed Jul 8, 2024
1 parent 5b84c0c commit 883fd00
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions go/ql/src/experimental/CWE-639/urlCheck.ql
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import go

bindingset[s]
private predicate mayBeCors(string s) { s.toLowerCase().matches(["%origin%", "%cors%"]) }
private predicate mayBeCors(string s) {
s.toLowerCase().matches(["%origin%", "%cors%"]) and not s.toLowerCase().matches(["%original%"])

Check warning

Code scanning / CodeQL

Singleton set literal Warning

Singleton set literal can be replaced by its member.
}

/**
* An argument to a Gorilla's OriginValidator Function taken as a source
*/
class GorillaOriginFuncSource extends RemoteFlowSource::Range {
class GorillaOriginFuncSource extends DataFlow::Node {
GorillaOriginFuncSource() {
exists(FuncDef f, DataFlow::CallNode c |
// Find a func passed to `AllowedOriginValdiator` as a validator.
Expand All @@ -29,7 +31,7 @@ class GorillaOriginFuncSource extends RemoteFlowSource::Range {
c.getTarget().hasQualifiedName("github.com/gorilla/handlers", "AllowedOriginValidator") and
c.getArgument(0).asExpr() = f
|
DataFlow::localFlow(DataFlow::parameterNode(f.getParameter(0)), this)
this = DataFlow::parameterNode(f.getParameter(0))
)
}
}
Expand Down

0 comments on commit 883fd00

Please sign in to comment.