Configure to auto generate SBOM or not on project configuration page. (#20059)

Signed-off-by: xuelichao <xuel@vmware.com>
Co-authored-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
Lichao Xue 2024-03-06 16:06:25 +08:00 committed by GitHub
parent 950fc06a87
commit 9b7c1a2274
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 63 additions and 8 deletions

View File

@ -121,6 +121,23 @@
{{ 'PROJECT_CONFIG.AUTOSCAN_POLICY' | translate }}
</clr-control-helper>
</clr-checkbox-container>
<clr-checkbox-container>
<label>{{ 'PROJECT_CONFIG.SBOM' | translate }}</label>
<clr-checkbox-wrapper id="generate-sbom-on-push-wrapper">
<input
type="checkbox"
clrCheckbox
[(ngModel)]="projectPolicy.GenerateSbomOnPush"
[disabled]="!hasChangeConfigRole"
name="generate-sbom-on-push" />
<label>{{
'PROJECT_CONFIG.AUTOSBOM_TOGGLE' | translate
}}</label>
</clr-checkbox-wrapper>
<clr-control-helper class="config-subtext">
{{ 'PROJECT_CONFIG.AUTOSBOM_POLICY' | translate }}
</clr-control-helper>
</clr-checkbox-container>
<div
*ngIf="systemInfo"
class="clr-form-control"

View File

@ -65,6 +65,7 @@ const mockProjectPolicies: Project[] | any[] = [
repo_count: 0,
metadata: {
auto_scan: 'true',
auto_sbom_generation: 'true',
enable_content_trust: 'true',
prevent_vul: 'true',
public: 'true',
@ -140,6 +141,10 @@ describe('ProjectPolicyConfigComponent', () => {
expect(
component.projectPolicyConfigComponent.projectPolicy.ScanImgOnPush
).toBeTruthy();
expect(
component.projectPolicyConfigComponent.projectPolicy
.GenerateSbomOnPush
).toBeTruthy();
});
it('should get hasChangeConfigRole', () => {
expect(

View File

@ -32,6 +32,7 @@ export class ProjectPolicy {
PreventVulImg: boolean;
PreventVulImgSeverity: string;
ScanImgOnPush: boolean;
GenerateSbomOnPush: boolean;
constructor() {
this.Public = false;
@ -40,6 +41,7 @@ export class ProjectPolicy {
this.PreventVulImg = false;
this.PreventVulImgSeverity = LOW;
this.ScanImgOnPush = false;
this.GenerateSbomOnPush = false;
}
initByProject(pro: Project) {
@ -52,6 +54,7 @@ export class ProjectPolicy {
this.PreventVulImgSeverity = pro.metadata.severity;
}
this.ScanImgOnPush = pro.metadata.auto_scan === 'true';
this.GenerateSbomOnPush = pro.metadata.auto_sbom_generation === 'true';
}
}

View File

@ -19,6 +19,7 @@ export class Project {
prevent_vul: string | boolean;
severity: string;
auto_scan: string | boolean;
auto_sbom_generation: string | boolean;
reuse_sys_cve_allowlist?: string;
};
cve_allowlist?: object;
@ -28,5 +29,6 @@ export class Project {
this.metadata.prevent_vul = false;
this.metadata.severity = 'low';
this.metadata.auto_scan = false;
this.metadata.auto_sbom_generation = false;
}
}

View File

@ -33,6 +33,7 @@ export class Project {
prevent_vul: string | boolean;
severity: string;
auto_scan: string | boolean;
auto_sbom_generation: string | boolean;
retention_id: number;
};
constructor() {

View File

@ -158,6 +158,9 @@ export class ProjectDefaultService extends ProjectService {
auto_scan: projectPolicy.ScanImgOnPush
? 'true'
: 'false',
auto_sbom_generation: projectPolicy.GenerateSbomOnPush
? 'true'
: 'false',
reuse_sys_cve_allowlist: reuseSysCVEVAllowlist,
},
cve_allowlist: projectAllowlist,

View File

@ -286,7 +286,10 @@
"PREVENT_VULNERABLE_2": "und darüber.",
"SCAN": "Scannen auf Schwachstellen",
"AUTOSCAN_TOGGLE": "Images automatisch beim Hochladen scannen",
"AUTOSCAN_POLICY": "Scanne Images automatisch, wenn sie in das Projekt hochgeladen werden."
"AUTOSCAN_POLICY": "Scanne Images automatisch, wenn sie in das Projekt hochgeladen werden.",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "Nutzer als Mitglied hinzufügen",

View File

@ -286,7 +286,10 @@
"PREVENT_VULNERABLE_2": "and above from being deployed.",
"SCAN": "Vulnerability scanning",
"AUTOSCAN_TOGGLE": "Automatically scan images on push",
"AUTOSCAN_POLICY": "Automatically scan images when they are pushed to the project registry."
"AUTOSCAN_POLICY": "Automatically scan images when they are pushed to the project registry.",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "Add User Member",

View File

@ -287,7 +287,10 @@
"PREVENT_VULNERABLE_2": "y más arriba de ser desplegado.",
"SCAN": "Escaneo de vulnerabilidad",
"AUTOSCAN_TOGGLE": "Escanee automáticamente las imágenes al instante",
"AUTOSCAN_POLICY": "Escanee automáticamente las imágenes cuando son enviadas al registro del proyecto."
"AUTOSCAN_POLICY": "Escanee automáticamente las imágenes cuando son enviadas al registro del proyecto.",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "Add User Member",

View File

@ -286,7 +286,10 @@
"PREVENT_VULNERABLE_2": "et au-dessus d'être déployées.",
"SCAN": "Analyse des vulnérabilités",
"AUTOSCAN_TOGGLE": "Analyse automatique des images lors de l'envoi",
"AUTOSCAN_POLICY": "Analyser automatiquement les images lorsqu'elles sont envoyées au projet du registre."
"AUTOSCAN_POLICY": "Analyser automatiquement les images lorsqu'elles sont envoyées au projet du registre.",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "Ajouter un nouveau membre",

View File

@ -284,7 +284,10 @@
"PREVENT_VULNERABLE_2": "e acima de serem utilizadas.",
"SCAN": "Análise de vulnerabilidades",
"AUTOSCAN_TOGGLE": "Verificar imagens automaticamente",
"AUTOSCAN_POLICY": "Imagens serão analisadas automaticamente quando enviadas ao repositório do projeto."
"AUTOSCAN_POLICY": "Imagens serão analisadas automaticamente quando enviadas ao repositório do projeto.",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "Adicionar um usuário",

View File

@ -286,7 +286,10 @@
"PREVENT_VULNERABLE_2": "ve yukarıda yüklenilmekte.",
"SCAN": "Güvenlik açığı taraması",
"AUTOSCAN_TOGGLE": "İmajları yüklerken anında tarayın",
"AUTOSCAN_POLICY": "İmajlar proje kayıt defterine yüklenildiğinde otomatik olarak tarayın."
"AUTOSCAN_POLICY": "İmajlar proje kayıt defterine yüklenildiğinde otomatik olarak tarayın.",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "Kullanıcı Üyesi Ekle",

View File

@ -285,7 +285,10 @@
"PREVENT_VULNERABLE_2": "以上的镜像运行。",
"SCAN": "漏洞扫描",
"AUTOSCAN_TOGGLE": "自动扫描镜像",
"AUTOSCAN_POLICY": "当镜像上传后,自动进行扫描"
"AUTOSCAN_POLICY": "当镜像上传后,自动进行扫描",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "添加用户成员",

View File

@ -285,7 +285,10 @@
"PREVENT_VULNERABLE_2": "或更高危險級別的映像檔部署。",
"SCAN": "弱點掃描",
"AUTOSCAN_TOGGLE": "推送時自動掃描映像檔",
"AUTOSCAN_POLICY": "當映像檔推送到專案儲存庫時自動掃描。"
"AUTOSCAN_POLICY": "當映像檔推送到專案儲存庫時自動掃描。",
"SBOM": "SBOM generation",
"AUTOSBOM_TOGGLE": "Automatically generate SBOM on push",
"AUTOSBOM_POLICY": "Automatically generate SBOM when the images are pushed to the project registry."
},
"MEMBER": {
"NEW_USER": "新增使用者成員",