File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
lib/semmle/javascript/frameworks
test/query-tests/Security/CWE-022/TaintedPath Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,23 @@ module TaintStep {
52
52
/**
53
53
* Holds if there's a step from `pred` to `succ` due to templating data being
54
54
* passed from a templating call to a registered helper via a parameter.
55
+ *
56
+ * To establish the step, we look at the template passed to `compile`, and will
57
+ * only track steps from templates to helpers they actually reference.
58
+ *
59
+ * ```javascript
60
+ * function loudHelper(text) {
61
+ * // ^^^^ succ
62
+ * return text.toUpperCase();
63
+ * }
64
+ *
65
+ * hb.registerHelper("loud", loudHelper);
66
+ *
67
+ * const template = hb.compile("Hello, {{loud name}}!");
68
+ *
69
+ * template({name: "user"});
70
+ * // ^^^^^^ pred
71
+ * ```
55
72
*/
56
73
private predicate isHandlebarsArgStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
57
74
exists ( string helperName |
Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ const app = express();
7
7
const data = { } ;
8
8
9
9
function init ( ) {
10
+ hb . registerHelper ( "catFile" , catFile ) ;
10
11
data . compiledFileAccess = hb . compile ( "contents of file {{path}} are: {{catFile path}}" )
11
12
data . compiledBenign = hb . compile ( "hello, {{name}}" ) ;
12
13
data . compiledUnknown = hb . compile ( fs . readFileSync ( "greeting.template" ) ) ;
13
- hb . registerHelper ( "catFile" , catFile ) ;
14
14
}
15
15
16
16
init ( ) ;
You can’t perform that action at this time.
0 commit comments