From 527043632d48722375f43a454b9a381d02de5331 Mon Sep 17 00:00:00 2001 From: Kaden Emley Date: Tue, 13 Aug 2024 12:09:42 -0400 Subject: [PATCH] re-adjust structure of sbom component filtering Signed-off-by: Kaden Emley --- .../cards/sbomview/ComponentContent.vue | 32 +++- .../cards/sbomview/ComponentTable.vue | 161 +++--------------- .../cards/sbomview/DependencyTree.vue | 9 +- .../cards/sbomview/SbomSettingsSelector.vue | 100 +++++++++++ apps/frontend/src/store/data_filters.ts | 34 +++- apps/frontend/src/utilities/sbom_util.ts | 5 + apps/frontend/src/views/Sbom.vue | 118 +++++++++++-- 7 files changed, 286 insertions(+), 173 deletions(-) create mode 100644 apps/frontend/src/components/cards/sbomview/SbomSettingsSelector.vue diff --git a/apps/frontend/src/components/cards/sbomview/ComponentContent.vue b/apps/frontend/src/components/cards/sbomview/ComponentContent.vue index 02a02999f3..b1c25a2179 100644 --- a/apps/frontend/src/components/cards/sbomview/ComponentContent.vue +++ b/apps/frontend/src/components/cards/sbomview/ComponentContent.vue @@ -56,8 +56,32 @@ Name Description - - + + View All + + + View All + @@ -69,7 +93,7 @@ small outlined @click=" - $emit('show-component-in-table', component['bom-ref']) + $emit('show-components-in-table', [component['bom-ref']]) " >Go to Component Table @@ -79,7 +103,7 @@ small outlined @click=" - $emit('show-component-in-tree', component['bom-ref']) + $emit('show-components-in-tree', [component['bom-ref']]) " >Go to Dependency Tree diff --git a/apps/frontend/src/components/cards/sbomview/ComponentTable.vue b/apps/frontend/src/components/cards/sbomview/ComponentTable.vue index afeb1393d6..43f9d7f097 100644 --- a/apps/frontend/src/components/cards/sbomview/ComponentTable.vue +++ b/apps/frontend/src/components/cards/sbomview/ComponentTable.vue @@ -6,7 +6,6 @@ - - @@ -117,7 +62,7 @@ @@ -276,6 +150,11 @@ export default class ComponentTable extends Vue { border-left: 5px solid var(--v-primary-base); } +/** Blue bar on the bottom to show where expanded content ends */ +::v-deep .v-data-table__expanded__content { + border-bottom: 5px solid var(--v-primary-base) !important; +} + /** Allows blue bar to be visible */ ::v-deep .v-data-table__wrapper table { border-collapse: collapse; diff --git a/apps/frontend/src/components/cards/sbomview/DependencyTree.vue b/apps/frontend/src/components/cards/sbomview/DependencyTree.vue index 72bf30cc2f..1228b6266b 100644 --- a/apps/frontend/src/components/cards/sbomview/DependencyTree.vue +++ b/apps/frontend/src/components/cards/sbomview/DependencyTree.vue @@ -14,7 +14,7 @@ diff --git a/apps/frontend/src/store/data_filters.ts b/apps/frontend/src/store/data_filters.ts index 8a08627daf..b63e8f1a7c 100644 --- a/apps/frontend/src/store/data_filters.ts +++ b/apps/frontend/src/store/data_filters.ts @@ -90,6 +90,17 @@ export interface Filter { control_id?: string; } +/** Contains common filters on SBOM components from the store */ +export interface SBOMFilter { + /** Which file these objects came from. */ + fromFile: FileID[]; + + /** Each component has to have at least one of these severities. + * "none" allows controls with no vulnerabilities to appear */ + severity?: Severity[]; + 'bom-refs'?: string[]; +} + export type TreeMapState = string[]; // Representing the current path spec, from root /** @@ -513,18 +524,27 @@ export class FilteredData extends VuexModule { }; } - get components(): (filter: Filter) => readonly ContextualizedSBOMComponent[] { - return (filter: Filter) => { + get components(): ( + filter: SBOMFilter + ) => readonly ContextualizedSBOMComponent[] { + return (filter: SBOMFilter) => { const sboms = this.sboms(filter.fromFile).map(parseSbomPassthrough); - const controls = this.controls(filter); + const controls = this.controls(filter); // gets all the controls in the SBOM files // grab every component from each SBOM and apply a filter if necessary return sboms.flatMap((sbom) => sbom.components.filter((component) => { - return ( - !filter.severity || - componentFitsSeverityFilter(component, filter.severity, controls) - ); + if ( + filter.severity && + !componentFitsSeverityFilter(component, filter.severity, controls) + ) + return false; + if ( + filter['bom-refs'] && + !filter['bom-refs'].includes(component['bom-ref']) + ) + return false; + return true; }) ); }; diff --git a/apps/frontend/src/utilities/sbom_util.ts b/apps/frontend/src/utilities/sbom_util.ts index 2aa8014592..077d3e1295 100644 --- a/apps/frontend/src/utilities/sbom_util.ts +++ b/apps/frontend/src/utilities/sbom_util.ts @@ -55,6 +55,11 @@ export interface SBOMData { componentMap: Map>; } +export interface SbomViewSettings { + severities: Severity[]; + currentHeaders: string[]; +} + /** * @param evaluation The evaluation to test * @returns true if the given evaluation contains SBOM data in the passthrough section diff --git a/apps/frontend/src/views/Sbom.vue b/apps/frontend/src/views/Sbom.vue index 58ad0eca1f..d420b52e52 100644 --- a/apps/frontend/src/views/Sbom.vue +++ b/apps/frontend/src/views/Sbom.vue @@ -17,6 +17,10 @@ @click:clear="searchTerm = ''" /> + + Clear + mdi-filter-remove +
@@ -66,6 +70,8 @@ @@ -76,18 +82,25 @@ - + Component Table Dependency Tree + + + + + @@ -95,10 +108,10 @@ @@ -111,14 +124,19 @@ - + + All results are filtered out. Use the + mdi-filter-remove button in the top right to clear + filters and show all. + + No files are currently loaded. Press the LOAD mdi-cloud-upload button above to load some. @@ -135,6 +153,7 @@