From 2d702a1a205f21238e0a858ec3101b0723e76b02 Mon Sep 17 00:00:00 2001 From: Chris Rodriguez Date: Thu, 30 Jan 2025 17:12:49 -0500 Subject: [PATCH] Preset filters under STIG Manager Component -> Benchmark ID --- .../stigmanager-import.component.html | 70 ++++++++----------- .../stigmanager-import.component.ts | 60 +++++++++++++++- 2 files changed, 90 insertions(+), 40 deletions(-) diff --git a/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.html b/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.html index efcc39e..b0018c5 100644 --- a/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.html +++ b/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.html @@ -39,45 +39,37 @@ > - - {{col.header}} - - - - - - - - - - - + + {{col.header}} + + + + + + + + + + + diff --git a/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.ts b/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.ts index 8248e91..fcd1094 100644 --- a/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.ts +++ b/client/src/app/pages/import-processing/stigmanager-import/stigmanager-import.component.ts @@ -40,6 +40,30 @@ interface AssetEntry { poamStatus?: string; } +interface STIGData { + benchmarkId: string; + collectionIds: string[]; + lastRevisionDate: string; + lastRevisionStr: string; + revisionStrs: string[]; + revisions: STIGRevision[]; + ruleCount: number; + status: string; + title: string; +} + +interface STIGRevision { + benchmarkDate: string; + benchmarkId: string; + collectionIds: string[]; + release: string; + revisionStr: string; + ruleCount: number; + status: string; + statusDate: string; + version: string; +} + @Component({ selector: 'cpat-stigmanager-import', templateUrl: './stigmanager-import.component.html', @@ -87,13 +111,21 @@ export class STIGManagerImportComponent implements OnInit, OnDestroy { }, { field: 'groupId', header: 'Group ID', width: '15%', filterType: 'text' }, { field: 'ruleTitle', header: 'Rule Title', width: '35%', filterType: 'text' }, - { field: 'benchmarkId', header: 'Benchmark ID', width: '15%', filterType: 'text' }, + { + field: 'benchmarkId', + header: 'Benchmark ID', + width: '15%', + filterType: 'text', + filterOptions: [{ label: 'Any', value: null }] + }, { field: 'severity', header: 'Severity', width: '15%', filterType: 'text' }, { field: 'assetCount', header: 'Asset Count', width: '15%', filterType: 'numeric' }, ]; private dataSource: AssetEntry[] = []; public displayDataSource: AssetEntry[] = []; public existingPoams: any[] = []; + benchmarkIds: string[] = []; + selectedBenchmarkId: string | null = null; loadingTableInfo: boolean = true; loadingSkeletonData: any[] = Array(15).fill({}); multiSortMeta: any[] = []; @@ -159,6 +191,7 @@ export class STIGManagerImportComponent implements OnInit, OnDestroy { ); this.initializeComponent(); this.selectedFindings = 'All'; + this.loadBenchmarkIds(); } private initializeComponent() { @@ -290,6 +323,31 @@ export class STIGManagerImportComponent implements OnInit, OnDestroy { }); } + private loadBenchmarkIds() { + this.subscriptions.add( + this.sharedService.getSTIGsFromSTIGMAN().subscribe({ + next: (data: STIGData[]) => { + this.benchmarkIds = [...new Set(data.map(stig => stig.benchmarkId))].sort(); + this.updateBenchmarkFilter(); + }, + error: (error) => { + console.error('Error loading STIG data:', error); + this.showError('Failed to load benchmark IDs. Please try again.'); + } + }) + ); + } + + private updateBenchmarkFilter() { + const benchmarkColumn = this.allColumns.find(col => col.field === 'benchmarkId'); + if (benchmarkColumn) { + benchmarkColumn.filterOptions = [ + { label: 'Any', value: null }, + ...this.benchmarkIds.map(id => ({ label: id, value: id })) + ]; + } + } + private mapSeverity(severity: string): string { switch (severity) { case 'high': return 'CAT I - High';