76
76
private import go
77
77
import internal.ExternalFlowExtensions
78
78
private import internal.DataFlowPrivate
79
+ private import internal.FlowSummaryImpl
80
+ private import internal.FlowSummaryImpl:: Private
79
81
private import internal.FlowSummaryImpl:: Private:: External
80
- private import internal.FlowSummaryImplSpecific
81
- private import internal.AccessPathSyntax
82
- private import FlowSummary
82
+ private import internal.FlowSummaryImpl:: Public
83
83
private import codeql.mad.ModelValidation as SharedModelVal
84
84
85
85
/** Holds if `package` have MaD framework coverage. */
@@ -274,7 +274,7 @@ private string interpretPackage(string p) {
274
274
}
275
275
276
276
/** Gets the source/sink/summary element corresponding to the supplied parameters. */
277
- SourceOrSinkElement interpretElement (
277
+ SourceSinkInterpretationInput :: SourceOrSinkElement interpretElement (
278
278
string pkg , string type , boolean subtypes , string name , string signature , string ext
279
279
) {
280
280
elementSpec ( pkg , type , subtypes , name , signature , ext ) and
@@ -298,8 +298,9 @@ SourceOrSinkElement interpretElement(
298
298
predicate hasExternalSpecification ( Function f ) {
299
299
f = any ( SummarizedCallable sc ) .asFunction ( )
300
300
or
301
- exists ( SourceOrSinkElement e | f = e .asEntity ( ) |
302
- sourceElement ( e , _, _, _) or sinkElement ( e , _, _, _)
301
+ exists ( SourceSinkInterpretationInput:: SourceOrSinkElement e | f = e .asEntity ( ) |
302
+ SourceSinkInterpretationInput:: sourceElement ( e , _, _) or
303
+ SourceSinkInterpretationInput:: sinkElement ( e , _, _)
303
304
)
304
305
}
305
306
@@ -353,7 +354,9 @@ private module Cached {
353
354
*/
354
355
cached
355
356
predicate sourceNode ( DataFlow:: Node node , string kind ) {
356
- exists ( InterpretNode n | isSourceNode ( n , kind ) and n .asNode ( ) = node )
357
+ exists ( SourceSinkInterpretationInput:: InterpretNode n |
358
+ isSourceNode ( n , kind ) and n .asNode ( ) = node
359
+ )
357
360
}
358
361
359
362
/**
@@ -362,8 +365,71 @@ private module Cached {
362
365
*/
363
366
cached
364
367
predicate sinkNode ( DataFlow:: Node node , string kind ) {
365
- exists ( InterpretNode n | isSinkNode ( n , kind ) and n .asNode ( ) = node )
368
+ exists ( SourceSinkInterpretationInput:: InterpretNode n |
369
+ isSinkNode ( n , kind ) and n .asNode ( ) = node
370
+ )
366
371
}
367
372
}
368
373
369
374
import Cached
375
+
376
+ private predicate interpretSummary (
377
+ Callable c , string input , string output , string kind , string provenance
378
+ ) {
379
+ exists (
380
+ string namespace , string type , boolean subtypes , string name , string signature , string ext
381
+ |
382
+ summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind , provenance ) and
383
+ c .asFunction ( ) = interpretElement ( namespace , type , subtypes , name , signature , ext ) .asEntity ( )
384
+ )
385
+ }
386
+
387
+ private class SummarizedCallableAdapter extends SummarizedCallable {
388
+ SummarizedCallableAdapter ( ) { interpretSummary ( this , _, _, _, _) }
389
+
390
+ private predicate relevantSummaryElementManual ( string input , string output , string kind ) {
391
+ exists ( Provenance provenance |
392
+ interpretSummary ( this , input , output , kind , provenance ) and
393
+ provenance .isManual ( )
394
+ )
395
+ }
396
+
397
+ private predicate relevantSummaryElementGenerated ( string input , string output , string kind ) {
398
+ exists ( Provenance provenance |
399
+ interpretSummary ( this , input , output , kind , provenance ) and
400
+ provenance .isGenerated ( )
401
+ )
402
+ }
403
+
404
+ override predicate propagatesFlow ( string input , string output , boolean preservesValue ) {
405
+ exists ( string kind |
406
+ this .relevantSummaryElementManual ( input , output , kind )
407
+ or
408
+ not this .relevantSummaryElementManual ( _, _, _) and
409
+ this .relevantSummaryElementGenerated ( input , output , kind )
410
+ |
411
+ if kind = "value" then preservesValue = true else preservesValue = false
412
+ )
413
+ }
414
+
415
+ override predicate hasProvenance ( Provenance provenance ) {
416
+ interpretSummary ( this , _, _, _, provenance )
417
+ }
418
+ }
419
+
420
+ private class NeutralCallableAdapter extends NeutralCallable {
421
+ string kind ;
422
+ string provenance_ ;
423
+
424
+ NeutralCallableAdapter ( ) {
425
+ // Neutral models have not been implemented for Go.
426
+ none ( ) and
427
+ exists ( this ) and
428
+ exists ( kind ) and
429
+ exists ( provenance_ )
430
+ }
431
+
432
+ override string getKind ( ) { result = kind }
433
+
434
+ override predicate hasProvenance ( Provenance provenance ) { provenance = provenance_ }
435
+ }
0 commit comments