Skip to content

Commit

Permalink
Merge pull request #156 from NSWC-Crane/CHRIS_DEV
Browse files Browse the repository at this point in the history
Preset filters under STIG Manager Component -> Benchmark ID
  • Loading branch information
crodriguez6497 authored Jan 30, 2025
2 parents e2060c0 + 3682ae3 commit 557839b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,37 @@
>
<ng-template pTemplate="header">
<tr>
<th
*ngFor="let col of allColumns"
id="col"
[pSortableColumn]="col.field"
[ngStyle]="{'width': col.width}"
>
{{col.header}}
<ng-container *ngIf="col.field === 'poam'">
<p-columnFilter
[type]="col.filterType"
[field]="col.filterField"
[showOperator]="false"
[showMatchModes]="false"
[showAddButton]="false"
[showButtons]="true"
display="menu"
>
<ng-template pTemplate="filter" let-value let-filter="filterCallback">
<p-select
[ngModel]="value"
[options]="col.filterOptions"
(onChange)="filter($event.value)"
placeholder="Select Status"
[showClear]="true"
styleClass="w-full"
>
</p-select>
</ng-template>
</p-columnFilter>
</ng-container>
<p-columnFilter
*ngIf="col.field !== 'poam'"
[type]="col.filterType"
[field]="col.field"
[showOperator]="false"
display="menu"
>
</p-columnFilter>
</th>
<th *ngFor="let col of allColumns"
id="col"
[pSortableColumn]="col.field"
[ngStyle]="{'width': col.width}">
{{col.header}}
<ng-container *ngIf="col.field === 'benchmarkId'">
<p-columnFilter [type]="col.filterType"
[field]="col.field"
[showOperator]="false"
[showMatchModes]="false"
[showAddButton]="false"
[showButtons]="true"
display="menu">
<ng-template pTemplate="filter" let-value let-filter="filterCallback">
<p-select [ngModel]="value"
[options]="col.filterOptions"
(onChange)="filter($event.value)"
placeholder="Select Benchmark"
[showClear]="true"
styleClass="w-full">
</p-select>
</ng-template>
</p-columnFilter>
</ng-container>
<p-columnFilter *ngIf="col.field !== 'poam' && col.field !== 'benchmarkId'"
[type]="col.filterType"
[field]="col.field"
[showOperator]="false"
display="menu">
</p-columnFilter>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -159,6 +191,7 @@ export class STIGManagerImportComponent implements OnInit, OnDestroy {
);
this.initializeComponent();
this.selectedFindings = 'All';
this.loadBenchmarkIds();
}

private initializeComponent() {
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 557839b

Please sign in to comment.