Skip to content

Commit 42b487b

Browse files
author
Alvaro Muñoz
committed
Match callers and callees when root is not the repo root
When running codeql test run, the root of the database is not the root of the original repo (the directory containing .github and .git) therefore calls to reusable workflows are not correctly matched.
1 parent f9d66d9 commit 42b487b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ql/lib/codeql/actions/dataflow/internal/DataFlowPrivate.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class DataFlowCall instanceof Cfg::Node {
8686
int totalorder() { none() }
8787

8888
/** Gets the location of this call. */
89-
Location getLocation() { result = this.getLocation() }
89+
Location getLocation() { result = this.(Cfg::Node).getLocation() }
9090
}
9191

9292
/**
@@ -97,7 +97,17 @@ class DataFlowCallable instanceof Cfg::CfgScope {
9797

9898
string getName() {
9999
if this instanceof ReusableWorkflow
100-
then result = this.(ReusableWorkflow).getLocation().getFile().getRelativePath()
100+
then
101+
result =
102+
this.(ReusableWorkflow)
103+
.getLocation()
104+
.getFile()
105+
.getRelativePath()
106+
.suffix(this.(ReusableWorkflow)
107+
.getLocation()
108+
.getFile()
109+
.getRelativePath()
110+
.indexOf("/.github/workflows") + 1)
101111
else
102112
if this instanceof CompositeAction
103113
then
@@ -118,7 +128,7 @@ class DataFlowCallable instanceof Cfg::CfgScope {
118128
int totalorder() { none() }
119129

120130
/** Gets the location of this callable. */
121-
Location getLocation() { result = this.getLocation() }
131+
Location getLocation() { result = this.(Cfg::CfgScope).getLocation() }
122132
}
123133

124134
newtype TReturnKind = TNormalReturn()
@@ -380,8 +390,8 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
380390
fieldStoreStep(node1, node2, c) or
381391
madStoreStep(node1, node2, c) or
382392
envToOutputStoreStep(node1, node2, c) or
383-
artifactToOutputStoreStep(node1, node2, c) or
384393
envToEnvStoreStep(node1, node2, c) or
394+
artifactToOutputStoreStep(node1, node2, c) or
385395
artifactToEnvStoreStep(node1, node2, c)
386396
}
387397

0 commit comments

Comments
 (0)