@@ -453,6 +453,30 @@ module API {
453
453
int getNumArgument ( ) { result = count ( this .getArg ( _) ) }
454
454
}
455
455
456
+ /**
457
+ * An API entry point.
458
+ *
459
+ * By default, API graph nodes are only created for nodes that come from an external
460
+ * library or escape into an external library. The points where values are cross the boundary
461
+ * between codebases are called "entry points".
462
+ *
463
+ * Anything imported from an external package is considered to be an entry point, but
464
+ * additional entry points may be added by extending this class.
465
+ */
466
+ abstract class EntryPoint extends string {
467
+ bindingset [ this ]
468
+ EntryPoint ( ) { any ( ) }
469
+
470
+ /** Gets a data-flow node corresponding to a use-node for this entry point. */
471
+ DataFlow:: LocalSourceNode getASource ( ) { none ( ) }
472
+
473
+ /** Gets a data-flow node corresponding to a def-node for this entry point. */
474
+ DataFlow:: Node getASink ( ) { none ( ) }
475
+
476
+ /** Gets an API-node for this entry point. */
477
+ API:: Node getANode ( ) { result = root ( ) .getASuccessor ( Label:: entryPoint ( this ) ) }
478
+ }
479
+
456
480
/**
457
481
* Provides the actual implementation of API graphs, cached for performance.
458
482
*
@@ -652,6 +676,12 @@ module API {
652
676
|
653
677
lbl = Label:: memberFromRef ( aw )
654
678
)
679
+ or
680
+ exists ( EntryPoint entry |
681
+ base = root ( ) and
682
+ lbl = Label:: entryPoint ( entry ) and
683
+ rhs = entry .getASink ( )
684
+ )
655
685
}
656
686
657
687
/**
@@ -735,6 +765,12 @@ module API {
735
765
ImportStar:: namePossiblyDefinedInImportStar ( ref .asCfgNode ( ) , name , s )
736
766
) )
737
767
)
768
+ or
769
+ exists ( EntryPoint entry |
770
+ base = root ( ) and
771
+ lbl = Label:: entryPoint ( entry ) and
772
+ ref = entry .getASource ( )
773
+ )
738
774
}
739
775
740
776
/**
@@ -909,7 +945,8 @@ module API {
909
945
MkLabelSelfParameter ( ) or
910
946
MkLabelReturn ( ) or
911
947
MkLabelSubclass ( ) or
912
- MkLabelAwait ( )
948
+ MkLabelAwait ( ) or
949
+ MkLabelEntryPoint ( EntryPoint ep )
913
950
914
951
/** A label for a module. */
915
952
class LabelModule extends ApiLabel , MkLabelModule {
@@ -983,6 +1020,15 @@ module API {
983
1020
class LabelAwait extends ApiLabel , MkLabelAwait {
984
1021
override string toString ( ) { result = "getAwaited()" }
985
1022
}
1023
+
1024
+ /** A label for entry points. */
1025
+ class LabelEntryPoint extends ApiLabel , MkLabelEntryPoint {
1026
+ private EntryPoint entry ;
1027
+
1028
+ LabelEntryPoint ( ) { this = MkLabelEntryPoint ( entry ) }
1029
+
1030
+ override string toString ( ) { result = "entryPoint(\"" + entry + "\")" }
1031
+ }
986
1032
}
987
1033
988
1034
/** Gets the edge label for the module `m`. */
@@ -1019,5 +1065,8 @@ module API {
1019
1065
1020
1066
/** Gets the `await` edge label. */
1021
1067
LabelAwait await ( ) { any ( ) }
1068
+
1069
+ /** Gets the label going from the root node to the nodes associated with the given entry point. */
1070
+ LabelEntryPoint entryPoint ( EntryPoint ep ) { result = MkLabelEntryPoint ( ep ) }
1022
1071
}
1023
1072
}
0 commit comments