Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/core/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,27 @@ export class Validate {
* @returns Validation diagnostics with either a success message or errors.
*/
private async validateCveRecordSchema(cveRecord: JsonObject): Promise<Diagnostics> {
const validator = await this.cveRecordValidator;
let validator;
try {
validator = await this.cveRecordValidator;

} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);

return Diagnostics.failSchemaValidation([
`Error: ${errorMessage}`,
]);
}

const isValid = validator(cveRecord);

return isValid
? Diagnostics.success()
: Diagnostics.failSchemaValidation(validator.errors ?? []);
? Diagnostics.success()
: Diagnostics.failSchemaValidation(validator.errors ?? []);
}



/**
* Validates a CVE record with CVE-specific metadata prechecks before running
* AJV JSON schema validation.
Expand Down
7 changes: 6 additions & 1 deletion src/utils/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export async function resolveExistingPath(
}

const checkedPaths = candidates.join(', ');
throw new Error(`Unable to find ${fileName}. Checked: ${checkedPaths}`);
throw new Error(`CVE Validation Library failed to validate CVE data.

Try using npm to reinstall the library. If that does not work, file an issue in the repository:
https://github.com/CVEProject/cve-validation-library/issues/new

Error: Unable to find ${fileName}. Checked: ${checkedPaths}`);
}

/**
Expand Down