Skip to content

Commit 9183fb0

Browse files
author
Alvaro Muñoz
committed
Fix expression always true query
1 parent 46d2bb2 commit 9183fb0

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

ql/lib/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
library: true
33
warnOnImplicitThis: true
44
name: githubsecuritylab/actions-all
5-
version: 0.0.13
5+
version: 0.0.14
66
dependencies:
77
codeql/util: ^0.2.0
88
codeql/yaml: ^0.1.2

ql/src/Security/CWE-571/ExpressionIsAlwaysTrue.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
*:
3+
*
24
* @name If expression always true
35
* @description Expressions used in If conditions with extra spaces are always true.
46
* @kind problem
@@ -16,10 +18,10 @@ import actions
1618
from If i
1719
where
1820
i.getCondition().matches("%${{%") and
19-
i.getConditionStyle() = ["|", ">"]
20-
or
21-
i.getCondition().matches("%${{%") and
22-
not i.getCondition().matches("${{%")
21+
(
22+
not i.getCondition().matches("${{%") or
23+
not i.getCondition().matches("%}}")
24+
)
2325
or
2426
count(i.getCondition().splitAt("${{")) > 2
2527
select i, "Expression always evaluates to true"

ql/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
library: false
33
name: githubsecuritylab/actions-queries
4-
version: 0.0.13
4+
version: 0.0.14
55
groups:
66
- actions
77
- queries

ql/test/query-tests/Security/CWE-571/.github/workflows/test.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
process-pr:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Test1
11+
- name: Test 1
1212
if: 1 == 2
1313
run: echo "Test 1 should not be printed"
1414
- name: Test 2
@@ -36,8 +36,8 @@ jobs:
3636
- name: Test 7
3737
run: echo "Test 7 should not be printed"
3838
if: ${{
39-
1 == 2 ||
40-
3 == 4
39+
github.actor == 'torvalds' ||
40+
github.actor == 'dependabot[bot]'
4141
}}
4242

4343
- name: Test 8
@@ -58,3 +58,32 @@ jobs:
5858
- name: Test 12
5959
if: " ${{ 1 == 2 }}"
6060
run: echo "Test 12 should not be printed"
61+
- name: Test 13
62+
if: |
63+
1 == 2 ||
64+
3 == 4
65+
run: echo "Test 13 should not be printed"
66+
- name: Test 14
67+
if: >-
68+
${{(
69+
false || 1 == 2
70+
)}}
71+
run: echo "Test 14 should not be printed"
72+
- name: Test 15
73+
if: |-
74+
${{(
75+
false || 1 == 2
76+
)}}
77+
run: echo "Test 15 should not be printed"
78+
- name: Test 16
79+
if: |+
80+
${{(
81+
false || 1 == 2
82+
)}}
83+
run: echo "Test 16 should not be printed"
84+
- name: Test 17
85+
if: >+
86+
${{(
87+
false || 1 == 2
88+
)}}
89+
run: echo "Test 17 should not be printed"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
| .github/workflows/test.yml:15:13:19:13 | \| | Expression always evaluates to true |
2+
| .github/workflows/test.yml:34:13:34:39 | ${{ 1 = ... == 2 }} | Expression always evaluates to true |
3+
| .github/workflows/test.yml:45:13:48:24 | > | Expression always evaluates to true |
4+
| .github/workflows/test.yml:56:15:56:31 | " ${{ 1 == 2 }}" | Expression always evaluates to true |
5+
| .github/workflows/test.yml:59:15:59:31 | " ${{ 1 == 2 }}" | Expression always evaluates to true |
6+
| .github/workflows/test.yml:79:13:82:14 | \|+ | Expression always evaluates to true |
7+
| .github/workflows/test.yml:85:13:88:14 | >+ | Expression always evaluates to true |

0 commit comments

Comments
 (0)