Skip to content

Commit db6b1e5

Browse files
authored
Merge pull request #14912 from jketema/dep-userinput
C++: Deprecate `isUserInput`, `userInputArgument`, and `userInputReturned`
2 parents 64eb4ff + c6b0a23 commit db6b1e5

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: deprecated
3+
---
4+
* The `isUserInput`, `userInputArgument`, and `userInputReturned` predicates from `SecurityOptions` have been deprecated. Use `FlowSource` instead.

cpp/ql/lib/semmle/code/cpp/security/Security.qll

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class SecurityOptions extends string {
4545
/**
4646
* The argument of the given function is filled in from user input.
4747
*/
48-
predicate userInputArgument(FunctionCall functionCall, int arg) {
48+
deprecated predicate userInputArgument(FunctionCall functionCall, int arg) {
4949
exists(string fname |
5050
functionCall.getTarget().hasGlobalOrStdName(fname) and
5151
exists(functionCall.getArgument(arg)) and
@@ -73,7 +73,7 @@ class SecurityOptions extends string {
7373
/**
7474
* The return value of the given function is filled in from user input.
7575
*/
76-
predicate userInputReturned(FunctionCall functionCall) {
76+
deprecated predicate userInputReturned(FunctionCall functionCall) {
7777
exists(string fname |
7878
functionCall.getTarget().getName() = fname and
7979
(
@@ -91,12 +91,8 @@ class SecurityOptions extends string {
9191

9292
/**
9393
* DEPRECATED: Users should override `userInputReturned()` instead.
94-
*
95-
* note: this function is not formally tagged as `deprecated` since the
96-
* new `userInputReturned` uses it to provide compatibility with older
97-
* custom SecurityOptions.qll files.
9894
*/
99-
predicate userInputReturn(string function) { none() }
95+
deprecated predicate userInputReturn(string function) { none() }
10096

10197
/**
10298
* The argument of the given function is used for running a process or loading
@@ -117,7 +113,7 @@ class SecurityOptions extends string {
117113
* computed from user input. Such expressions are treated as
118114
* sources of taint.
119115
*/
120-
predicate isUserInput(Expr expr, string cause) {
116+
deprecated predicate isUserInput(Expr expr, string cause) {
121117
exists(FunctionCall fc, int i |
122118
this.userInputArgument(fc, i) and
123119
expr = fc.getArgument(i) and
@@ -178,17 +174,17 @@ predicate argv(Parameter argv) {
178174
predicate isPureFunction(string name) { exists(SecurityOptions opts | opts.isPureFunction(name)) }
179175

180176
/** Convenience accessor for SecurityOptions.userInputArgument */
181-
predicate userInputArgument(FunctionCall functionCall, int arg) {
177+
deprecated predicate userInputArgument(FunctionCall functionCall, int arg) {
182178
exists(SecurityOptions opts | opts.userInputArgument(functionCall, arg))
183179
}
184180

185181
/** Convenience accessor for SecurityOptions.userInputReturn */
186-
predicate userInputReturned(FunctionCall functionCall) {
182+
deprecated predicate userInputReturned(FunctionCall functionCall) {
187183
exists(SecurityOptions opts | opts.userInputReturned(functionCall))
188184
}
189185

190186
/** Convenience accessor for SecurityOptions.isUserInput */
191-
predicate isUserInput(Expr expr, string cause) {
187+
deprecated predicate isUserInput(Expr expr, string cause) {
192188
exists(SecurityOptions opts | opts.isUserInput(expr, cause))
193189
}
194190

cpp/ql/lib/semmle/code/cpp/security/SecurityOptions.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CustomSecurityOptions extends SecurityOptions {
2323
none() // rules to match custom functions replace this line
2424
}
2525

26-
override predicate userInputArgument(FunctionCall functionCall, int arg) {
26+
deprecated override predicate userInputArgument(FunctionCall functionCall, int arg) {
2727
SecurityOptions.super.userInputArgument(functionCall, arg)
2828
or
2929
exists(string fname |
@@ -36,7 +36,7 @@ class CustomSecurityOptions extends SecurityOptions {
3636
)
3737
}
3838

39-
override predicate userInputReturned(FunctionCall functionCall) {
39+
deprecated override predicate userInputReturned(FunctionCall functionCall) {
4040
SecurityOptions.super.userInputReturned(functionCall)
4141
or
4242
exists(string fname |

0 commit comments

Comments
 (0)