-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.ts
More file actions
33 lines (28 loc) · 1.59 KB
/
Copy pathmain.ts
File metadata and controls
33 lines (28 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Validate, readJsonFile, type Diagnostics, type JsonObject } from '@cveproject/cve-validation-library';
const validator = new Validate();
const exampleValidCveRecord = await readJsonFile(
'./scripts/test-data/cve-record-valid.json',
) as JsonObject;
console.log('1. Attemping to validate a valid CVE Record');
const cveRecordResult: Diagnostics = await validator.validateCveRecord(exampleValidCveRecord);
console.log(JSON.stringify(cveRecordResult, null, 2));
console.log('\n2. Attemping to validate an invalid CVE Record');
const exampleInvalidCveRecord = await readJsonFile(
'./scripts/test-data/cve-record-invalid-datePublic-future-date.json',
) as JsonObject;
const invalidCveRecordResult: Diagnostics = await validator.validateCveRecord(exampleInvalidCveRecord);
console.log(JSON.stringify(invalidCveRecordResult, null, 2));
console.log('\n3. Attemping to validate an invalid Published CNA container')
const exampleInvalidPublishedCnaContainer: JsonObject = {
"providerMetadata": {
"test": "This will fail against validation."
}
}
const publishedCnaContainerResult: Diagnostics = await validator.validatePublishedCveCnaContainer(exampleInvalidPublishedCnaContainer);
console.log(JSON.stringify(publishedCnaContainerResult, null, 2));
console.log('\n4. Attemping to validate an invalid Rejected CNA container')
const exampleInvalidRejectedCnaContainer: JsonObject = {
"cnaContainer": {}
}
const rejectedCnaContainerResult: Diagnostics = await validator.validateRejectedCveCnaContainer(exampleInvalidRejectedCnaContainer);
console.log(JSON.stringify(rejectedCnaContainerResult, null, 2));