File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed
src/semmle/javascript/dataflow/internal
test/library-tests/TaintTracking Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,23 @@ private PropertyName getPropertyName(PropAccess pacc) {
3939 )
4040}
4141
42+ private SsaVariable getRefinedVariable ( SsaVariable variable ) {
43+ result = variable .getDefinition ( ) .( SsaRefinementNode ) .getAnInput ( )
44+ }
45+
46+ private SsaVariable getARefinementOf ( SsaVariable variable ) {
47+ variable = getRefinedVariable ( result )
48+ }
49+
4250/**
4351 * A representation of a (nested) property access on an SSA variable
4452 * where each property name is either constant or itself an SSA variable.
4553 */
4654private newtype TAccessPath =
47- MkSsaRoot ( SsaVariable var ) or
55+ MkSsaRoot ( SsaVariable var ) {
56+ not exists ( getRefinedVariable ( var ) )
57+ }
58+ or
4859 MkThisRoot ( Function function ) { function .getThisBinder ( ) = function } or
4960 MkAccessStep ( AccessPath base , PropertyName name ) {
5061 exists ( PropAccess pacc |
@@ -64,7 +75,7 @@ class AccessPath extends TAccessPath {
6475 Expr getAnInstanceIn ( BasicBlock bb ) {
6576 exists ( SsaVariable var |
6677 this = MkSsaRoot ( var ) and
67- result = var .getAUseIn ( bb )
78+ result = getARefinementOf * ( var ) .getAUseIn ( bb )
6879 )
6980 or
7081 exists ( ThisExpr this_ |
Original file line number Diff line number Diff line change 11| access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:4:8:4:12 | obj.x |
2- | access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:15:10:15:14 | obj.x |
32| addexpr.js:4:10:4:17 | source() | addexpr.js:7:8:7:8 | x |
43| addexpr.js:11:15:11:22 | source() | addexpr.js:21:8:21:12 | value |
54| advanced-callgraph.js:2:13:2:20 | source() | advanced-callgraph.js:6:22:6:22 | v |
Original file line number Diff line number Diff line change @@ -12,6 +12,6 @@ function foo() {
1212 }
1313
1414 if ( isSafe ( obj . x ) && typeof obj === "object" ) {
15- sink ( obj . x ) ; // OK - but flagged anyway
15+ sink ( obj . x ) ; // OK
1616 }
1717}
You can’t perform that action at this time.
0 commit comments