Skip to content

Commit f811294

Browse files
committed
Merge branch 'main' into sourcesinkdoc
2 parents df4f117 + 40903a9 commit f811294

File tree

1,547 files changed

+23041
-13755
lines changed

Some content is hidden

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

1,547 files changed

+23041
-13755
lines changed

.github/codeql/codeql-config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ paths-ignore:
88
- '/java/'
99
- '/python/'
1010
- '/javascript/ql/test'
11+
- '/javascript/ql/integration-tests'
1112
- '/javascript/extractor/tests'
1213
- '/rust/ql'

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818

1919
jobs:
2020
CodeQL-Build:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: ['actions', 'csharp']
2125

2226
runs-on: ubuntu-latest
2327

@@ -38,9 +42,8 @@ jobs:
3842
# Initializes the CodeQL tools for scanning.
3943
- name: Initialize CodeQL
4044
uses: github/codeql-action/init@main
41-
# Override language selection by uncommenting this and choosing your languages
4245
with:
43-
languages: csharp
46+
languages: ${{ matrix.language }}
4447
config-file: ./.github/codeql/codeql-config.yml
4548

4649
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).

actions/ql/src/Security/CWE-829/ArtifactPoisoningCritical.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
The following example, correctly creates a temporary directory and extracts the contents of the artifact there before calling `cmd.sh`.
4444

4545
```yaml
46-
name: Insecure Workflow
46+
name: Secure Workflow
4747
4848
on:
4949
workflow_run:

actions/ql/src/Security/CWE-829/ArtifactPoisoningMedium.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
The following example, correctly creates a temporary directory and extracts the contents of the artifact there before calling `cmd.sh`.
4444

4545
```yaml
46-
name: Insecure Workflow
46+
name: Secure Workflow
4747
4848
on:
4949
workflow_run:

actions/ql/src/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ extractor: actions
88
defaultSuiteFile: codeql-suites/actions-code-scanning.qls
99
dependencies:
1010
codeql/actions-all: ${workspace}
11+
codeql/suite-helpers: ${workspace}

csharp/ql/src/API Abuse/NoDisposeCallOnLocalIDisposable.ql

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import csharp
1717
import Dispose
1818
import semmle.code.csharp.frameworks.System
19+
import semmle.code.csharp.frameworks.system.threading.Tasks
1920
import semmle.code.csharp.commons.Disposal
2021

2122
private class ReturnNode extends DataFlow::ExprNode {
@@ -24,15 +25,27 @@ private class ReturnNode extends DataFlow::ExprNode {
2425
}
2526
}
2627

28+
private class Task extends Type {
29+
Task() {
30+
this instanceof SystemThreadingTasksTaskClass or
31+
this instanceof SystemThreadingTasksTaskTClass
32+
}
33+
}
34+
2735
module DisposeCallOnLocalIDisposableConfig implements DataFlow::ConfigSig {
2836
predicate isSource(DataFlow::Node node) {
29-
node.asExpr() =
30-
any(LocalScopeDisposableCreation disposable |
31-
// Only care about library types - user types often have spurious IDisposable declarations
32-
disposable.getType().fromLibrary() and
33-
// WebControls are usually disposed automatically
34-
not disposable.getType() instanceof WebControl
35-
)
37+
exists(LocalScopeDisposableCreation disposable, Type t |
38+
node.asExpr() = disposable and
39+
t = disposable.getType()
40+
|
41+
// Only care about library types - user types often have spurious IDisposable declarations
42+
t.fromLibrary() and
43+
// WebControls are usually disposed automatically
44+
not t instanceof WebControl and
45+
// It is typically not nessesary to dispose tasks
46+
// https://devblogs.microsoft.com/pfxteam/do-i-need-to-dispose-of-tasks/
47+
not t instanceof Task
48+
)
3649
}
3750

3851
predicate isSink(DataFlow::Node node) {

csharp/ql/src/Bad Practices/Control-Flow/ConstantCondition.ql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,14 @@ class ConstantMatchingCondition extends ConstantCondition {
119119
}
120120

121121
override predicate isWhiteListed() {
122-
exists(SwitchExpr se, int i |
123-
se.getCase(i).getPattern() = this.(DiscardExpr) and
122+
exists(Switch se, Case c, int i |
123+
c = se.getCase(i) and
124+
c.getPattern() = this.(DiscardExpr)
125+
|
124126
i > 0
127+
or
128+
i = 0 and
129+
exists(Expr cond | c.getCondition() = cond and not isConstantCondition(cond, true))
125130
)
126131
or
127132
this = any(PositionalPatternExpr ppe).getPattern(_)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The `cs/local-not-disposed` query no longer flags un-disposed tasks as this is often not needed (explained [here](https://devblogs.microsoft.com/pfxteam/do-i-need-to-dispose-of-tasks/)).
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Increase query precision for `cs/constant-condition` and allow the use of discards in switch/case statements and also take the condition (if any) into account.

csharp/ql/src/codeql-suites/csharp-ccr.qls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
- cs/self-assignment
99
- cs/inefficient-containskey
1010
- cs/call-to-object-tostring
11+
- cs/local-not-disposed

0 commit comments

Comments
 (0)