@@ -41,20 +41,22 @@ jobs:
41
41
- name : Run action with args
42
42
uses : ./
43
43
with :
44
- args : -Dsonar.someArg=aValue -Dsonar.anotherArgWithSpaces="Another Value"
44
+ args : -Dsonar.someArg=aValue -Dsonar.anotherArgWithSpaces="Another Value" -Dsonar.argWithSingleQuotes='Another Value'
45
45
env :
46
46
SONAR_HOST_URL : http://not_actually_used
47
47
SONAR_SCANNER_JSON_PARAMS : ' {"sonar.scanner.internal.dumpToFile": "./output.properties"}'
48
48
- name : Assert
49
49
run : |
50
50
./test/assertFileContains ./output.properties "sonar.someArg=aValue"
51
- ./test/assertFileContains ./output.properties "sonar.anotherArgWithSpaces=Another Value"
51
+ ./test/assertFileContains ./output.properties 'sonar.anotherArgWithSpaces="Another Value"'
52
+ ./test/assertFileContains ./output.properties "sonar.argWithSingleQuotes='Another Value'"
52
53
argsInputInjectionTest :
53
54
name : >
54
55
'args' input with command injection will fail
55
56
strategy :
56
57
matrix :
57
58
os : [ ubuntu-latest-large, windows-latest-large, macos-latest ]
59
+ args : [ -Dsonar.someArg=aValue && echo "Injection", -Dsonar.someArg="value\"; whoami; echo \"" ]
58
60
runs-on : ${{ matrix.os }}
59
61
steps :
60
62
- uses : actions/checkout@v5
64
66
uses : ./
65
67
continue-on-error : true
66
68
with :
67
- args : -Dsonar.someArg=aValue && echo "Injection"
69
+ args : ${{ matrix.args }}
68
70
env :
69
71
SONAR_HOST_URL : http://not_actually_used
70
72
SONAR_SCANNER_JSON_PARAMS : ' {"sonar.scanner.internal.dumpToFile": "./output.properties"}'
74
76
- name : Assert the scanner was not called
75
77
run : |
76
78
./test/assertFileDoesntExist ./output.properties
79
+ backtickCommandInjectionTest :
80
+ name : >
81
+ 'args' input with backticks injection does not execute command
82
+ strategy :
83
+ matrix :
84
+ os : [ ubuntu-latest-large, windows-latest-large, macos-latest ]
85
+ runs-on : ${{ matrix.os }}
86
+ steps :
87
+ - uses : actions/checkout@v5
88
+ with :
89
+ token : ${{ secrets.GITHUB_TOKEN }}
90
+ - name : Run action with args
91
+ uses : ./
92
+ continue-on-error : true
93
+ with :
94
+ args : >
95
+ -Dsonar.arg1="refs/heads/branch: [workflows] Bump `actions/*`" -Dsonar.arg2="test `echo Command Injection`" -Dsonar.arg3="`id`" -Dsonar.arg4="test'; `echo injection`; echo '" -Dsonar.arg5=" `whoami` " -Dsonar.arg6="test\`echo injection\`test"
96
+ env :
97
+ SONAR_HOST_URL : http://not_actually_used
98
+ SONAR_SCANNER_JSON_PARAMS : ' {"sonar.scanner.internal.dumpToFile": "./output.properties"}'
99
+ - name : Assert command in arg is not executed
100
+ run : |
101
+ ./test/assertFileContains ./output.properties 'sonar.arg1="refs/heads/branch\\: \[workflows\] Bump `actions/\*`"'
102
+ ./test/assertFileContains ./output.properties 'sonar.arg2="test `echo Command Injection`"'
103
+ ./test/assertFileContains ./output.properties 'sonar.arg3="`id`"'
104
+ ./test/assertFileContains ./output.properties "sonar.arg4=\"test'; \`echo injection\`; echo '\""
105
+ ./test/assertFileContains ./output.properties 'sonar.arg5=" `whoami` "'
106
+ ./test/assertFileContains ./output.properties 'sonar.arg6="test\\\\`echo injection\\\\`test"'
107
+ dollarSymbolCommandInjectionTest :
108
+ name : >
109
+ 'args' input with dollar command injection does not execute command
110
+ strategy :
111
+ matrix :
112
+ os : [ ubuntu-latest-large, windows-latest-large, macos-latest ]
113
+ runs-on : ${{ matrix.os }}
114
+ steps :
115
+ - uses : actions/checkout@v5
116
+ with :
117
+ token : ${{ secrets.GITHUB_TOKEN }}
118
+ - name : Run action with args
119
+ uses : ./
120
+ continue-on-error : true
121
+ with :
122
+ args : -Dsonar.arg1="$(whoami)" -Dsonar.arg2="$GITHUB_TOKEN" -Dsonar.arg3="$(echo outer $(echo inner))" -Dsonar.arg4="value\$(whoami)end" -Dsonar.arg5="$(printf 'A%.0s' {1..10000})" -Dsonar.arg6='value"; $(whoami); echo "'
123
+ env :
124
+ SONAR_HOST_URL : http://not_actually_used
125
+ SONAR_SCANNER_JSON_PARAMS : ' {"sonar.scanner.internal.dumpToFile": "./output.properties"}'
126
+ - name : Assert command in arg is not executed
127
+ run : |
128
+ ./test/assertFileContains ./output.properties 'sonar.arg1="$(whoami)"'
129
+ ./test/assertFileContains ./output.properties 'sonar.arg2="$GITHUB_TOKEN"'
130
+ ./test/assertFileContains ./output.properties 'sonar.arg3="$(echo outer $(echo inner))"'
131
+ ./test/assertFileContains ./output.properties 'sonar.arg4="value\\\\$(whoami)end"'
132
+ ./test/assertFileContains ./output.properties 'sonar.arg5="$(printf '\''A%.0s'\'' {1..10000})"'
133
+ ./test/assertFileContains ./output.properties 'sonar.arg6='\''value"; $(whoami); echo "'\'''
134
+ otherCommandInjectionVariantsTest :
135
+ name : >
136
+ 'args' input with other command injection variants does not execute command
137
+ strategy :
138
+ matrix :
139
+ os : [ ubuntu-latest-large, windows-latest-large, macos-latest ]
140
+ runs-on : ${{ matrix.os }}
141
+ steps :
142
+ - uses : actions/checkout@v5
143
+ with :
144
+ token : ${{ secrets.GITHUB_TOKEN }}
145
+ - name : Run action with args
146
+ uses : ./
147
+ continue-on-error : true
148
+ with :
149
+ args : -Dsonar.arg1="test | base64" -Dsonar.arg2="value; whoami" -Dsonar.arg3="value && echo test" -Dsonar.arg4="value > /tmp/output.txt" -Dsonar.arg5="< /etc/passwd" -Dsonar.arg6="" -Dsonar.arg7="../../../*" -Dsonar.arg8="*.key" -Dsonar.arg9="test\u0027\u0060whoami\u0060"
150
+ env :
151
+ SONAR_HOST_URL : http://not_actually_used
152
+ SONAR_SCANNER_JSON_PARAMS : ' {"sonar.scanner.internal.dumpToFile": "./output.properties"}'
153
+ - name : Assert command in arg is not executed
154
+ run : |
155
+ ./test/assertFileContains ./output.properties 'sonar.arg1="test | base64"'
156
+ ./test/assertFileContains ./output.properties 'sonar.arg2="value; whoami"'
157
+ ./test/assertFileContains ./output.properties 'sonar.arg3="value && echo test"'
158
+ ./test/assertFileContains ./output.properties 'sonar.arg4="value > /tmp/output.txt"'
159
+ ./test/assertFileContains ./output.properties 'sonar.arg5="< /etc/passwd"'
160
+ ./test/assertFileContains ./output.properties 'sonar.arg6=""'
161
+ ./test/assertFileContains ./output.properties 'sonar.arg7="../../../\*"'
162
+ ./test/assertFileContains ./output.properties 'sonar.arg8="\*.key"'
163
+ ./test/assertFileContains ./output.properties 'sonar.arg9="test\\\\u0027\\\\u0060whoami\\\\u0060"'
77
164
projectBaseDirInputTest :
78
165
name : >
79
166
'projectBaseDir' input
0 commit comments