@@ -78,10 +78,17 @@ module ExceptionXss {
7878 )
7979 }
8080
81+ /**
82+ * Get the parameter in the callback that contains an error.
83+ * In the current implementation this is always the first parameter.
84+ */
8185 DataFlow:: Node getErrorParam ( ) { result = errorParameter }
8286 }
8387
84- // `someFunction(.. <pred> .., (<result>, value) => {...}).
88+ /**
89+ * Gets the error parameter for a callback that is supplied to the same call as `pred` is an argument to.
90+ * E.g: `outerCall(foo, <pred>, bar, (<result>, val) => { ... })`.
91+ */
8592 DataFlow:: Node getCallbackErrorParam ( DataFlow:: Node pred ) {
8693 exists ( DataFlow:: CallNode call , Callback callback |
8794 pred = call .getAnArgument ( ) and
@@ -92,10 +99,12 @@ module ExceptionXss {
9299 }
93100
94101 /**
95- * Gets the DataFlow::Node where an exception would flow to if `pred` is used in some context
96- * where an exception could potentially be thrown.
102+ * Gets the data-flow node where exceptions thrown by this expression will
103+ * propagate if this expression causes an exception to be thrown.
104+ * This predicate adds, on top of `Expr::getExceptionTarget`, exceptions
105+ * propagated by callbacks.
97106 */
98- DataFlow:: Node getWhereExceptionWouldFlow ( DataFlow:: Node pred ) {
107+ private DataFlow:: Node getExceptionTarget ( DataFlow:: Node pred ) {
99108 result = pred .asExpr ( ) .getExceptionTarget ( )
100109 or
101110 result = getCallbackErrorParam ( pred )
@@ -126,7 +135,7 @@ module ExceptionXss {
126135 inlbl instanceof NotYetThrown and
127136 ( outlbl .isTaint ( ) or outlbl instanceof NotYetThrown ) and
128137 canThrowSensitiveInformation ( pred ) and
129- succ = getWhereExceptionWouldFlow ( pred )
138+ succ = getExceptionTarget ( pred )
130139 or
131140 // All the usual taint-flow steps apply on data-flow before it has been thrown in an exception.
132141 this .isAdditionalFlowStep ( pred , succ ) and
0 commit comments