33 */
44
55private import java
6+ private import semmle.code.Location as Location
67private import semmle.code.java.dataflow.DataFlow
78private import semmle.code.java.dataflow.TaintTracking
89private import semmle.code.java.security.PathCreation
@@ -23,10 +24,12 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
2324
2425 class NegativeEndpointType = AutomodelEndpointTypes:: NegativeSinkType ;
2526
27+ class RelatedLocation = Location:: Top ;
28+
2629 // Sanitizers are currently not modeled in MaD. TODO: check if this has large negative impact.
2730 predicate isSanitizer ( Endpoint e , EndpointType t ) { none ( ) }
2831
29- string getLocationString ( Endpoint e ) { result = e .getLocation ( ) . toString ( ) }
32+ RelatedLocation toRelatedLocation ( Endpoint e ) { result = e .asParameter ( ) }
3033
3134 predicate isKnownLabel ( string label , string humanReadableLabel , EndpointType type ) {
3235 label = "read-file" and
@@ -87,11 +90,9 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
8790 predicate hasMetadata ( Endpoint e , string metadata ) {
8891 exists (
8992 string package , string type , boolean subtypes , string name , string signature , string ext ,
90- int input , string provenance , boolean isPublic , boolean isFinal , boolean isStatic ,
91- string callableJavaDoc
93+ int input , boolean isPublic , boolean isFinal , boolean isStatic
9294 |
93- hasMetadata ( e , package , type , name , signature , input , isFinal , isStatic , isPublic ,
94- callableJavaDoc ) and
95+ hasMetadata ( e , package , type , name , signature , input , isFinal , isStatic , isPublic ) and
9596 ( if isFinal = true or isStatic = true then subtypes = false else subtypes = true ) and
9697 ext = "" and
9798 /*
@@ -100,7 +101,6 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
100101 * a certain annotation.
101102 */
102103
103- provenance = "ai-generated" and
104104 metadata =
105105 "{" //
106106 + "'Package': '" + package //
@@ -109,14 +109,18 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
109109 + ", 'Name': '" + name //
110110 + ", 'ParamName': '" + e .toString ( ) //
111111 + "', 'Signature': '" + signature //
112- + "', 'Ext': '" + ext //
113112 + "', 'Argument index': " + input //
114- + ", 'Provenance': '" + provenance //
115- + "', 'Is public': " + isPublic //
116- + "', 'Callable JavaDoc': '" + callableJavaDoc .replaceAll ( "'" , "\"" ) //
117113 + "'}" // TODO: Why are the curly braces added twice?
118114 )
119115 }
116+
117+ RelatedLocation getRelatedLocation ( Endpoint e , string name ) {
118+ name = "Callable-JavaDoc" and
119+ result = e .getEnclosingCallable ( ) .( Documentable ) .getJavadoc ( )
120+ or
121+ name = "Class-JavaDoc" and
122+ result = e .getEnclosingCallable ( ) .getDeclaringType ( ) .( Documentable ) .getJavadoc ( )
123+ }
120124}
121125
122126module CharacteristicsImpl = SharedCharacteristics:: SharedCharacteristics< CandidatesImpl > ;
@@ -136,7 +140,7 @@ class Endpoint = CandidatesImpl::Endpoint;
136140 */
137141predicate hasMetadata (
138142 Endpoint n , string package , string type , string name , string signature , int input ,
139- boolean isFinal , boolean isStatic , boolean isPublic , string callableJavaDoc
143+ boolean isFinal , boolean isStatic , boolean isPublic
140144) {
141145 exists ( Callable callable |
142146 n .asParameter ( ) = callable .getParameter ( input ) and
@@ -154,10 +158,7 @@ predicate hasMetadata(
154158 ) and
155159 name = callable .getSourceDeclaration ( ) .getName ( ) and
156160 signature = ExternalFlow:: paramsString ( callable ) and // TODO: Why are brackets being escaped (`\[\]` vs `[]`)?
157- ( if callable .isPublic ( ) then isPublic = true else isPublic = false ) and
158- if exists ( callable .( Documentable ) .getJavadoc ( ) )
159- then callableJavaDoc = callable .( Documentable ) .getJavadoc ( ) .toString ( )
160- else callableJavaDoc = ""
161+ ( if callable .isPublic ( ) then isPublic = true else isPublic = false )
161162 )
162163}
163164
0 commit comments