Skip to content

Commit 9468f62

Browse files
author
Stephan Brandauer
committed
add assignedToPropName feature to let the model improve number of false positives for XSS query
1 parent db73a62 commit 9468f62

File tree

1 file changed

+21
-1
lines changed
  • javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling

1 file changed

+21
-1
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/EndpointFeatures.qll

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ private newtype TEndpointFeature =
236236
TInputAccessPathFromCallee() or
237237
TInputArgumentIndex() or
238238
TContextFunctionInterfaces() or
239-
TContextSurroundingFunctionParameters()
239+
TContextSurroundingFunctionParameters() or
240+
TAssignedToPropName()
240241

241242
/**
242243
* An implementation of an endpoint feature: produces feature names and values for used in ML.
@@ -472,6 +473,25 @@ class ContextSurroundingFunctionParameters extends EndpointFeature,
472473
}
473474
}
474475

476+
/**
477+
* The feature that gives the name an endpoint is assigned to (if any).
478+
*
479+
* ### Example
480+
* ```javascript
481+
* const div = document.createElement('div');
482+
* div.innerHTML = endpoint; // feature value is 'innerHTML'
483+
* ```
484+
*/
485+
class AssignedToPropName extends EndpointFeature, TAssignedToPropName {
486+
override string getName() { result = "assignedToPropName" }
487+
488+
override string getValue(DataFlow::Node endpoint) {
489+
exists(DataFlow::PropWrite w | w.getRhs().asExpr().getUnderlyingValue().flow() = endpoint |
490+
result = w.getPropertyName()
491+
)
492+
}
493+
}
494+
475495
/**
476496
* The feature for the imports used in the callee of an invocation.
477497
*

0 commit comments

Comments
 (0)