mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
feat(sources): Do not take triggers into consideration
This commit is contained in:
@@ -16,14 +16,16 @@ import actions
|
||||
import codeql.actions.security.CommandInjectionQuery
|
||||
import CommandInjectionFlow::PathGraph
|
||||
|
||||
predicate isSingleTriggerWorkflow(Workflow w, string trigger) {
|
||||
w.getATriggerEvent() = trigger and
|
||||
count(string t | w.getATriggerEvent() = t | t) = 1
|
||||
}
|
||||
|
||||
from CommandInjectionFlow::PathNode source, CommandInjectionFlow::PathNode sink, Workflow w
|
||||
where
|
||||
CommandInjectionFlow::flowPath(source, sink) and
|
||||
w = source.getNode().asExpr().getEnclosingWorkflow() and
|
||||
(
|
||||
w instanceof ReusableWorkflow or
|
||||
w.hasTriggerEvent(source.getNode().(RemoteFlowSource).getATriggerEvent())
|
||||
)
|
||||
not isSingleTriggerWorkflow(w, "pull_request")
|
||||
select sink.getNode(), source, sink,
|
||||
"Potential privileged command injection in $@, which may be controlled by an external user.",
|
||||
sink, sink.getNode().asExpr().(Expression).getRawExpression()
|
||||
|
||||
@@ -18,14 +18,16 @@ import actions
|
||||
import codeql.actions.security.CodeInjectionQuery
|
||||
import CodeInjectionFlow::PathGraph
|
||||
|
||||
predicate isSingleTriggerWorkflow(Workflow w, string trigger) {
|
||||
w.getATriggerEvent() = trigger and
|
||||
count(string t | w.getATriggerEvent() = t | t) = 1
|
||||
}
|
||||
|
||||
from CodeInjectionFlow::PathNode source, CodeInjectionFlow::PathNode sink, Workflow w
|
||||
where
|
||||
CodeInjectionFlow::flowPath(source, sink) and
|
||||
w = source.getNode().asExpr().getEnclosingWorkflow() and
|
||||
(
|
||||
w instanceof ReusableWorkflow or
|
||||
w.hasTriggerEvent(source.getNode().(RemoteFlowSource).getATriggerEvent())
|
||||
)
|
||||
not isSingleTriggerWorkflow(w, "pull_request")
|
||||
select sink.getNode(), source, sink,
|
||||
"Potential privileged code injection in $@, which may be controlled by an external user.", sink,
|
||||
sink.getNode().asExpr().(Expression).getRawExpression()
|
||||
|
||||
Reference in New Issue
Block a user