@@ -45,7 +45,8 @@ private DataFlow::Node getAValueExportedByPackage() {
45
45
|
46
46
result = callee .getAPropertyRead ( "prototype" ) .getAPropertyWrite ( publicPropertyName ( ) ) .getRhs ( )
47
47
or
48
- result = callee .( DataFlow:: ClassNode ) .getInstanceMethod ( publicPropertyName ( ) )
48
+ result = callee .( DataFlow:: ClassNode ) .getInstanceMethod ( publicPropertyName ( ) ) and
49
+ not isPrivateMethodDeclaration ( result )
49
50
)
50
51
or
51
52
result = getAValueExportedByPackage ( ) .getALocalSource ( )
@@ -65,7 +66,10 @@ private DataFlow::Node getAValueExportedByPackage() {
65
66
// static baz() {} // <- result
66
67
// constructor() {} // <- result
67
68
// };
68
- exists ( DataFlow:: ClassNode cla | cla = getAValueExportedByPackage ( ) |
69
+ exists ( DataFlow:: ClassNode cla |
70
+ cla = getAValueExportedByPackage ( ) and
71
+ not isPrivateMethodDeclaration ( result )
72
+ |
69
73
result = cla .getInstanceMethod ( publicPropertyName ( ) ) or
70
74
result = cla .getStaticMethod ( publicPropertyName ( ) ) or
71
75
result = cla .getConstructor ( )
@@ -185,3 +189,17 @@ bindingset[result]
185
189
private string publicPropertyName ( ) {
186
190
result .regexpMatch ( "[a-zA-Z0-9].*" )
187
191
}
192
+
193
+ /**
194
+ * Holds if the given function is part of a private (or protected) method declaration.
195
+ */
196
+ private predicate isPrivateMethodDeclaration ( DataFlow:: FunctionNode func ) {
197
+ exists ( MethodDeclaration decl |
198
+ decl .getBody ( ) = func .getFunction ( ) and
199
+ (
200
+ decl .isPrivate ( )
201
+ or
202
+ decl .isProtected ( )
203
+ )
204
+ )
205
+ }
0 commit comments