Skip to content

Commit 84b2d39

Browse files
committed
Write a clickable source link in untrusted checkout message
1 parent cdc1375 commit 84b2d39

4 files changed

Lines changed: 57 additions & 49 deletions

File tree

actions/ql/lib/codeql/actions/security/UntrustedCheckoutQuery.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ AstNode getCheckoutReference(PRHeadCheckoutStep checkout) {
425425

426426
/** Gets a display label for the expression that controls the untrusted checkout. */
427427
string getCheckoutReferenceText(AstNode reference) {
428-
result = reference.(Expression).getExpression()
428+
result = reference.(Expression).toString()
429429
or
430430
not reference instanceof Expression and result = "the checkout command"
431431
}

actions/ql/src/Security/CWE-829/UntrustedCheckoutCritical.ql

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ query predicate edges(AstNode predecessor, AstNode successor) {
2828
checkoutReferenceEdge(predecessor, successor)
2929
}
3030

31-
from PRHeadCheckoutStep checkout, PoisonableStep poisonable, Event event
31+
from
32+
PRHeadCheckoutStep checkout, PoisonableStep poisonable, Event event, AstNode checkoutReference,
33+
string checkoutReferenceText
3234
where
35+
checkoutReference = getCheckoutReference(checkout) and
36+
checkoutReferenceText = getCheckoutReferenceText(checkoutReference) and
3337
// the checkout is followed by a known poisonable step
3438
checkout.getAFollowingStep() = poisonable and
3539
(
@@ -59,6 +63,6 @@ where
5963
event.getName() = checkoutTriggers() and
6064
not exists(ControlCheck check | check.protects(checkout, event, "untrusted-checkout")) and
6165
not exists(ControlCheck check | check.protects(poisonable, event, "untrusted-checkout"))
62-
select checkout, getCheckoutReference(checkout), poisonable,
63-
"Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: $@).",
64-
event, event.getName()
66+
select checkout, checkoutReference, poisonable,
67+
"Checkout of untrusted code from $@ in a privileged workflow with later potential execution (event trigger: $@).",
68+
checkoutReference, checkoutReferenceText, event, event.getName()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: fix
3+
---
4+
* The `actions/cache-poisoning/poisonable-step` and `actions/untrusted-checkout/critical` queries now start paths at the expressions that control untrusted checkouts and link their alert messages to those expressions.

0 commit comments

Comments
 (0)