Skip to content

Commit 60920c1

Browse files
committed
require that the URL refers to graphql in some way
1 parent 416c986 commit 60920c1

File tree

1 file changed

+18
-1
lines changed
  • javascript/ql/src/semmle/javascript/frameworks

1 file changed

+18
-1
lines changed

javascript/ql/src/semmle/javascript/frameworks/GraphQL.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ private module Octokit {
6262
private class RequestClientRequest extends ClientRequest::Range, API::CallNode {
6363
RequestClientRequest() { this = requestCallee().getACall() }
6464

65-
override DataFlow::Node getUrl() { none() }
65+
override DataFlow::Node getUrl() {
66+
result = this.getArgument(0) // contains both the method and the URL, but it's close enough
67+
}
6668

6769
override DataFlow::Node getHost() { none() }
6870

@@ -96,7 +98,22 @@ private module GraphQLLib {
9698
.getALocalSource()
9799
.getAPropertyWrite("query")
98100
.getRhs()
101+
|
102+
containsGraphQLIndicator(req.getUrl())
99103
)
100104
}
101105
}
106+
107+
/**
108+
* Holds if `node` is a node that likely contains an URL to a GraphQL endpoint.
109+
*/
110+
private predicate containsGraphQLIndicator(DataFlow::Node node) {
111+
node.getStringValue().regexpMatch("(?i).*graphql.*")
112+
or
113+
node.(DataFlow::PropRead).getPropertyName().regexpMatch("(?i).*graphql.*")
114+
or
115+
containsGraphQLIndicator(node.(StringOps::Concatenation).getAnOperand())
116+
or
117+
containsGraphQLIndicator(node.getAPredecessor())
118+
}
102119
}

0 commit comments

Comments
 (0)