Skip to content

Commit 048f7db

Browse files
committed
Merge branch 'main' into nth
2 parents 6c31473 + 0ca9b22 commit 048f7db

File tree

201 files changed

+4411
-1410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+4411
-1410
lines changed

Cargo.lock

Lines changed: 15 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ use_repo(
8787
"vendor__globset-0.4.15",
8888
"vendor__itertools-0.14.0",
8989
"vendor__lazy_static-1.5.0",
90-
"vendor__log-0.4.22",
9190
"vendor__mustache-0.9.0",
9291
"vendor__num-traits-0.2.19",
9392
"vendor__num_cpus-1.16.0",
@@ -114,10 +113,10 @@ use_repo(
114113
"vendor__serde-1.0.217",
115114
"vendor__serde_json-1.0.135",
116115
"vendor__serde_with-3.12.0",
117-
"vendor__stderrlog-0.6.0",
118116
"vendor__syn-2.0.96",
119117
"vendor__toml-0.8.19",
120118
"vendor__tracing-0.1.41",
119+
"vendor__tracing-flame-0.2.0",
121120
"vendor__tracing-subscriber-0.3.19",
122121
"vendor__tree-sitter-0.24.6",
123122
"vendor__tree-sitter-embedded-template-0.23.2",

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ private predicate isTrustedOwner(string nwo) {
2323
trustedActionsOwnerDataModel(nwo.substring(0, nwo.indexOf("/")))
2424
}
2525

26+
bindingset[version]
27+
private predicate isPinnedContainer(string version) {
28+
version.regexpMatch("^sha256:[A-Fa-f0-9]{64}$")
29+
}
30+
31+
bindingset[nwo]
32+
private predicate isContainerImage(string nwo) { nwo.regexpMatch("^docker://.+") }
33+
2634
from UsesStep uses, string nwo, string version, Workflow workflow, string name
2735
where
2836
uses.getCallee() = nwo and
@@ -34,7 +42,7 @@ where
3442
) and
3543
uses.getVersion() = version and
3644
not isTrustedOwner(nwo) and
37-
not isPinnedCommit(version) and
45+
not (if isContainerImage(nwo) then isPinnedContainer(version) else isPinnedCommit(version)) and
3846
not isImmutableAction(uses, nwo)
3947
select uses.getCalleeNode(),
4048
"Unpinned 3rd party Action '" + name + "' step $@ uses '" + nwo + "' with ref '" + version +
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
5+
* Fixed false positives in the query `actions/unpinned-tag` (CWE-829), which will no longer flag uses of Docker-based GitHub actions pinned by the container's SHA256 digest.

actions/ql/test/query-tests/Security/CWE-829/.github/workflows/unpinned_tags.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ jobs:
99
- uses: foo/bar
1010
- uses: foo/bar@v1
1111
- uses: foo/bar@25b062c917b0c75f8b47d8469aff6c94ffd89abb
12+
- uses: docker://foo/bar@latest
13+
- uses: docker://foo/bar@sha256:887a259a5a534f3c4f36cb02dca341673c6089431057242cdc931e9f133147e9

actions/ql/test/query-tests/Security/CWE-829/UnpinnedActionsTag.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@
3232
| .github/workflows/test17.yml:20:21:20:63 | sonarsource/sonarcloud-github-action@master | Unpinned 3rd party Action 'Sonar' step $@ uses 'sonarsource/sonarcloud-github-action' with ref 'master', not a pinned commit hash | .github/workflows/test17.yml:19:15:23:58 | Uses Step | Uses Step |
3333
| .github/workflows/test18.yml:37:21:37:63 | sonarsource/sonarcloud-github-action@master | Unpinned 3rd party Action 'Sonar' step $@ uses 'sonarsource/sonarcloud-github-action' with ref 'master', not a pinned commit hash | .github/workflows/test18.yml:36:15:40:58 | Uses Step | Uses Step |
3434
| .github/workflows/unpinned_tags.yml:10:13:10:22 | foo/bar@v1 | Unpinned 3rd party Action 'unpinned_tags.yml' step $@ uses 'foo/bar' with ref 'v1', not a pinned commit hash | .github/workflows/unpinned_tags.yml:10:7:11:4 | Uses Step | Uses Step |
35+
| .github/workflows/unpinned_tags.yml:12:13:12:35 | docker://foo/bar@latest | Unpinned 3rd party Action 'unpinned_tags.yml' step $@ uses 'docker://foo/bar' with ref 'latest', not a pinned commit hash | .github/workflows/unpinned_tags.yml:12:7:13:4 | Uses Step | Uses Step |

actions/ql/test/query-tests/Security/CWE-829/UntrustedCheckoutCritical.expected

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ edges
299299
| .github/workflows/test.yml:14:9:25:6 | Run Step | .github/workflows/test.yml:25:9:33:6 | Run Step |
300300
| .github/workflows/test.yml:25:9:33:6 | Run Step | .github/workflows/test.yml:33:9:37:34 | Run Step |
301301
| .github/workflows/unpinned_tags.yml:9:7:10:4 | Uses Step | .github/workflows/unpinned_tags.yml:10:7:11:4 | Uses Step |
302-
| .github/workflows/unpinned_tags.yml:10:7:11:4 | Uses Step | .github/workflows/unpinned_tags.yml:11:7:11:61 | Uses Step |
302+
| .github/workflows/unpinned_tags.yml:10:7:11:4 | Uses Step | .github/workflows/unpinned_tags.yml:11:7:12:4 | Uses Step |
303+
| .github/workflows/unpinned_tags.yml:11:7:12:4 | Uses Step | .github/workflows/unpinned_tags.yml:12:7:13:4 | Uses Step |
304+
| .github/workflows/unpinned_tags.yml:12:7:13:4 | Uses Step | .github/workflows/unpinned_tags.yml:13:7:13:101 | Uses Step |
303305
| .github/workflows/untrusted_checkout2.yml:7:9:14:6 | Run Step: pr_number | .github/workflows/untrusted_checkout2.yml:14:9:19:72 | Run Step |
304306
| .github/workflows/untrusted_checkout3.yml:11:9:12:6 | Uses Step | .github/workflows/untrusted_checkout3.yml:12:9:13:6 | Uses Step |
305307
| .github/workflows/untrusted_checkout3.yml:12:9:13:6 | Uses Step | .github/actions/dangerous-git-checkout/action.yml:6:7:11:4 | Uses Step |

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,14 +1765,14 @@ module IteratorFlow {
17651765
* Note: Unlike `def.getAnUltimateDefinition()` this predicate also
17661766
* traverses back through iterator increment and decrement operations.
17671767
*/
1768-
private Ssa::Def getAnUltimateDefinition(Ssa::Def def) {
1768+
private Ssa::DefinitionExt getAnUltimateDefinition(Ssa::DefinitionExt def) {
17691769
result = def.getAnUltimateDefinition()
17701770
or
17711771
exists(IRBlock bb, int i, IteratorCrementCall crementCall, Ssa::SourceVariable sv |
17721772
crementCall = def.getValue().asInstruction().(StoreInstruction).getSourceValue() and
17731773
sv = def.getSourceVariable() and
17741774
bb.getInstruction(i) = crementCall and
1775-
Ssa::ssaDefReachesReadExt(sv, result.asDef(), bb, i)
1775+
Ssa::ssaDefReachesReadExt(sv, result, bb, i)
17761776
)
17771777
}
17781778

@@ -1800,13 +1800,13 @@ module IteratorFlow {
18001800
GetsIteratorCall beginCall, Instruction writeToDeref
18011801
) {
18021802
exists(
1803-
StoreInstruction beginStore, IRBlock bbStar, int iStar, Ssa::Def def,
1804-
IteratorPointerDereferenceCall starCall, Ssa::Def ultimate, Operand address
1803+
StoreInstruction beginStore, IRBlock bbStar, int iStar, Ssa::DefinitionExt def,
1804+
IteratorPointerDereferenceCall starCall, Ssa::DefinitionExt ultimate, Operand address
18051805
|
18061806
isIteratorWrite(writeToDeref, address) and
18071807
operandForFullyConvertedCall(address, starCall) and
18081808
bbStar.getInstruction(iStar) = starCall and
1809-
Ssa::ssaDefReachesReadExt(_, def.asDef(), bbStar, iStar) and
1809+
Ssa::ssaDefReachesReadExt(_, def, bbStar, iStar) and
18101810
ultimate = getAnUltimateDefinition*(def) and
18111811
beginStore = ultimate.getValue().asInstruction() and
18121812
operandForFullyConvertedCall(beginStore.getSourceValueOperand(), beginCall)

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -842,18 +842,11 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
842842
result.asSourceCallable() = this.getFunction()
843843
}
844844

845-
override Declaration getFunction() { result = globalDef.getIRFunction().getFunction() }
845+
override Declaration getFunction() { result = globalDef.getFunction() }
846846

847847
final override predicate isGLValue() { globalDef.getIndirectionIndex() = 0 }
848848

849-
override DataFlowType getType() {
850-
exists(DataFlowType type |
851-
type = globalDef.getUnderlyingType() and
852-
if this.isGLValue()
853-
then result = type
854-
else result = getTypeImpl(type, globalDef.getIndirectionIndex() - 1)
855-
)
856-
}
849+
override DataFlowType getType() { result = globalDef.getUnderlyingType() }
857850

858851
final override Location getLocationImpl() { result = globalDef.getLocation() }
859852

@@ -1312,7 +1305,7 @@ class UninitializedNode extends Node {
13121305
LocalVariable v;
13131306

13141307
UninitializedNode() {
1315-
exists(Ssa::Def def, Ssa::SourceVariable sv |
1308+
exists(Ssa::DefinitionExt def, Ssa::SourceVariable sv |
13161309
def.getIndirectionIndex() = 0 and
13171310
def.getValue().asInstruction() instanceof UninitializedInstruction and
13181311
Ssa::defToNode(this, def, sv, _, _, _) and
@@ -2299,7 +2292,7 @@ class ContentSet instanceof Content {
22992292

23002293
pragma[nomagic]
23012294
private predicate guardControlsPhiInput(
2302-
IRGuardCondition g, boolean branch, Ssa::Definition def, IRBlock input, Ssa::PhiNode phi
2295+
IRGuardCondition g, boolean branch, Ssa::DefinitionExt def, IRBlock input, Ssa::PhiNode phi
23032296
) {
23042297
phi.hasInputFromBlock(def, _, _, _, input) and
23052298
(

0 commit comments

Comments
 (0)