Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e93c20a

Browse files
committed
Python: You can supply defaults for HTTP Response properties
1 parent 87f31a9 commit e93c20a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

python/ql/src/experimental/semmle/python/Concepts.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,23 +262,35 @@ module HTTP {
262262
/** Gets the data-flow node that specifies the content-type of this HTTP response, if any. */
263263
abstract DataFlow::Node getContentTypeArg();
264264

265+
/** Gets the default content-type that should be used if `getContentTypeArg` has no results. */
266+
abstract string getContentTypeDefault();
267+
265268
/** Gets the content-type of this HTTP response, if it can be statically determined. */
266269
string getContentType() {
267270
exists(StrConst str |
268271
DataFlow::localFlow(DataFlow::exprNode(str), this.getContentTypeArg()) and
269272
result = str.getText()
270273
)
274+
or
275+
not exists(this.getContentTypeArg()) and
276+
result = this.getContentTypeDefault()
271277
}
272278

273279
/** Gets the data-flow node that specifies the status code of this HTTP response, if any. */
274280
abstract DataFlow::Node getStatusCodeArg();
275281

282+
/** Gets the default status code that should be used if `getStatusCodeArg` has no results. */
283+
abstract int getStatusCodeDefault();
284+
276285
/** Gets the status code of this HTTP response, if it can be statically determined. */
277286
int getStatusCode() {
278287
exists(IntegerLiteral i |
279288
DataFlow::localFlow(DataFlow::exprNode(i), this.getStatusCodeArg()) and
280289
result = i.getValue()
281290
)
291+
or
292+
not exists(this.getStatusCodeArg()) and
293+
result = this.getStatusCodeDefault()
282294
}
283295
}
284296
}

0 commit comments

Comments
 (0)