@@ -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 )
@@ -747,6 +771,32 @@ module ModelOutput {
747771 )
748772 }
749773
774+ /**
775+ * Holds if a barrier model contributed `barrier` with the given `kind`.
776+ */
777+ cached
778+ API:: Node getABarrierNode ( string kind , string model ) {
779+ exists ( string type , string path |
780+ barrierModel ( type , path , kind , model ) and
781+ result = getNodeFromPath ( type , path )
782+ )
783+ }
784+
785+ /**
786+ * Holds if a barrier model contributed `barrier` with the given `kind` for the given `branch`.
787+ */
788+ cached
789+ API:: Node getABarrierGuardNode ( string kind , boolean branch , string model ) {
790+ exists ( string type , string path , string branch_str |
791+ branch = true and branch_str = "true"
792+ or
793+ branch = false and branch_str = "false"
794+ |
795+ barrierGuardModel ( type , path , branch_str , kind , model ) and
796+ result = getNodeFromPath ( type , path )
797+ )
798+ }
799+
750800 /**
751801 * Holds if a relevant summary exists for these parameters.
752802 */
@@ -789,15 +839,50 @@ module ModelOutput {
789839 private import codeql.mad.ModelValidation as SharedModelVal
790840
791841 /**
792- * Holds if a CSV source model contributed `source` with the given `kind`.
842+ * Holds if an external model contributed `source` with the given `kind`.
793843 */
794844 API:: Node getASourceNode ( string kind ) { result = getASourceNode ( kind , _) }
795845
796846 /**
797- * Holds if a CSV sink model contributed `sink` with the given `kind`.
847+ * Holds if an external model contributed `sink` with the given `kind`.
798848 */
799849 API:: Node getASinkNode ( string kind ) { result = getASinkNode ( kind , _) }
800850
851+ /**
852+ * Holds if an external model contributed `barrier` with the given `kind`.
853+ *
854+ * INTERNAL: Do not use.
855+ */
856+ API:: Node getABarrierNode ( string kind ) { result = getABarrierNode ( kind , _) }
857+
858+ /**
859+ * Holds if an external model contributed `barrier-guard` with the given `kind` and `branch`.
860+ *
861+ * INTERNAL: Do not use.
862+ */
863+ API:: Node getABarrierGuardNode ( string kind , boolean branch ) {
864+ result = getABarrierGuardNode ( kind , branch , _)
865+ }
866+
867+ /**
868+ * Holds if `node` is specified as a source with the given kind in an external model.
869+ */
870+ predicate sourceNode ( DataFlow:: Node node , string kind ) { node = getASourceNode ( kind ) .asSource ( ) }
871+
872+ /**
873+ * Holds if `node` is specified as a sink with the given kind in an external model.
874+ */
875+ predicate sinkNode ( DataFlow:: Node node , string kind ) { node = getASinkNode ( kind ) .asSink ( ) }
876+
877+ /**
878+ * Holds if `node` is specified as a barrier with the given kind in an external model.
879+ */
880+ predicate barrierNode ( DataFlow:: Node node , string kind ) {
881+ node = getABarrierNode ( kind ) .asSource ( )
882+ or
883+ node = DataFlow:: ExternalBarrierGuard:: getAnExternalBarrierNode ( kind )
884+ }
885+
801886 private module KindValConfig implements SharedModelVal:: KindValidationConfigSig {
802887 predicate summaryKind ( string kind ) { summaryModel ( _, _, _, _, kind , _) }
803888
0 commit comments