Skip to content

Commit 558a0e0

Browse files
committed
Address QL-for-QL review findings
Rename model-binding predicates that do not return values and replace omittable exists variables with don't-care expressions.
1 parent ae4ce2e commit 558a0e0

1 file changed

Lines changed: 18 additions & 59 deletions

File tree

  • actions/ql/lib/codeql/actions/ast/internal

actions/ql/lib/codeql/actions/ast/internal/Ast.qll

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class CompositeActionImpl extends AstNodeImpl, TCompositeAction {
423423
)
424424
}
425425

426-
predicate getAnExternalCompositeActionModel(
426+
predicate hasExternalCompositeActionModel(
427427
string owner, string repo, string action_path, string requested_ref, string resolved_commit_sha,
428428
string local_path
429429
) {
@@ -433,24 +433,14 @@ class CompositeActionImpl extends AstNodeImpl, TCompositeAction {
433433
}
434434

435435
predicate isExternalCompositeAction() {
436-
exists(
437-
string owner, string repo, string action_path, string requested_ref,
438-
string resolved_commit_sha, string local_path
439-
|
440-
this.getAnExternalCompositeActionModel(owner, repo, action_path, requested_ref,
441-
resolved_commit_sha, local_path)
442-
)
436+
this.hasExternalCompositeActionModel(_, _, _, _, _, _)
443437
or
444438
this.getLocation().getFile().getRelativePath().matches("9466014afba34ef28239871ceabf4132/%")
445439
}
446440

447441
string getResolvedPath() {
448-
exists(
449-
string owner, string repo, string action_path, string requested_ref,
450-
string resolved_commit_sha, string local_path
451-
|
452-
this.getAnExternalCompositeActionModel(owner, repo, action_path, requested_ref,
453-
resolved_commit_sha, local_path) and
442+
exists(string owner, string repo, string action_path, string requested_ref |
443+
this.hasExternalCompositeActionModel(owner, repo, action_path, requested_ref, _, _) and
454444
result = externalCompositeActionName(owner, repo, action_path) + "@" + requested_ref.trim()
455445
)
456446
or
@@ -580,7 +570,7 @@ class ReusableWorkflowImpl extends AstNodeImpl, WorkflowImpl {
580570
)
581571
}
582572

583-
predicate getAnExternalReusableWorkflowModel(
573+
predicate hasExternalReusableWorkflowModel(
584574
string owner, string repo, string workflow_path, string requested_ref,
585575
string resolved_commit_sha, string local_path
586576
) {
@@ -590,24 +580,14 @@ class ReusableWorkflowImpl extends AstNodeImpl, WorkflowImpl {
590580
}
591581

592582
predicate isExternalReusableWorkflow() {
593-
exists(
594-
string owner, string repo, string workflow_path, string requested_ref,
595-
string resolved_commit_sha, string local_path
596-
|
597-
this.getAnExternalReusableWorkflowModel(owner, repo, workflow_path, requested_ref,
598-
resolved_commit_sha, local_path)
599-
)
583+
this.hasExternalReusableWorkflowModel(_, _, _, _, _, _)
600584
or
601585
this.getLocation().getFile().getRelativePath().matches("9466014afba34ef28239871ceabf4132/%") // root folder for external workflows and composite actions
602586
}
603587

604588
string getResolvedPath() {
605-
exists(
606-
string owner, string repo, string workflow_path, string requested_ref,
607-
string resolved_commit_sha, string local_path
608-
|
609-
this.getAnExternalReusableWorkflowModel(owner, repo, workflow_path, requested_ref,
610-
resolved_commit_sha, local_path) and
589+
exists(string owner, string repo, string workflow_path, string requested_ref |
590+
this.hasExternalReusableWorkflowModel(owner, repo, workflow_path, requested_ref, _, _) and
611591
result =
612592
owner.trim() + "/" + repo.trim() + "/" + workflow_path.trim() + "@" + requested_ref.trim()
613593
)
@@ -1448,12 +1428,8 @@ class UsesStepImpl extends StepImpl, UsesImpl {
14481428
private predicate isLocalCall() { this.isWorkspaceLocalCall() or this.isSelfCall() }
14491429

14501430
private predicate hasModeledExternalCallee() {
1451-
exists(
1452-
string owner, string repo, string action_path, string requested_ref,
1453-
string resolved_commit_sha, string local_path
1454-
|
1455-
externalCompositeActionDataModel(owner, repo, action_path, requested_ref, resolved_commit_sha,
1456-
local_path) and
1431+
exists(string owner, string repo, string action_path, string requested_ref |
1432+
externalCompositeActionDataModel(owner, repo, action_path, requested_ref, _, _) and
14571433
this.getCallee() = externalCompositeActionName(owner, repo, action_path) and
14581434
this.getVersion() = requested_ref.trim()
14591435
)
@@ -1466,26 +1442,16 @@ class UsesStepImpl extends StepImpl, UsesImpl {
14661442
}
14671443

14681444
private predicate hasModeledExternalEnclosingCompositeAction() {
1469-
exists(
1470-
CompositeActionImpl action, string owner, string repo, string action_path,
1471-
string requested_ref, string resolved_commit_sha, string local_path
1472-
|
1445+
exists(CompositeActionImpl action |
14731446
action = this.getEnclosingCompositeAction() and
1474-
action
1475-
.getAnExternalCompositeActionModel(owner, repo, action_path, requested_ref,
1476-
resolved_commit_sha, local_path)
1447+
action.hasExternalCompositeActionModel(_, _, _, _, _, _)
14771448
)
14781449
}
14791450

14801451
private string getSelfCallableName() {
1481-
exists(
1482-
CompositeActionImpl action, string owner, string repo, string action_path,
1483-
string requested_ref, string resolved_commit_sha, string local_path
1484-
|
1452+
exists(CompositeActionImpl action, string owner, string repo, string requested_ref |
14851453
action = this.getEnclosingCompositeAction() and
1486-
action
1487-
.getAnExternalCompositeActionModel(owner, repo, action_path, requested_ref,
1488-
resolved_commit_sha, local_path) and
1454+
action.hasExternalCompositeActionModel(owner, repo, _, requested_ref, _, _) and
14891455
result =
14901456
externalCompositeActionName(owner, repo, this.getCallee().suffix(2)) + "@" +
14911457
requested_ref.trim()
@@ -1556,12 +1522,8 @@ class ExternalJobImpl extends JobImpl, UsesImpl {
15561522
}
15571523

15581524
private predicate hasModeledExternalCallee() {
1559-
exists(
1560-
string owner, string repo, string workflow_path, string requested_ref,
1561-
string resolved_commit_sha, string local_path
1562-
|
1563-
externalReusableWorkflowDataModel(owner, repo, workflow_path, requested_ref,
1564-
resolved_commit_sha, local_path) and
1525+
exists(string owner, string repo, string workflow_path, string requested_ref |
1526+
externalReusableWorkflowDataModel(owner, repo, workflow_path, requested_ref, _, _) and
15651527
this.getCallee() = owner.trim() + "/" + repo.trim() + "/" + workflow_path.trim() and
15661528
this.getVersion() = requested_ref.trim()
15671529
)
@@ -1570,13 +1532,10 @@ class ExternalJobImpl extends JobImpl, UsesImpl {
15701532
override string getCallableName() {
15711533
this.isLocalCall() and
15721534
exists(
1573-
ReusableWorkflowImpl enclosing_workflow, string owner, string repo, string workflow_path,
1574-
string requested_ref, string resolved_commit_sha, string local_path
1535+
ReusableWorkflowImpl enclosing_workflow, string owner, string repo, string requested_ref
15751536
|
15761537
enclosing_workflow = this.getEnclosingWorkflow() and
1577-
enclosing_workflow
1578-
.getAnExternalReusableWorkflowModel(owner, repo, workflow_path, requested_ref,
1579-
resolved_commit_sha, local_path) and
1538+
enclosing_workflow.hasExternalReusableWorkflowModel(owner, repo, _, requested_ref, _, _) and
15801539
result =
15811540
owner.trim() + "/" + repo.trim() + "/" + this.getCallee() + "@" + requested_ref.trim()
15821541
)

0 commit comments

Comments
 (0)