Skip to content

Commit aa62603

Browse files
author
Alvaro Muñoz
authored
Merge pull request #29 from GitHubSecurityLab/clean
fix: clean debug lefovers
2 parents 37331c3 + 0b71d02 commit aa62603

File tree

7 files changed

+116
-43
lines changed

7 files changed

+116
-43
lines changed

ql/lib/codeql/actions/Ast.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class Outputs extends AstNode instanceof OutputsImpl {
121121

122122
Expression getOutputExpr(string outputName) { result = super.getOutputExpr(outputName) }
123123

124-
// TODO: REMOVE
125124
override string toString() { result = "Job outputs node" }
126125
}
127126

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,6 @@ class CompositeActionImpl extends AstNodeImpl, TCompositeAction {
252252

253253
override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
254254

255-
// override AstNodeImpl getAChildNode() {
256-
// result = this.getInputs() or
257-
// result = this.getOutputs() or
258-
// result = this.getRuns()
259-
// }
260255
override AstNodeImpl getParentNode() { none() }
261256

262257
override string getAPrimaryQlClass() { result = "CompositeActionImpl" }
@@ -292,12 +287,6 @@ class WorkflowImpl extends AstNodeImpl, TWorkflowNode {
292287

293288
override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
294289

295-
// override AstNodeImpl getAChildNode() {
296-
// result = this.getAJob() or
297-
// result = this.getStrategy() or
298-
// result = this.getEnv() or
299-
// result = this.getPermissions()
300-
// }
301290
override AstNodeImpl getParentNode() { none() }
302291

303292
override string getAPrimaryQlClass() { result = "WorkflowImpl" }
@@ -306,8 +295,6 @@ class WorkflowImpl extends AstNodeImpl, TWorkflowNode {
306295

307296
override YamlMapping getNode() { result = n }
308297

309-
// /** Gets the `jobs` mapping from job IDs to job definitions in this workflow. */
310-
// YamlMapping getJobs() { result = this.asYamlMapping().lookup("jobs") }
311298
/** Gets the 'global' `env` mapping in this workflow. */
312299
EnvImpl getEnv() { result.getNode() = n.lookup("env") }
313300

@@ -346,11 +333,6 @@ class ReusableWorkflowImpl extends AstNodeImpl, WorkflowImpl {
346333

347334
override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
348335

349-
// override AstNodeImpl getAChildNode() {
350-
// result = super.getAChildNode() or
351-
// result = this.getInputs() or
352-
// result = this.getOutputs()
353-
// }
354336
OutputsImpl getOutputs() { result.getNode() = workflow_call.(YamlMapping).lookup("outputs") }
355337

356338
ExpressionImpl getAnOutputExpr() { result = this.getOutputs().getAnOutputExpr() }
@@ -378,7 +360,6 @@ class RunsImpl extends AstNodeImpl, TRunsNode {
378360

379361
override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
380362

381-
//override AstNodeImpl getAChildNode() { result = this.getAStep() }
382363
override CompositeActionImpl getParentNode() { result.getAChildNode() = this }
383364

384365
override string getAPrimaryQlClass() { result = "RunsImpl" }
@@ -450,7 +431,6 @@ class OutputsImpl extends AstNodeImpl, TOutputsNode {
450431

451432
override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
452433

453-
//override AstNodeImpl getAChildNode() { result = this.getAnOutputExpr() }
454434
override AstNodeImpl getParentNode() { result.getAChildNode() = this }
455435

456436
override string getAPrimaryQlClass() { result = "OutputsImpl" }
@@ -503,7 +483,6 @@ class StrategyImpl extends AstNodeImpl, TStrategyNode {
503483

504484
override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
505485

506-
//override ExpressionImpl getAChildNode() { result = this.getAMatrixVarExpr() }
507486
override AstNodeImpl getParentNode() { result.getAChildNode() = this }
508487

509488
override string getAPrimaryQlClass() { result = "StrategyImpl" }
@@ -557,10 +536,8 @@ class JobImpl extends AstNodeImpl, TJobNode {
557536
workflow.getNode().lookup("jobs").(YamlMapping).lookup(jobId) = n
558537
}
559538

560-
// TODO: REMOVE
561539
override string toString() { result = "Job: " + jobId }
562540

563-
//override string toString() { result = n.toString() }
564541
override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
565542

566543
override WorkflowImpl getParentNode() { result.getAChildNode() = this }
@@ -739,7 +716,6 @@ class UsesStepImpl extends StepImpl, UsesImpl {
739716
result.getParentNode().getNode() = n.lookup("with").(YamlMapping).lookup(key)
740717
}
741718

742-
// TODO: REMOVE
743719
override string toString() {
744720
if exists(this.getId()) then result = "Uses Step: " + this.getId() else result = "Uses Step"
745721
}
@@ -760,7 +736,6 @@ class ExternalJobImpl extends JobImpl, UsesImpl {
760736

761737
ExternalJobImpl() { n.lookup("uses") = u }
762738

763-
//override AstNodeImpl getAChildNode() { result.getNode() = n.getAChildNode*() }
764739
override string getCallee() {
765740
if u.getValue().matches("./%")
766741
then result = u.getValue().regexpCapture(pathUsesParser(), 1)
@@ -796,7 +771,6 @@ class RunImpl extends StepImpl {
796771

797772
ExpressionImpl getAnScriptExpr() { result.getParentNode().getNode() = script }
798773

799-
// TODO: REMOVE
800774
override string toString() {
801775
if exists(this.getId()) then result = "Run Step: " + this.getId() else result = "Run Step"
802776
}
@@ -807,14 +781,6 @@ class RunImpl extends StepImpl {
807781
* https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
808782
*/
809783
abstract class ContextExpressionImpl extends ExpressionImpl {
810-
// TODO: REMOVE
811-
// ContextExpressionImpl() {
812-
// expression
813-
// .regexpMatch([
814-
// stepsCtxRegex(), needsCtxRegex(), jobsCtxRegex(), envCtxRegex(), inputsCtxRegex(),
815-
// matrixCtxRegex()
816-
// ])
817-
// }
818784
abstract string getFieldName();
819785

820786
abstract AstNodeImpl getTarget();

ql/lib/codeql/actions/dataflow/FlowSources.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ private predicate isExternalUserControlledWorkflowRun(string context) {
9696
exists(string reg |
9797
reg =
9898
[
99+
"\\bgithub\\s*\\.\\s*event\\s*\\.\\s*workflow\\s*\\.\\s*path\\b",
99100
"\\bgithub\\s*\\.\\s*event\\s*\\.\\s*workflow_run\\s*\\.\\s*head_branch\\b",
100101
"\\bgithub\\s*\\.\\s*event\\s*\\.\\s*workflow_run\\s*\\.\\s*display_title\\b",
101102
"\\bgithub\\s*\\.\\s*event\\s*\\.\\s*workflow_run\\s*\\.\\s*head_repository\\b\\s*\\.\\s*description\\b",

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class DataFlowCall instanceof Cfg::Node {
7272
/** Gets a textual representation of this element. */
7373
string toString() { result = super.toString() }
7474

75-
//Location getLocation() { result = super.getLocation() }
7675
string getName() { result = super.getAstNode().(Uses).getCallee() }
7776

7877
DataFlowCallable getEnclosingCallable() { result = super.getScope() }
@@ -84,7 +83,6 @@ class DataFlowCall instanceof Cfg::Node {
8483
class DataFlowCallable instanceof Cfg::CfgScope {
8584
string toString() { result = super.toString() }
8685

87-
//Location getLocation() { result = super.getLocation() }
8886
string getName() {
8987
if this instanceof ReusableWorkflow
9088
then result = this.(ReusableWorkflow).getLocation().getFile().getRelativePath()

ql/src/Security/CWE-094/CriticalExpressionInjection.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ module MyFlow = TaintTracking::Global<MyConfig>;
3434

3535
import MyFlow::PathGraph
3636

37-
from MyFlow::PathNode source, MyFlow::PathNode sink
37+
from MyFlow::PathNode source, MyFlow::PathNode sink, Workflow w
3838
where
3939
MyFlow::flowPath(source, sink) and
40-
source
41-
.getNode()
42-
.asExpr()
43-
.getEnclosingWorkflow()
44-
.hasTriggerEvent(source.getNode().(RemoteFlowSource).getATriggerEvent())
40+
w = source.getNode().asExpr().getEnclosingWorkflow() and
41+
(
42+
w instanceof ReusableWorkflow or
43+
w.hasTriggerEvent(source.getNode().(RemoteFlowSource).getATriggerEvent())
44+
)
4545
select sink.getNode(), source, sink,
4646
"Potential expression injection in $@, which may be controlled by an external user.", sink,
4747
sink.getNode().asExpr().(Expression).getExpression()
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: changelog
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
create:
7+
description: Add a log to the changelog
8+
type: boolean
9+
required: false
10+
default: false
11+
update:
12+
description: Update the existing changelog
13+
type: boolean
14+
required: false
15+
default: false
16+
17+
jobs:
18+
changelog:
19+
runs-on: ubuntu-latest
20+
env:
21+
file: CHANGELOG.md
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
- name: Check ${{ env.file }}
27+
run: |
28+
if [[ $(git diff --name-only origin/master HEAD -- ${{ env.file }} | grep '^${{ env.file }}$' -c) -eq 0 ]]; then
29+
echo "Expected '${{ env.file }}' to be modified"
30+
exit 1
31+
fi
32+
update:
33+
runs-on: ubuntu-latest
34+
needs: changelog
35+
if: (inputs.create && failure()) || (inputs.update && success())
36+
continue-on-error: true
37+
env:
38+
file: CHANGELOG.md
39+
next_version: next
40+
link: '[#${{ github.event.number }}](https://github.com/fabricjs/fabric.js/pull/${{ github.event.number }})'
41+
steps:
42+
- uses: actions/checkout@v3
43+
with:
44+
ref: ${{ github.event.pull_request.head.ref }}
45+
- name: Update ${{ env.file }} from PR title
46+
id: update
47+
uses: actions/github-script@v6
48+
env:
49+
log: '- ${{ github.event.pull_request.title }} ${{ env.link }}\n'
50+
prev_log: '- ${{ github.event.changes.title.from }} ${{ env.link }}\n'
51+
with:
52+
result-encoding: string
53+
script: |
54+
const fs = require('fs');
55+
const file = './${{ env.file }}';
56+
let content = fs.readFileSync(file).toString();
57+
const title = '[${{ env.next_version }}]';
58+
const log = '${{ env.log }}';
59+
let exists = ${{ needs.changelog.result == 'success' }};
60+
61+
if (!content.includes(title)) {
62+
const insertAt = content.indexOf('\n') + 1;
63+
content =
64+
content.slice(0, insertAt) +
65+
`\n## ${title}\n\n\n` +
66+
content.slice(insertAt);
67+
}
68+
69+
const insertAt = content.indexOf('\n', content.indexOf(title) + title.length + 1) + 1;
70+
if (exists && ${{ github.event.action == 'edited' }}) {
71+
const prevLog = '${{ env.prev_log }}';
72+
const index = content.indexOf(prevLog, insertAt);
73+
if (index > -1) {
74+
content = content.slice(0, index) + content.slice(index + prevLog.length);
75+
exists = false;
76+
}
77+
}
78+
79+
if (!exists) {
80+
content = content.slice(0, insertAt) + log + content.slice(insertAt);
81+
fs.writeFileSync(file, content);
82+
return true;
83+
}
84+
85+
return false;
86+
- name: Setup node
87+
if: fromJson(steps.update.outputs.result)
88+
uses: actions/setup-node@v3
89+
with:
90+
node-version: 18.x
91+
- name: Commit & Push
92+
if: fromJson(steps.update.outputs.result)
93+
run: |
94+
npm ci
95+
npx prettier --write ${{ env.file }}
96+
git config user.name github-actions[bot]
97+
git config user.email github-actions[bot]@users.noreply.github.com
98+
git add ${{ env.file }}
99+
git commit -m "update ${{ env.file }}"
100+
git push
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: '📋'
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
changelog:
9+
uses: ./.github/workflows/changelog.yml

0 commit comments

Comments
 (0)