mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-02 13:01:23 +01:00
Fix and Should to display Unsupported if no SBOM accessories found (#20426)
Should this be Unsupported either for SBOM Signed-off-by: xuelichao <xuel@vmware.com> Co-authored-by: Shengwen YU <yshengwen@vmware.com>
This commit is contained in:
parent
8ccf98a2ac
commit
840d4085f0
@ -451,18 +451,22 @@
|
||||
</clr-dg-cell>
|
||||
<clr-dg-cell>
|
||||
<div class="cell">
|
||||
<span *ngIf="!hasScannerSupportSBOM">
|
||||
<span *ngIf="!hasSbom(artifact)">
|
||||
{{ 'ARTIFACT.SBOM_UNSUPPORTED' | translate }}
|
||||
</span>
|
||||
<hbr-sbom-bar
|
||||
(submitStopFinish)="submitSbomStopFinish($event)"
|
||||
(scanFinished)="sbomFinished($event)"
|
||||
*ngIf="hasScannerSupportSBOM"
|
||||
[inputScanner]="projectScanner"
|
||||
*ngIf="hasSbom(artifact)"
|
||||
[inputScanner]="
|
||||
handleSbomOverview(artifact.sbom_overview)
|
||||
?.scanner
|
||||
"
|
||||
(submitFinish)="submitSbomFinish($event)"
|
||||
[projectName]="projectName"
|
||||
[projectId]="projectId"
|
||||
[repoName]="repoName"
|
||||
[accessories]="artifact?.accessories"
|
||||
[artifactDigest]="artifact?.digest"
|
||||
[sbomDigest]="artifact?.sbomDigest"
|
||||
[sbomOverview]="artifact?.sbom_overview">
|
||||
|
@ -161,9 +161,6 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy {
|
||||
get generateSbomBtnState(): ClrLoadingState {
|
||||
return this.artifactListPageService.getSbomBtnState();
|
||||
}
|
||||
get projectScanner(): Scanner {
|
||||
return this.artifactListPageService.getProjectScanner();
|
||||
}
|
||||
|
||||
onSendingScanCommand: boolean;
|
||||
onSendingStopScanCommand: boolean = false;
|
||||
@ -935,6 +932,14 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy {
|
||||
return null;
|
||||
}
|
||||
|
||||
handleSbomOverview(sbomOverview: any): any {
|
||||
if (sbomOverview) {
|
||||
const keys = Object.keys(sbomOverview) ?? [];
|
||||
return keys.length > 0 ? sbomOverview[keys[0]] : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
goIntoIndexArtifact(artifact: Artifact) {
|
||||
let depth: string = '';
|
||||
if (this.depth) {
|
||||
@ -992,6 +997,9 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy {
|
||||
this.selectedRow[i].sbomDigest =
|
||||
artifact.sbom_overview.sbom_digest;
|
||||
}
|
||||
if (artifact.accessories !== undefined) {
|
||||
this.selectedRow[i].accessories = artifact.accessories;
|
||||
}
|
||||
this.selectedRow.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
<hbr-sbom-tip-histogram
|
||||
[scanner]="getScanner()"
|
||||
[artifactDigest]="artifactDigest"
|
||||
[accessories]="accessories"
|
||||
[sbomSummary]="sbomOverview"
|
||||
[sbomDigest]="sbomDigest"></hbr-sbom-tip-histogram>
|
||||
</div>
|
||||
|
@ -10,6 +10,7 @@ import { SbomTipHistogramComponent } from './sbom-tip-histogram/sbom-tip-histogr
|
||||
import { SBOMOverview } from './sbom-overview';
|
||||
import { of, timer } from 'rxjs';
|
||||
import { ArtifactService, ScanService } from 'ng-swagger-gen/services';
|
||||
import { AccessoryType } from '../artifact';
|
||||
|
||||
describe('ResultSbomComponent (inline template)', () => {
|
||||
let component: ResultSbomComponent;
|
||||
@ -165,6 +166,13 @@ describe('ResultSbomComponent (inline template)', () => {
|
||||
|
||||
it('should show summary bar chart if status is COMPLETED', () => {
|
||||
component.sbomOverview.scan_status = SBOM_SCAN_STATUS.SUCCESS;
|
||||
component.sbomDigest = mockedSbomDigest;
|
||||
component.accessories = [
|
||||
{
|
||||
type: AccessoryType.SBOM,
|
||||
digest: mockedSbomDigest,
|
||||
},
|
||||
];
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
HarborEvent,
|
||||
} from '../../../../../services/event-service/event.service';
|
||||
import { ScanService } from '../../../../../../../ng-swagger-gen/services/scan.service';
|
||||
import { ScanType } from 'ng-swagger-gen/models';
|
||||
import { Accessory, ScanType } from 'ng-swagger-gen/models';
|
||||
import { ScanTypes } from '../../../../../shared/entities/shared.const';
|
||||
import { SBOMOverview } from './sbom-overview';
|
||||
import { Scanner } from '../../../../left-side-nav/interrogation-services/scanner/scanner';
|
||||
@ -43,6 +43,7 @@ export class ResultSbomComponent implements OnInit, OnDestroy {
|
||||
@Input() artifactDigest: string = '';
|
||||
@Input() sbomDigest: string = '';
|
||||
@Input() sbomOverview: SBOMOverview;
|
||||
@Input() accessories: Accessory[] = [];
|
||||
onSubmitting: boolean = false;
|
||||
onStopping: boolean = false;
|
||||
retryCounter: number = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="tip-wrapper width-215">
|
||||
<clr-tooltip>
|
||||
<div clrTooltipTrigger class="tip-block">
|
||||
<div *ngIf="!noSbom" class="circle-block">
|
||||
<div *ngIf="showSbomDetailLink()" class="circle-block">
|
||||
<a
|
||||
href="javascript:void(0)"
|
||||
class="digest margin-left-5"
|
||||
@ -11,10 +11,15 @@
|
||||
>
|
||||
</div>
|
||||
<div
|
||||
*ngIf="noSbom"
|
||||
*ngIf="showNoSbom()"
|
||||
class="pl-1 margin-left-5 tip-wrapper bar-block-none shadow-none width-150">
|
||||
{{ 'SBOM.NO_SBOM' | translate }}
|
||||
</div>
|
||||
<div
|
||||
*ngIf="!showSbomDetailLink() && !showNoSbom()"
|
||||
class="pl-1 margin-left-5 tip-wrapper bar-block-none shadow-none width-150">
|
||||
{{ 'SBOM.COMPLETED,' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
<clr-tooltip-content
|
||||
class="w-800"
|
||||
@ -23,15 +28,18 @@
|
||||
*clrIfOpen>
|
||||
<div class="bar-tooltip-font-larger">
|
||||
<div
|
||||
*ngIf="!noSbom"
|
||||
*ngIf="showSbomDetailLink()"
|
||||
class="level-border clr-display-inline-block margin-right-5">
|
||||
<div>
|
||||
{{ 'SBOM.PACKAGES' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
<ng-container *ngIf="noSbom">
|
||||
<ng-container *ngIf="showNoSbom()">
|
||||
<span>{{ 'SBOM.NO_SBOM' | translate }}</span>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="!showSbomDetailLink() && !showNoSbom()">
|
||||
<span>{{ 'SBOM.COMPLETED' | translate }}</span>
|
||||
</ng-container>
|
||||
</div>
|
||||
<hr />
|
||||
<div *ngIf="scanner">
|
||||
|
@ -75,7 +75,7 @@ describe('SbomTipHistogramComponent', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component).toBeTruthy();
|
||||
expect(component.isLimitedSuccess()).toBeFalsy();
|
||||
expect(component.noSbom).toBeTruthy();
|
||||
expect(component.showNoSbom()).toBeTruthy();
|
||||
expect(component.isThemeLight()).toBeFalsy();
|
||||
expect(component.duration()).toBe('0');
|
||||
expect(component.completePercent).toBe('0%');
|
||||
|
@ -10,6 +10,8 @@ import {
|
||||
import { HAS_STYLE_MODE, StyleMode } from '../../../../../../services/theme';
|
||||
import { ScanTypes } from '../../../../../../shared/entities/shared.const';
|
||||
import { Scanner } from '../../../../../left-side-nav/interrogation-services/scanner/scanner';
|
||||
import { Accessory } from 'ng-swagger-gen/models';
|
||||
import { AccessoryType } from '../../artifact';
|
||||
|
||||
const MIN = 60;
|
||||
const MIN_STR = 'min ';
|
||||
@ -28,6 +30,7 @@ export class SbomTipHistogramComponent {
|
||||
};
|
||||
@Input() artifactDigest: string = '';
|
||||
@Input() sbomDigest: string = '';
|
||||
@Input() accessories: Accessory[] = [];
|
||||
constructor(
|
||||
private translate: TranslateService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
@ -50,6 +53,14 @@ export class SbomTipHistogramComponent {
|
||||
return '0';
|
||||
}
|
||||
|
||||
public getSbomAccessories(): Accessory[] {
|
||||
return (
|
||||
this.accessories.filter(
|
||||
accessory => accessory.type === AccessoryType.SBOM
|
||||
) ?? []
|
||||
);
|
||||
}
|
||||
|
||||
public get completePercent(): string {
|
||||
return this.sbomSummary.scan_status === SBOM_SCAN_STATUS.SUCCESS
|
||||
? `100%`
|
||||
@ -67,8 +78,12 @@ export class SbomTipHistogramComponent {
|
||||
: new Date();
|
||||
}
|
||||
|
||||
get noSbom(): boolean {
|
||||
return this.sbomDigest === undefined || this.sbomDigest === '';
|
||||
showSbomDetailLink(): boolean {
|
||||
return this.sbomDigest && this.getSbomAccessories.length > 0;
|
||||
}
|
||||
|
||||
showNoSbom(): boolean {
|
||||
return !this.sbomDigest && this.getSbomAccessories.length === 0;
|
||||
}
|
||||
|
||||
isThemeLight() {
|
||||
|
@ -217,6 +217,7 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
repositoryName: dbEncodeURIComponent(this.repoName),
|
||||
reference: this.artifactDigest,
|
||||
withScanOverview: true,
|
||||
withAccessory: true,
|
||||
XAcceptVulnerabilities: DEFAULT_SUPPORTED_MIME_TYPES,
|
||||
})
|
||||
.subscribe(
|
||||
|
@ -1058,6 +1058,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1059,6 +1059,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM ",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1057,6 +1057,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1057,6 +1057,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1056,6 +1056,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1055,6 +1055,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1058,6 +1058,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1056,6 +1056,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
@ -1055,6 +1055,7 @@
|
||||
},
|
||||
"NO_SBOM": "No SBOM",
|
||||
"PACKAGES": "SBOM",
|
||||
"COMPLETED": "Completed",
|
||||
"REPORTED_BY": "Reported by {{scanner}}",
|
||||
"GENERATE": "Generate SBOM",
|
||||
"DOWNLOAD": "Download SBOM",
|
||||
|
Loading…
Reference in New Issue
Block a user