@@ -64,8 +64,8 @@ public class JsSecuritySanitizer
6464 "location.href" , // Commonly set to redirect
6565 "document.location" , // Same
6666 "window.name" , // Used to pass data between domains
67- "localStorage" , // Persistent local storage
68- "sessionStorage" , // Session-scoped storage
67+ "localStorage" , // Persistent local storage (including .setItem, .getItem, etc.)
68+ "sessionStorage" , // Session-scoped storage (including .setItem, .getItem, etc.)
6969 "indexedDB" , // DB access
7070 "navigator.geolocation" , // Gets user location
7171 "navigator.clipboard" , // Read/write clipboard
@@ -108,6 +108,27 @@ private void TraverseNode(Node node, List<string> issues)
108108 {
109109 issues . Add ( $ "Call to disallowed function: { ident . Name } ") ;
110110 }
111+
112+ // Check for method calls on dangerous objects (e.g., localStorage.setItem)
113+ if ( callExpr . Callee is MemberExpression memberCall &&
114+ memberCall . Object is Identifier objIdent )
115+ {
116+ // Check if it's a dangerous object being called
117+ if ( DangerousProperties . Contains ( objIdent . Name ) )
118+ {
119+ issues . Add ( $ "Method call on disallowed object: { objIdent . Name } ") ;
120+ }
121+ }
122+ }
123+
124+ // Check for dangerous constructor calls (new XMLHttpRequest(), new Function(), etc.)
125+ if ( node is NewExpression newExpr )
126+ {
127+ if ( newExpr . Callee is Identifier ident &&
128+ DangerousCalls . Contains ( ident . Name ) )
129+ {
130+ issues . Add ( $ "Use of disallowed constructor: new { ident . Name } ()") ;
131+ }
111132 }
112133
113134 // Check for dangerous property access like window.location or document.cookie
0 commit comments