@@ -344,6 +344,26 @@ private predicate sinkModel(string type, string path, string kind, string model)
344344 )
345345}
346346
347+ /** Holds if a barrier model exists for the given parameters. */
348+ private predicate barrierModel ( string type , string path , string kind , string model ) {
349+ // No deprecation adapter for barrier models, they were not around back then.
350+ exists ( QlBuiltins:: ExtensionId madId |
351+ Extensions:: barrierModel ( type , path , kind , madId ) and
352+ model = "MaD:" + madId .toString ( )
353+ )
354+ }
355+
356+ /** Holds if a barrier guard model exists for the given parameters. */
357+ private predicate barrierGuardModel (
358+ string type , string path , string branch , string kind , string model
359+ ) {
360+ // No deprecation adapter for barrier models, they were not around back then.
361+ exists ( QlBuiltins:: ExtensionId madId |
362+ Extensions:: barrierGuardModel ( type , path , branch , kind , madId ) and
363+ model = "MaD:" + madId .toString ( )
364+ )
365+ }
366+
347367/** Holds if a summary model `row` exists for the given parameters. */
348368private predicate summaryModel (
349369 string type , string path , string input , string output , string kind , string model
@@ -400,6 +420,8 @@ predicate isRelevantType(string type) {
400420 (
401421 sourceModel ( type , _, _, _) or
402422 sinkModel ( type , _, _, _) or
423+ barrierModel ( type , _, _, _) or
424+ barrierGuardModel ( type , _, _, _, _) or
403425 summaryModel ( type , _, _, _, _, _) or
404426 typeModel ( _, type , _)
405427 ) and
@@ -427,6 +449,8 @@ predicate isRelevantFullPath(string type, string path) {
427449 (
428450 sourceModel ( type , path , _, _) or
429451 sinkModel ( type , path , _, _) or
452+ barrierModel ( type , path , _, _) or
453+ barrierGuardModel ( type , path , _, _, _) or
430454 summaryModel ( type , path , _, _, _, _) or
431455 typeModel ( _, type , path )
432456 )
@@ -745,6 +769,32 @@ module ModelOutput {
745769 )
746770 }
747771
772+ /**
773+ * Holds if a barrier model contributed `barrier` with the given `kind`.
774+ */
775+ cached
776+ API:: Node getABarrierNode ( string kind , string model ) {
777+ exists ( string type , string path |
778+ barrierModel ( type , path , kind , model ) and
779+ result = getNodeFromPath ( type , path )
780+ )
781+ }
782+
783+ /**
784+ * Holds if a barrier model contributed `barrier` with the given `kind` for the given `branch`.
785+ */
786+ cached
787+ API:: Node getABarrierGuardNode ( string kind , boolean branch , string model ) {
788+ exists ( string type , string path , string branch_str |
789+ branch = true and branch_str = "true"
790+ or
791+ branch = false and branch_str = "false"
792+ |
793+ barrierGuardModel ( type , path , branch_str , kind , model ) and
794+ result = getNodeFromPath ( type , path )
795+ )
796+ }
797+
748798 /**
749799 * Holds if a relevant summary exists for these parameters.
750800 */
@@ -787,15 +837,46 @@ module ModelOutput {
787837 private import codeql.mad.ModelValidation as SharedModelVal
788838
789839 /**
790- * Holds if a CSV source model contributed `source` with the given `kind`.
840+ * Holds if an external model contributed `source` with the given `kind`.
791841 */
792842 API:: Node getASourceNode ( string kind ) { result = getASourceNode ( kind , _) }
793843
794844 /**
795- * Holds if a CSV sink model contributed `sink` with the given `kind`.
845+ * Holds if an external model contributed `sink` with the given `kind`.
796846 */
797847 API:: Node getASinkNode ( string kind ) { result = getASinkNode ( kind , _) }
798848
849+ /**
850+ * Holds if an external model contributed `barrier` with the given `kind`.
851+ */
852+ API:: Node getABarrierNode ( string kind ) { result = getABarrierNode ( kind , _) }
853+
854+ /**
855+ * Holds if an external model contributed `barrier-guard` with the given `kind` and `branch`.
856+ */
857+ API:: Node getABarrierGuardNode ( string kind , boolean branch ) {
858+ result = getABarrierGuardNode ( kind , branch , _)
859+ }
860+
861+ /**
862+ * Holds if `node` is specified as a source with the given kind in an external model.
863+ */
864+ predicate sourceNode ( DataFlow:: Node node , string kind ) { node = getASourceNode ( kind ) .asSource ( ) }
865+
866+ /**
867+ * Holds if `node` is specified as a sink with the given kind in an external model.
868+ */
869+ predicate sinkNode ( DataFlow:: Node node , string kind ) { node = getASinkNode ( kind ) .asSink ( ) }
870+
871+ /**
872+ * Holds if `node` is specified as a barrier with the given kind in an external model.
873+ */
874+ predicate barrierNode ( DataFlow:: Node node , string kind ) {
875+ node = getABarrierNode ( kind ) .asSource ( )
876+ or
877+ node = DataFlow:: ExternalBarrierGuard:: getAnExternalBarrierNode ( kind )
878+ }
879+
799880 private module KindValConfig implements SharedModelVal:: KindValidationConfigSig {
800881 predicate summaryKind ( string kind ) { summaryModel ( _, _, _, _, kind , _) }
801882
0 commit comments