From 35bf5392fe6532b8d3305fb863e061b797374584 Mon Sep 17 00:00:00 2001 From: hkong-mitre <122547078+hkong-mitre@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:29:38 -0400 Subject: [PATCH] change the delta.unknown list to delta.error --- src/core/Delta.test.ts | 2 +- src/core/Delta.ts | 24 +++++++++---------- src/core/git.ts | 2 +- .../activityLog/recent_activities.json | 4 ++-- test/fixtures/delta/test_delta.json | 2 +- test/fixtures/delta/test_deltaLog.json | 6 ++--- test/fixtures/delta/test_delta_min.json | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/core/Delta.test.ts b/src/core/Delta.test.ts index 8c13149..8c34131 100644 --- a/src/core/Delta.test.ts +++ b/src/core/Delta.test.ts @@ -105,7 +105,7 @@ describe(`Delta`, () => { const delta = await Delta.newDeltaFromGitHistory(startDate, null, process.env.CVES_TEST_BASE_DIRECTORY); const deltaNow = await Delta.newDeltaFromGitHistory(startDate, new Date().toISOString(), process.env.CVES_TEST_BASE_DIRECTORY); expect(delta.numberOfChanges).toBe(deltaNow.numberOfChanges); - expect(delta.unknown).toEqual(deltaNow.unknown); + expect(delta.error).toEqual(deltaNow.error); await cleanup_TestGitRepository() }); diff --git a/src/core/Delta.ts b/src/core/Delta.ts index 8f47644..0ec5670 100644 --- a/src/core/Delta.ts +++ b/src/core/Delta.ts @@ -28,7 +28,7 @@ export enum DeltaQueue { kNew = 1, kPublished, kUpdated, - kUnknown + kError } /** @@ -63,7 +63,7 @@ export class DeltaOutpuItem { static replacer(key: string, value: any) { let items = []; - if (key === 'new' || key === 'updated' || key === 'unknown') { + if (key === 'new' || key === 'updated' || key === 'error') { value.forEach((item: CveCorePlus) => { // Note, it is important to keep this loop as simple as possible, // don't rely on item being an actual CveCorePlus object since @@ -106,7 +106,7 @@ export class Delta { numberOfChanges: number = 0; new: CveCorePlus[] = []; updated: CveCorePlus[] = []; - unknown?: CveCorePlus[] = []; // for any CVE that is not new or updated, which should never be the case except for errors + error?: CveCorePlus[] = []; // for any CVE that is not new or updated, which should never be the case except for errors // ----- constructor and factory functions ----- ----- @@ -124,7 +124,7 @@ export class Delta { this.new = prevDelta?.new ? cloneDeep(prevDelta.new) : []; // this.published = prevDelta?.published ? cloneDeep(prevDelta.published) : []; this.updated = prevDelta?.updated ? cloneDeep(prevDelta.updated) : []; - this.unknown = prevDelta?.unknown ? cloneDeep(prevDelta.unknown) : []; + this.error = prevDelta?.error ? cloneDeep(prevDelta.error) : []; } } @@ -141,7 +141,7 @@ export class Delta { const delta = await git.logDeltasInTimeWindow(start, stop); // files.forEach(element => { // const tuple = Delta.getCveIdMetaData(element); - // delta.add(new CveCore(tuple[0]), DeltaQueue.kUnknown); + // delta.add(new CveCore(tuple[0]), DeltaQueue.kError); // }); return delta; } @@ -241,7 +241,7 @@ export class Delta { return this.new.length // + this.published.length + this.updated.length - + this.unknown.length; + + this.error.length; } /** adds a cveCore object into one of the queues in a delta object @@ -266,8 +266,8 @@ export class Delta { break; default: if (cve.cveId) { - console.log(`pushing into unknown: ${JSON.stringify(cve)}`); - this.unknown.push(cve); + console.log(`pushing into error list: ${JSON.stringify(cve)}`); + this.error.push(cve); } else { console.log(`ignoring cve=${JSON.stringify(cve)}`); @@ -284,16 +284,16 @@ export class Delta { const updatedCves: string[] = []; this.updated.forEach(item => updatedCves.push(item.cveId.id)); const unkownFiles: string[] = []; - this.unknown.forEach(item => unkownFiles.push(item.cveId.id)); + this.error.forEach(item => unkownFiles.push(item.cveId.id)); let s = `${this.new.length} new | ${this.updated.length} updated`; - if (this.unknown.length > 0) { - s += ` | ${this.unknown.length} other files`; + if (this.error.length > 0) { + s += ` | ${this.error.length} other files`; } const retstr = `${this.numberOfChanges} changes (${s}): - ${this.new.length} new CVEs: ${newCves.join(', ')} - ${this.updated.length} updated CVEs: ${updatedCves.join(', ')} - ${this.unknown.length > 0 ? `- ${this.unknown.length} other files: ${unkownFiles.join(', ')}` : ``} + ${this.error.length > 0 ? `- ${this.error.length} other files: ${unkownFiles.join(', ')}` : ``} `; return retstr; } diff --git a/src/core/git.ts b/src/core/git.ts index 4c3cb67..4e1010f 100644 --- a/src/core/git.ts +++ b/src/core/git.ts @@ -174,7 +174,7 @@ export class Git { delta.add(CveCorePlus.fromJsonFile(path), DeltaQueue.kUpdated); break; default: - delta.add(CveCorePlus.fromJsonFile(path), DeltaQueue.kUnknown); + delta.add(CveCorePlus.fromJsonFile(path), DeltaQueue.kError); break; } } diff --git a/test/fixtures/activityLog/recent_activities.json b/test/fixtures/activityLog/recent_activities.json index 62f8d95..f863bac 100644 --- a/test/fixtures/activityLog/recent_activities.json +++ b/test/fixtures/activityLog/recent_activities.json @@ -15,7 +15,7 @@ "cveId": "CVE-2023-31996" } ], - "unknown": [] + "error": [] }, "steps": [ { @@ -71,7 +71,7 @@ "cveId": "CVE-2022-46945" } ], - "unknown": [] + "error": [] }, "steps": [ { diff --git a/test/fixtures/delta/test_delta.json b/test/fixtures/delta/test_delta.json index 4a2e2c4..ac05d8d 100644 --- a/test/fixtures/delta/test_delta.json +++ b/test/fixtures/delta/test_delta.json @@ -16,5 +16,5 @@ "dateUpdated": "1970-01-01T01:02:00.000Z" } ], - "unknown": [] + "error": [] } \ No newline at end of file diff --git a/test/fixtures/delta/test_deltaLog.json b/test/fixtures/delta/test_deltaLog.json index fe4d335..80fc6ab 100644 --- a/test/fixtures/delta/test_deltaLog.json +++ b/test/fixtures/delta/test_deltaLog.json @@ -17,7 +17,7 @@ "dateUpdated": "2023-07-24T17:32:04.394Z" } ], - "unknown": [] + "error": [] }, { "fetchTime": "2023-07-24T17:14:04.394Z", @@ -38,7 +38,7 @@ "dateUpdated": "2023-07-24T17:12:04.394Z" } ], - "unknown": [] + "error": [] }, { "fetchTime": "2023-07-24T17:02:00.394Z", @@ -52,6 +52,6 @@ } ], "updated": [], - "unknown": [] + "error": [] } ] \ No newline at end of file diff --git a/test/fixtures/delta/test_delta_min.json b/test/fixtures/delta/test_delta_min.json index 629a5e5..ce0ad80 100644 --- a/test/fixtures/delta/test_delta_min.json +++ b/test/fixtures/delta/test_delta_min.json @@ -11,5 +11,5 @@ "cveId": "CVE-2023-3321" } ], - "unknown": [] + "error": [] } \ No newline at end of file