Skip to content

Commit 68309a7

Browse files
Minor bug fixes
1 parent e7f100c commit 68309a7

File tree

3 files changed

+197
-157
lines changed

3 files changed

+197
-157
lines changed

client/src/app/pages/import-processing/tenable-import/components/iavVulnerabilities/tenableIAVVulnerabilities.component.ts

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -488,32 +488,37 @@ export class TenableIAVVulnerabilitiesComponent implements OnInit, OnDestroy {
488488
this.showDetails(vulnerability);
489489
}
490490

491-
showDetails(vulnerability: any, createPoam: boolean = false) {
491+
showDetails(vulnerability: any, createPoam: boolean = false): Promise<void> {
492492
if (!vulnerability || !vulnerability.pluginID) {
493493
this.showErrorMessage('Invalid vulnerability data');
494-
return;
494+
return Promise.reject('Invalid vulnerability data');
495495
}
496496

497-
this.importService.getTenablePlugin(vulnerability.pluginID)
498-
.subscribe({
499-
next: (data) => {
500-
if (!data || !data.response) {
501-
throw new Error('Invalid response from getTenablePlugin');
502-
}
503-
504-
this.pluginData = data.response;
505-
this.processPluginData();
506-
this.selectedVulnerability = vulnerability;
507-
508-
if (!createPoam) {
509-
this.displayDialog = true;
497+
return new Promise((resolve, reject) => {
498+
this.importService.getTenablePlugin(vulnerability.pluginID)
499+
.subscribe({
500+
next: (data) => {
501+
if (!data || !data.response) {
502+
reject(new Error('Invalid response from getTenablePlugin'));
503+
return;
504+
}
505+
506+
this.pluginData = data.response;
507+
this.processPluginData();
508+
this.selectedVulnerability = vulnerability;
509+
510+
if (!createPoam) {
511+
this.displayDialog = true;
512+
}
513+
resolve();
514+
},
515+
error: (error) => {
516+
console.error('Error fetching plugin data:', error);
517+
this.showErrorMessage('Error fetching plugin data. Please try again.');
518+
reject(error);
510519
}
511-
},
512-
error: (error) => {
513-
console.error('Error fetching plugin data:', error);
514-
this.showErrorMessage('Error fetching plugin data. Please try again.');
515-
}
516-
});
520+
});
521+
});
517522
}
518523

519524
private processPluginData() {
@@ -540,18 +545,31 @@ export class TenableIAVVulnerabilitiesComponent implements OnInit, OnDestroy {
540545

541546
async onPoamIconClick(vulnerability: any, event: Event) {
542547
event.stopPropagation();
543-
if (vulnerability.poam && vulnerability.poamId) {
544-
this.router.navigateByUrl(`/poam-processing/poam-details/${vulnerability.poamId}`);
545-
} else {
548+
try {
549+
if (vulnerability.poam && vulnerability.poamId) {
550+
this.router.navigateByUrl(`/poam-processing/poam-details/${vulnerability.poamId}`);
551+
return;
552+
}
553+
546554
await this.showDetails(vulnerability, true);
555+
556+
if (!this.pluginData) {
557+
throw new Error('Plugin data not available');
558+
}
559+
560+
const formattedDate = vulnerability.navyComplyDate ? format(vulnerability.navyComplyDate, 'yyyy-MM-dd') : null;
561+
547562
this.router.navigate(['/poam-processing/poam-details/ADDPOAM'], {
548563
state: {
549564
vulnerabilitySource: 'Assured Compliance Assessment Solution (ACAS) Nessus Scanner',
550565
pluginData: this.pluginData,
551566
iavNumber: vulnerability.iav,
552-
iavComplyByDate: vulnerability.navyComplyDate,
567+
iavComplyByDate: formattedDate,
553568
},
554569
});
570+
} catch (error) {
571+
console.error('Error in onPoamIconClick:', error);
572+
this.showErrorMessage('Error processing vulnerability data. Please try again.');
555573
}
556574
}
557575

client/src/app/pages/import-processing/tenable-import/tenableVulnerabilities.component.ts

Lines changed: 74 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,28 +2315,38 @@ export class TenableVulnerabilitiesComponent implements OnInit, OnDestroy {
23152315

23162316
async onPoamIconClick(vulnerability: any, event: Event) {
23172317
event.stopPropagation();
2318-
const poamAssociation = this.existingPoamPluginIDs[vulnerability.pluginID];
2319-
if (poamAssociation?.poamId) {
2320-
this.router.navigateByUrl(`/poam-processing/poam-details/${poamAssociation.poamId}`);
2321-
return;
2322-
}
2323-
2324-
await this.showDetails(vulnerability, true);
2325-
const pluginIAVData = this.iavInfo[this.pluginData.id];
2326-
let formattedIavComplyByDate = null;
2327-
if (pluginIAVData?.navyComplyDate) {
2328-
const complyDate = new Date(pluginIAVData.navyComplyDate);
2329-
formattedIavComplyByDate = format(complyDate, 'yyyy-MM-dd');
2330-
}
2331-
2332-
this.router.navigate(['/poam-processing/poam-details/ADDPOAM'], {
2333-
state: {
2334-
vulnerabilitySource: 'Assured Compliance Assessment Solution (ACAS) Nessus Scanner',
2335-
pluginData: this.pluginData,
2336-
iavNumber: pluginIAVData?.iav,
2337-
iavComplyByDate: formattedIavComplyByDate,
2338-
},
2339-
});
2318+
try {
2319+
const poamAssociation = this.existingPoamPluginIDs[vulnerability.pluginID];
2320+
if (poamAssociation?.poamId) {
2321+
this.router.navigateByUrl(`/poam-processing/poam-details/${poamAssociation.poamId}`);
2322+
return;
2323+
}
2324+
2325+
await this.showDetails(vulnerability, true);
2326+
2327+
if (!this.pluginData) {
2328+
throw new Error('Plugin data not available');
2329+
}
2330+
2331+
const pluginIAVData = this.iavInfo[this.pluginData.id];
2332+
let formattedIavComplyByDate = null;
2333+
if (pluginIAVData?.navyComplyDate) {
2334+
const complyDate = new Date(pluginIAVData.navyComplyDate);
2335+
formattedIavComplyByDate = format(complyDate, 'yyyy-MM-dd');
2336+
}
2337+
2338+
this.router.navigate(['/poam-processing/poam-details/ADDPOAM'], {
2339+
state: {
2340+
vulnerabilitySource: 'Assured Compliance Assessment Solution (ACAS) Nessus Scanner',
2341+
pluginData: this.pluginData,
2342+
iavNumber: pluginIAVData?.iav,
2343+
iavComplyByDate: formattedIavComplyByDate,
2344+
},
2345+
});
2346+
} catch (error) {
2347+
console.error('Error in onPoamIconClick:', error);
2348+
this.showErrorMessage('Error processing vulnerability data. Please try again.');
2349+
}
23402350
}
23412351

23422352
getPoamStatusColor(status: string): string {
@@ -2384,51 +2394,55 @@ export class TenableVulnerabilitiesComponent implements OnInit, OnDestroy {
23842394
}
23852395
}
23862396

2387-
showDetails(vulnerability: any, createPoam: boolean = false) {
2397+
showDetails(vulnerability: any, createPoam: boolean = false): Promise<void> {
23882398
if (!vulnerability || !vulnerability.pluginID) {
23892399
this.showErrorMessage('Invalid vulnerability data');
2390-
return;
2400+
return Promise.reject('Invalid vulnerability data');
23912401
}
23922402

2393-
this.importService.getTenablePlugin(vulnerability.pluginID).pipe(
2394-
tap(data => {
2395-
if (!data || !data.response) {
2396-
throw new Error('Invalid response from getTenablePlugin');
2397-
}
2398-
}),
2399-
map(data => data.response)
2400-
).subscribe({
2401-
next: (pluginData) => {
2402-
this.pluginData = pluginData;
2403-
this.formattedDescription = this.pluginData.description
2404-
? this.sanitizer.bypassSecurityTrustHtml(
2405-
this.pluginData.description.replace(/\n\n/g, '<br>')
2406-
)
2407-
: '';
2408-
2409-
if (this.pluginData.xrefs && this.pluginData.xrefs.length > 0) {
2410-
this.parseReferences(this.pluginData.xrefs);
2411-
} else {
2412-
this.cveReferences = [];
2413-
this.iavReferences = [];
2414-
this.otherReferences = [];
2415-
}
2403+
return new Promise((resolve, reject) => {
2404+
this.importService.getTenablePlugin(vulnerability.pluginID).pipe(
2405+
tap(data => {
2406+
if (!data || !data.response) {
2407+
throw new Error('Invalid response from getTenablePlugin');
2408+
}
2409+
}),
2410+
map(data => data.response)
2411+
).subscribe({
2412+
next: (pluginData) => {
2413+
this.pluginData = pluginData;
2414+
this.formattedDescription = this.pluginData.description
2415+
? this.sanitizer.bypassSecurityTrustHtml(
2416+
this.pluginData.description.replace(/\n\n/g, '<br>')
2417+
)
2418+
: '';
2419+
2420+
if (this.pluginData.xrefs && this.pluginData.xrefs.length > 0) {
2421+
this.parseReferences(this.pluginData.xrefs);
2422+
} else {
2423+
this.cveReferences = [];
2424+
this.iavReferences = [];
2425+
this.otherReferences = [];
2426+
}
24162427

2417-
if (Array.isArray(this.pluginData.vprContext)) {
2418-
this.parseVprContext(this.pluginData.vprContext);
2419-
} else {
2420-
this.parsedVprContext = [];
2421-
}
2428+
if (Array.isArray(this.pluginData.vprContext)) {
2429+
this.parseVprContext(this.pluginData.vprContext);
2430+
} else {
2431+
this.parsedVprContext = [];
2432+
}
24222433

2423-
this.selectedVulnerability = vulnerability;
2424-
if (!createPoam) {
2425-
this.displayDialog = true;
2434+
this.selectedVulnerability = vulnerability;
2435+
if (!createPoam) {
2436+
this.displayDialog = true;
2437+
}
2438+
resolve();
2439+
},
2440+
error: (error) => {
2441+
console.error('Error fetching plugin data:', error);
2442+
this.showErrorMessage('Error fetching plugin data. Please try again.');
2443+
reject(error);
24262444
}
2427-
},
2428-
error: (error) => {
2429-
console.error('Error fetching plugin data:', error);
2430-
this.showErrorMessage('Error fetching plugin data. Please try again.');
2431-
}
2445+
});
24322446
});
24332447
}
24342448

0 commit comments

Comments
 (0)