mirror of
https://github.com/github/codeql-action
synced 2026-10-07 00:30:17 +03:00
Share the check of the properties that Default Setup sets in the config input
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot App
parent
1c0814d7d2
commit
e869836b5a
Generated
+5
-3
@@ -149268,6 +149268,9 @@ var DEFAULT_SETUP_CONFIG_SCHEMA = {
|
||||
object(DEFAULT_SETUP_SCHEMA)
|
||||
)
|
||||
};
|
||||
function checkDefaultSetupConfig(config) {
|
||||
return checkSchema(DEFAULT_SETUP_CONFIG_SCHEMA, config);
|
||||
}
|
||||
function matchesDefaultSetupConfigSchema(contents) {
|
||||
let config;
|
||||
try {
|
||||
@@ -149281,15 +149284,14 @@ function matchesDefaultSetupConfigSchema(contents) {
|
||||
if (!isObject(config)) {
|
||||
return false;
|
||||
}
|
||||
const result = checkSchema(DEFAULT_SETUP_CONFIG_SCHEMA, config);
|
||||
const result = checkDefaultSetupConfig(config);
|
||||
return result.valid && result.unknownKeys.length === 0;
|
||||
}
|
||||
function mergeDefaultSetupAndUserConfigs(logger, fromConfigInput, fromConfigFile) {
|
||||
logger.debug(
|
||||
"Combining configuration files from 'config' and 'config-file' inputs"
|
||||
);
|
||||
const schemaCheckResult = checkSchema(
|
||||
DEFAULT_SETUP_CONFIG_SCHEMA,
|
||||
const schemaCheckResult = checkDefaultSetupConfig(
|
||||
fromConfigInput
|
||||
);
|
||||
if (schemaCheckResult.invalidKeys.length > 0) {
|
||||
|
||||
+13
-3
@@ -94,6 +94,17 @@ const DEFAULT_SETUP_CONFIG_SCHEMA = {
|
||||
),
|
||||
} as const satisfies json.Schema;
|
||||
|
||||
/**
|
||||
* Checks `config` against the properties that Default Setup sets in the `config` input. The result
|
||||
* lists any other properties in `unknownKeys`, and any properties with invalid values in
|
||||
* `invalidKeys`.
|
||||
*/
|
||||
function checkDefaultSetupConfig(
|
||||
config: json.UnvalidatedObject<any>,
|
||||
): json.CheckSchemaResult {
|
||||
return json.checkSchema(DEFAULT_SETUP_CONFIG_SCHEMA, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether `contents` is a YAML mapping that only sets the properties that Default Setup
|
||||
* uses, which are threat models and model packs, to valid values. Returns `false` otherwise,
|
||||
@@ -112,7 +123,7 @@ export function matchesDefaultSetupConfigSchema(contents: string): boolean {
|
||||
if (!json.isObject(config)) {
|
||||
return false;
|
||||
}
|
||||
const result = json.checkSchema(DEFAULT_SETUP_CONFIG_SCHEMA, config);
|
||||
const result = checkDefaultSetupConfig(config);
|
||||
return result.valid && result.unknownKeys.length === 0;
|
||||
}
|
||||
|
||||
@@ -138,8 +149,7 @@ export function mergeDefaultSetupAndUserConfigs(
|
||||
// Check for unexpected keys in the configuration from the `config` input
|
||||
// that was provided by Default Setup. This should only contain the keys
|
||||
// we would expect to receive from Default Setup.
|
||||
const schemaCheckResult = json.checkSchema(
|
||||
DEFAULT_SETUP_CONFIG_SCHEMA,
|
||||
const schemaCheckResult = checkDefaultSetupConfig(
|
||||
fromConfigInput as json.UnvalidatedObject<any>,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user