@@ -21,6 +21,9 @@ signature module InputSig<LocationSig Location, DF::InputSig<Location> Lang> {
2121 string toString ( ) ;
2222 }
2323
24+ /** Holds if a generated summary is allowed for `c`. */
25+ default predicate allowGeneratedSummary ( SummarizedCallableBase c ) { any ( ) }
26+
2427 /**
2528 * A base class of elements that are candidates for flow source modeling.
2629 */
@@ -289,55 +292,25 @@ module Make<
289292 *
290293 * `preservesValue` indicates whether this is a value-preserving step or a taint-step.
291294 *
292- * If `model` is non-empty then it indicates the provenance of the model
293- * defining this flow.
295+ * `p` indicates the provenance of the flow.
296+ *
297+ * `isExact` indicates whether there exists a model for which this callable is an exact
298+ * match, that is, no overriding was used to identify this callable from the model.
299+ *
300+ * If `model` is non-empty then it indicates the origin of the model defining this flow.
294301 */
295302 pragma [ nomagic]
296303 abstract predicate propagatesFlow (
297- string input , string output , boolean preservesValue , string model
304+ string input , string output , boolean preservesValue , Provenance p , boolean isExact ,
305+ string model
298306 ) ;
299307
300- /**
301- * Holds if there exists a generated summary that applies to this callable.
302- */
303- final predicate hasGeneratedModel ( ) {
304- exists ( Provenance p | p .isGenerated ( ) and this .hasProvenance ( p ) )
305- }
306-
307- /**
308- * Holds if all the summaries that apply to this callable are auto generated and not manually created.
309- * That is, only apply generated models, when there are no manual models.
310- */
311- final predicate applyGeneratedModel ( ) {
312- this .hasGeneratedModel ( ) and
313- not this .hasManualModel ( )
314- }
315-
316308 /**
317309 * Holds if there exists a manual summary that applies to this callable.
318310 */
319311 final predicate hasManualModel ( ) {
320- exists ( Provenance p | p . isManual ( ) and this . hasProvenance ( p ) )
312+ any ( Provenance p | this . propagatesFlow ( _ , _ , _ , p , _ , _ ) ) . isManual ( )
321313 }
322-
323- /**
324- * Holds if there exists a manual summary that applies to this callable.
325- * Always apply manual models if they exist.
326- */
327- final predicate applyManualModel ( ) { this .hasManualModel ( ) }
328-
329- /**
330- * Holds if there exists a summary that applies to this callable
331- * that has provenance `provenance`.
332- */
333- predicate hasProvenance ( Provenance provenance ) { provenance = "manual" }
334-
335- /**
336- * Holds if there exists a model for which this callable is an exact
337- * match, that is, no overriding was used to identify this callable from
338- * the model.
339- */
340- predicate hasExactModel ( ) { none ( ) }
341314 }
342315
343316 /** A source element. */
@@ -647,7 +620,7 @@ module Make<
647620 SummarizedCallableImpl callable , SummaryComponentStack input , SummaryComponentStack output ,
648621 string whichOne
649622 ) {
650- callable .propagatesFlow ( input , output , _, _) and
623+ callable .propagatesFlow ( input , output , _, _, _ , _ ) and
651624 (
652625 not isSupportedInputStack ( input ) and whichOne = "input"
653626 or
@@ -688,9 +661,9 @@ module Make<
688661
689662 private predicate summarySpec ( string spec ) {
690663 exists ( SummarizedCallable c |
691- c .propagatesFlow ( spec , _, _, _)
664+ c .propagatesFlow ( spec , _, _, _, _ , _ )
692665 or
693- c .propagatesFlow ( _, spec , _, _)
666+ c .propagatesFlow ( _, spec , _, _, _ , _ )
694667 )
695668 or
696669 isRelevantSource ( _, spec , _, _, _)
@@ -857,13 +830,9 @@ module Make<
857830 *
858831 * ```ql
859832 * private class CAdapter extends SummarizedCallable instanceof C {
860- * override predicate propagatesFlow(string input, string output, boolean preservesValue, string model) {
833+ * override predicate propagatesFlow(string input, string output, boolean preservesValue, Provenance p, string model) {
861834 * none()
862835 * }
863- *
864- * override predicate hasProvenance(Provenance provenance) {
865- * C.super.hasProvenance(provenance)
866- * }
867836 * }
868837 * ```
869838 */
@@ -897,32 +866,26 @@ module Make<
897866 pragma [ nomagic]
898867 abstract predicate propagatesFlow (
899868 SummaryComponentStack input , SummaryComponentStack output , boolean preservesValue ,
900- string model
869+ Provenance p , boolean isExact , string model
901870 ) ;
902-
903- /**
904- * Holds if there exists a summary that applies to this callable
905- * that has provenance `provenance`.
906- */
907- abstract predicate hasProvenance ( Provenance provenance ) ;
908871 }
909872
910873 pragma [ nomagic]
911874 private predicate summary (
912875 SummarizedCallableImpl c , SummaryComponentStack input , SummaryComponentStack output ,
913876 boolean preservesValue , string model
914877 ) {
915- c .propagatesFlow ( input , output , preservesValue , model )
878+ c .propagatesFlow ( input , output , preservesValue , _ , _ , model )
916879 or
917880 // observe side effects of callbacks on input arguments
918- c .propagatesFlow ( output , input , preservesValue , model ) and
881+ c .propagatesFlow ( output , input , preservesValue , _ , _ , model ) and
919882 preservesValue = true and
920883 isCallbackParameter ( input ) and
921884 isContentOfArgument ( output , _)
922885 or
923886 // flow from the receiver of a callback into the instance-parameter
924887 exists ( SummaryComponentStack s , SummaryComponentStack callbackRef |
925- c .propagatesFlow ( s , _, _, model ) or c .propagatesFlow ( _, s , _, model )
888+ c .propagatesFlow ( s , _, _, _ , _ , model ) or c .propagatesFlow ( _, s , _ , _ , _, model )
926889 |
927890 callbackRef = s .drop ( _) and
928891 ( isCallbackParameter ( callbackRef ) or callbackRef .head ( ) = TReturnSummaryComponent ( _) ) and
@@ -948,8 +911,8 @@ module Make<
948911 SummaryComponentStack mid , boolean preservesValue1 , boolean preservesValue2 , string model1 ,
949912 string model2
950913 |
951- c .propagatesFlow ( input , mid , preservesValue1 , model1 ) and
952- c .propagatesFlow ( mid , output , preservesValue2 , model2 ) and
914+ c .propagatesFlow ( input , mid , preservesValue1 , _ , _ , model1 ) and
915+ c .propagatesFlow ( mid , output , preservesValue2 , _ , _ , model2 ) and
953916 mid .drop ( mid .length ( ) - 2 ) =
954917 SummaryComponentStack:: push ( TParameterSummaryComponent ( _) ,
955918 SummaryComponentStack:: singleton ( TArgumentSummaryComponent ( _) ) ) and
@@ -2048,18 +2011,25 @@ module Make<
20482011 {
20492012 override predicate propagatesFlow (
20502013 SummaryComponentStack input , SummaryComponentStack output , boolean preservesValue ,
2051- string model
2014+ Provenance p , boolean isExact , string model
20522015 ) {
20532016 exists ( AccessPath inSpec , AccessPath outSpec |
2054- SummarizedCallable .super .propagatesFlow ( inSpec , outSpec , preservesValue , model ) and
2017+ SummarizedCallable .super
2018+ .propagatesFlow ( inSpec , outSpec , preservesValue , p , isExact , model ) and
20552019 interpretSpec ( inSpec , input ) and
20562020 interpretSpec ( outSpec , output )
2021+ |
2022+ p .isManual ( )
2023+ or
2024+ p .isGenerated ( ) and
2025+ not exists ( Provenance manual | manual .isManual ( ) |
2026+ SummarizedCallable .super .propagatesFlow ( _, _, _, manual , _, _)
2027+ or
2028+ neutralElement ( this , "summary" , manual , _)
2029+ ) and
2030+ allowGeneratedSummary ( this )
20572031 )
20582032 }
2059-
2060- override predicate hasProvenance ( Provenance provenance ) {
2061- SummarizedCallable .super .hasProvenance ( provenance )
2062- }
20632033 }
20642034
20652035 /** Holds if component `c` of specification `spec` cannot be parsed. */
@@ -2492,7 +2462,8 @@ module Make<
24922462 string getCallableCsv ( ) ;
24932463
24942464 predicate relevantSummary (
2495- SummaryComponentStack input , SummaryComponentStack output , boolean preservesValue
2465+ SummaryComponentStack input , SummaryComponentStack output , boolean preservesValue ,
2466+ Provenance p
24962467 ) ;
24972468 }
24982469
@@ -2505,13 +2476,6 @@ module Make<
25052476 preservesValue = false and result = "taint"
25062477 }
25072478
2508- private string renderProvenance ( SummarizedCallable c ) {
2509- exists ( Provenance p | p .isManual ( ) and c .hasProvenance ( p ) and result = p .toString ( ) )
2510- or
2511- not c .applyManualModel ( ) and
2512- c .hasProvenance ( result )
2513- }
2514-
25152479 /**
25162480 * Holds if there exists a relevant summary callable with information roughly corresponding to `csv`.
25172481 * Used for testing.
@@ -2521,15 +2485,15 @@ module Make<
25212485 query predicate summary ( string csv ) {
25222486 exists (
25232487 RelevantSummarizedCallable c , SummaryComponentStack input , SummaryComponentStack output ,
2524- boolean preservesValue
2488+ boolean preservesValue , Provenance p
25252489 |
2526- c .relevantSummary ( input , output , preservesValue ) and
2490+ c .relevantSummary ( input , output , preservesValue , p ) and
25272491 csv =
25282492 c .getCallableCsv ( ) // Callable information
25292493 + input .getMadRepresentation ( ) + ";" // input
25302494 + output .getMadRepresentation ( ) + ";" // output
25312495 + renderKind ( preservesValue ) + ";" // kind
2532- + renderProvenance ( c ) // provenance
2496+ + p // provenance
25332497 )
25342498 }
25352499 }
0 commit comments