mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Merge remote-tracking branch 'origin/main' into mbg/config/merge
This commit is contained in:
11
lib/entry-points.js
generated
11
lib/entry-points.js
generated
@@ -144536,11 +144536,14 @@ function array(validator) {
|
||||
for (const e of val) {
|
||||
const elementPath = `${path29}[${index2}]`;
|
||||
const eResult = validator.check(e, opts, `${elementPath}`);
|
||||
result.invalidKeys.push(...eResult.invalidKeys);
|
||||
result.unknownKeys.push(...eResult.unknownKeys);
|
||||
index2++;
|
||||
if (!eResult.valid) {
|
||||
result.valid = false;
|
||||
result.invalidKeys.push(elementPath);
|
||||
if (eResult.invalidKeys.length === 0) {
|
||||
result.invalidKeys.push(elementPath);
|
||||
}
|
||||
if (opts.failFast) {
|
||||
return result;
|
||||
}
|
||||
@@ -144623,14 +144626,14 @@ function checkSchema(schema, obj, options = {}, path29 = "") {
|
||||
if (validator.required && !hasKey) {
|
||||
result.valid = false;
|
||||
if (options.failFast) {
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (validator.required && (obj[key] === void 0 || obj[key] === null)) {
|
||||
result.valid = false;
|
||||
if (options.failFast) {
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -144644,7 +144647,7 @@ function checkSchema(schema, obj, options = {}, path29 = "") {
|
||||
if (!checkResult.valid) {
|
||||
result.valid = false;
|
||||
if (options.failFast) {
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ const checkSchemaTestSchema = {
|
||||
rootKey: json.object(objectSchema),
|
||||
};
|
||||
|
||||
test("validateSchema - checkSchema reports unknown keys", async (t) => {
|
||||
test("checkSchema - reports unknown keys", async (t) => {
|
||||
const result = json.checkSchema(checkSchemaTestSchema, {
|
||||
rootKey: {
|
||||
objectKey: {
|
||||
@@ -125,7 +125,7 @@ test("validateSchema - checkSchema reports unknown keys", async (t) => {
|
||||
);
|
||||
});
|
||||
|
||||
test("validateSchema - checkSchema reports invalid keys", async (t) => {
|
||||
test("checkSchema - reports invalid keys", async (t) => {
|
||||
const result = json.checkSchema(checkSchemaTestSchema, {
|
||||
rootKey: {
|
||||
objectKey: {
|
||||
|
||||
@@ -104,12 +104,18 @@ export function array<T>(validator: Validator<T>) {
|
||||
const elementPath = `${path}[${index}]`;
|
||||
const eResult = validator.check(e, opts, `${elementPath}`);
|
||||
|
||||
result.invalidKeys.push(...eResult.invalidKeys);
|
||||
result.unknownKeys.push(...eResult.unknownKeys);
|
||||
index++;
|
||||
|
||||
if (!eResult.valid) {
|
||||
result.valid = false;
|
||||
result.invalidKeys.push(elementPath);
|
||||
|
||||
// Add the element path to `invalidKeys` if we didn't get
|
||||
// any more specific ones from the element validator.
|
||||
if (eResult.invalidKeys.length === 0) {
|
||||
result.invalidKeys.push(elementPath);
|
||||
}
|
||||
|
||||
if (opts.failFast) {
|
||||
return result;
|
||||
@@ -258,9 +264,16 @@ export function checkSchema<S extends Schema>(
|
||||
path: string = "",
|
||||
): CheckSchemaResult {
|
||||
const result: CheckSchemaResult = successfulCheckSchema();
|
||||
|
||||
// Track the set of input keys. We remove keys from this set as we recognise them
|
||||
// during validation.
|
||||
const inputKeys = new Set(Object.keys(obj));
|
||||
|
||||
// Track keys that have failed validation, starting with the empty set.
|
||||
const invalidKeys = new Set();
|
||||
|
||||
// Loop through all keys in the object schema and validate that the given object
|
||||
// satisfies the schema key.
|
||||
for (const [key, validator] of Object.entries(schema)) {
|
||||
const hasKey = key in obj;
|
||||
|
||||
@@ -276,7 +289,7 @@ export function checkSchema<S extends Schema>(
|
||||
result.valid = false;
|
||||
|
||||
if (options.failFast) {
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -286,7 +299,7 @@ export function checkSchema<S extends Schema>(
|
||||
result.valid = false;
|
||||
|
||||
if (options.failFast) {
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -308,7 +321,7 @@ export function checkSchema<S extends Schema>(
|
||||
result.valid = false;
|
||||
|
||||
if (options.failFast) {
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user