Skip to content

Commit 9e675d9

Browse files
author
Esben Sparre Andreasen
committed
JS: split TaintedFormatString.qll
1 parent 26c29cb commit 9e675d9

File tree

2 files changed

+50
-33
lines changed

2 files changed

+50
-33
lines changed
Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
/**
2-
* Provides a taint-tracking configuration for reasoning about format injections.
2+
* Provides a taint-tracking configuration for reasoning about format
3+
* injections.
4+
*
5+
*
6+
* Note, for performance reasons: only import this file if
7+
* `TaintedFormatString::Configuration` is needed, otherwise
8+
* `TaintedFormatStringCustomizations` should be imported instead.
39
*/
410

511
import javascript
612
import semmle.javascript.security.dataflow.DOM
713

814
module TaintedFormatString {
9-
/**
10-
* A data flow source for format injections.
11-
*/
12-
abstract class Source extends DataFlow::Node { }
13-
14-
/**
15-
* A data flow sink for format injections.
16-
*/
17-
abstract class Sink extends DataFlow::Node { }
18-
19-
/**
20-
* A sanitizer for format injections.
21-
*/
22-
abstract class Sanitizer extends DataFlow::Node { }
15+
import TaintedFormatStringCustomizations::TaintedFormatString
2316

2417
/**
2518
* A taint-tracking configuration for format injections.
@@ -36,22 +29,4 @@ module TaintedFormatString {
3629
node instanceof Sanitizer
3730
}
3831
}
39-
40-
/** A source of remote user input, considered as a flow source for format injection. */
41-
class RemoteSource extends Source {
42-
RemoteSource() { this instanceof RemoteFlowSource }
43-
}
44-
45-
/**
46-
* A format argument to a printf-like function, considered as a flow sink for format injection.
47-
*/
48-
class FormatSink extends Sink {
49-
FormatSink() {
50-
exists(PrintfStyleCall printf |
51-
this = printf.getFormatString() and
52-
// exclude trivial case where there are no arguments to interpolate
53-
exists(printf.getFormatArgument(_))
54-
)
55-
}
56-
}
5732
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Provides default sources, sinks and sanitisers for reasoning about
3+
* format injections, as well as extension points for adding your own.
4+
*/
5+
6+
import javascript
7+
import semmle.javascript.security.dataflow.DOM
8+
9+
module TaintedFormatString {
10+
/**
11+
* A data flow source for format injections.
12+
*/
13+
abstract class Source extends DataFlow::Node { }
14+
15+
/**
16+
* A data flow sink for format injections.
17+
*/
18+
abstract class Sink extends DataFlow::Node { }
19+
20+
/**
21+
* A sanitizer for format injections.
22+
*/
23+
abstract class Sanitizer extends DataFlow::Node { }
24+
25+
/** A source of remote user input, considered as a flow source for format injection. */
26+
class RemoteSource extends Source {
27+
RemoteSource() { this instanceof RemoteFlowSource }
28+
}
29+
30+
/**
31+
* A format argument to a printf-like function, considered as a flow sink for format injection.
32+
*/
33+
class FormatSink extends Sink {
34+
FormatSink() {
35+
exists(PrintfStyleCall printf |
36+
this = printf.getFormatString() and
37+
// exclude trivial case where there are no arguments to interpolate
38+
exists(printf.getFormatArgument(_))
39+
)
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)