From 7094059934b6451d23fcfbde536075362298c68a Mon Sep 17 00:00:00 2001 From: owilliams23 Date: Wed, 26 Aug 2026 17:54:20 -0400 Subject: [PATCH 1/3] #24 resolution --- src/core/validate.ts | 20 +++++++++++++++++--- src/utils/fs.ts | 7 ++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/core/validate.ts b/src/core/validate.ts index ed341b8..c72182d 100644 --- a/src/core/validate.ts +++ b/src/core/validate.ts @@ -191,14 +191,28 @@ export class Validate { * @returns Validation diagnostics with either a success message or errors. */ private async validateCveRecordSchema(cveRecord: JsonObject): Promise { - const validator = await this.cveRecordValidator; - const isValid = validator(cveRecord); + try { + const validator = await this.cveRecordValidator; + const isValid = validator(cveRecord); - return isValid + return isValid ? Diagnostics.success() : Diagnostics.failSchemaValidation(validator.errors ?? []); + } catch (error) { + const message = [ + '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: ${error.message}', + ].join('\n'); + return Diagnostics.failSchemaValidation([message]); + } } + + /** * Validates a CVE record with CVE-specific metadata prechecks before running * AJV JSON schema validation. diff --git a/src/utils/fs.ts b/src/utils/fs.ts index 0b08083..9b629fe 100644 --- a/src/utils/fs.ts +++ b/src/utils/fs.ts @@ -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}`); } /** From a428b40c7e1830f2aa496d98650fac077d9fb960 Mon Sep 17 00:00:00 2001 From: owilliams23 Date: Thu, 27 Aug 2026 09:26:23 -0400 Subject: [PATCH 2/3] bug fixes --- src/core/validate.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/core/validate.ts b/src/core/validate.ts index c72182d..5dc5142 100644 --- a/src/core/validate.ts +++ b/src/core/validate.ts @@ -191,24 +191,23 @@ export class Validate { * @returns Validation diagnostics with either a success message or errors. */ private async validateCveRecordSchema(cveRecord: JsonObject): Promise { + let validator; try { - const validator = await this.cveRecordValidator; - const isValid = validator(cveRecord); + 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 ?? []); - } catch (error) { - const message = [ - '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: ${error.message}', - ].join('\n'); - return Diagnostics.failSchemaValidation([message]); - } } From e18ae55270c0c4a2d77b95c1f5dcb1c7508eccf1 Mon Sep 17 00:00:00 2001 From: owilliams23 Date: Thu, 27 Aug 2026 14:38:15 -0400 Subject: [PATCH 3/3] resolves comment --- src/core/validate.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/validate.ts b/src/core/validate.ts index 5dc5142..00bc3ab 100644 --- a/src/core/validate.ts +++ b/src/core/validate.ts @@ -205,9 +205,9 @@ export class Validate { const isValid = validator(cveRecord); - return isValid - ? Diagnostics.success() - : Diagnostics.failSchemaValidation(validator.errors ?? []); + return isValid + ? Diagnostics.success() + : Diagnostics.failSchemaValidation(validator.errors ?? []); }