@@ -364,25 +364,53 @@ function parseQueriesFromInput(
364364/**
365365 * Combines queries from various configuration sources.
366366 *
367- * @param augmentedConfig The loaded configuration file (either `config-file` or `config` input).
367+ * @param config The loaded configuration file (either `config-file` or `config` input).
368368 * @param augmentationProperties Additional configuration data from other sources.
369369 * @returns Returns `augmentedConfig` with `queries` set to the computed array of queries.
370370 */
371371function combineQueries (
372- augmentedConfig : UserConfig ,
372+ config : UserConfig ,
373373 augmentationProperties : AugmentationProperties ,
374- ) : QuerySpec [ ] | undefined {
374+ ) : QuerySpec [ ] {
375+ const result : QuerySpec [ ] = [ ] ;
376+
377+ // Query settings obtained from the repository properties have the highest precedence.
378+ if (
379+ augmentationProperties . repoPropertyQueries &&
380+ augmentationProperties . repoPropertyQueries . input
381+ ) {
382+ // If there are queries configured as a repository property, these may be organisational
383+ // settings. If they don't allow combining with other query configurations, return just the
384+ // ones configured in the repository properties.
385+ if ( ! augmentationProperties . repoPropertyQueries . combines ) {
386+ return augmentationProperties . repoPropertyQueries . input ;
387+ } else {
388+ // Otherwise, add them to the query array and continue.
389+ result . push ( ...augmentationProperties . repoPropertyQueries . input ) ;
390+ }
391+ }
392+
393+ // If there is a `queries` input to the Action, it has the next highest precedence.
375394 if ( augmentationProperties . queriesInput ) {
376- if ( augmentationProperties . queriesInputCombines ) {
377- return ( augmentedConfig . queries || [ ] ) . concat (
378- augmentationProperties . queriesInput ,
379- ) ;
395+ // If there is a `queries` input and `queriesInputCombines` is `false`, then we don't
396+ // combine it with the queries configured in the configuration file (if any). That is the
397+ // original behaviour of this property. However, we DO combine it with any queries that
398+ // we obtained from the repository properties, since that may be enforced by the organisation.
399+ if ( ! augmentationProperties . queriesInputCombines ) {
400+ return result . concat ( augmentationProperties . queriesInput ) ;
380401 } else {
381- return augmentationProperties . queriesInput ;
402+ // If they combine, add them to the query array and continue.
403+ result . push ( ...augmentationProperties . queriesInput ) ;
382404 }
383405 }
384406
385- return augmentedConfig . queries ;
407+ // If we get to this point, we either don't have any extra configuration inputs or all of them
408+ // allow themselves to be combined with the settings from the configuration file.
409+ if ( config . queries ) {
410+ result . push ( ...config . queries ) ;
411+ }
412+
413+ return result ;
386414}
387415
388416export function generateCodeScanningConfig (
0 commit comments