Skip to content

Commit 37fa244

Browse files
committed
JS: review comments
1 parent 07d508d commit 37fa244

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,6 @@ module FlowLabel {
242242
* source, but not necessarily directly derived from it.
243243
*/
244244
FlowLabel taint() { result = "taint" }
245-
246-
/**
247-
* Gets one of the two standard flow labels, `data` or `taint`, describing values that originate
248-
* from a flow source or are derived from a flow source.
249-
*/
250-
FlowLabel dataOrTaint() { result = data() or result = taint() }
251245
}
252246

253247
/**

javascript/ql/src/semmle/javascript/security/dataflow/TaintedPath.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ module TaintedPath {
2323

2424
module Label {
2525
/**
26-
* String indicating if a path is normalized, that is, whether internal `../` components
26+
* A string indicating if a path is normalized, that is, whether internal `../` components
2727
* have been removed.
2828
*/
2929
class Normalization extends string {
3030
Normalization() { this = "normalized" or this = "raw" }
3131
}
3232

3333
/**
34-
* String indicating if a path is relative or absolute.
34+
* A string indicating if a path is relative or absolute.
3535
*/
3636
class Relativeness extends string {
3737
Relativeness() { this = "relative" or this = "absolute" }
@@ -108,7 +108,7 @@ module TaintedPath {
108108
PosixPath toPosixPath(DataFlow::FlowLabel label) {
109109
result = label
110110
or
111-
label = DataFlow::FlowLabel::dataOrTaint()
111+
label instanceof DataFlow::StandardFlowLabel
112112
}
113113
}
114114

@@ -270,7 +270,7 @@ module TaintedPath {
270270
* Holds if `s` is a relative path.
271271
*/
272272
bindingset[s]
273-
private predicate isRelative(string s) { not s = "/" + any(string q) }
273+
private predicate isRelative(string s) { not s.charAt(0) = "/" }
274274

275275
/**
276276
* A call that normalizes a path.
@@ -375,7 +375,7 @@ module TaintedPath {
375375
input = getReceiver() and
376376
output = this and
377377
not exists(RegExpLiteral literal, RegExpSequence seq |
378-
getArgument(0).asExpr() = literal and
378+
getArgument(0).getALocalSource().asExpr() = literal and
379379
literal.isGlobal() and
380380
literal.getRoot() = seq and
381381
seq.getChild(0).(RegExpConstant).getValue() = "." and

javascript/ql/test/query-tests/Security/CWE-022/TaintedPath/normalizedPaths.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ app.get('/decode-after-normalization', (req, res) => {
223223
});
224224

225225
app.get('/replace', (req, res) => {
226-
let path = pathModule.normalize(req.query.path).replace(/%20/g, ' ');
227-
if (!pathModule.isAbsolute(path)) {
228-
res.sendFile(path); // NOT OK
226+
let path = pathModule.normalize(req.query.path).replace(/%20/g, ' ');
227+
if (!pathModule.isAbsolute(path)) {
228+
res.sendFile(path); // NOT OK
229229

230-
path = path.replace(/\.\./g, '');
231-
res.sendFile(path); // OK
232-
}
230+
path = path.replace(/\.\./g, '');
231+
res.sendFile(path); // OK
232+
}
233233
});

0 commit comments

Comments
 (0)