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:
Henry Mercer
2026-10-02 14:24:04 +01:00
co-authored by Copilot App
parent 1c0814d7d2
commit e869836b5a
2 changed files with 18 additions and 6 deletions
+5 -3
View File
@@ -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
View File
@@ -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>,
);