mirror of
https://github.com/goharbor/harbor.git
synced 2025-04-06 20:15:53 +02:00
add sbom settings for project (#20069)
Add a new switcher for sbom generation, by default is false. Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
d79e4b1176
commit
3782bab80a
@ -23,4 +23,5 @@ const (
|
|||||||
ProMetaSeverity = "severity"
|
ProMetaSeverity = "severity"
|
||||||
ProMetaAutoScan = "auto_scan"
|
ProMetaAutoScan = "auto_scan"
|
||||||
ProMetaReuseSysCVEAllowlist = "reuse_sys_cve_allowlist"
|
ProMetaReuseSysCVEAllowlist = "reuse_sys_cve_allowlist"
|
||||||
|
ProMetaAutoSBOMGen = "auto_sbom_generation"
|
||||||
)
|
)
|
||||||
|
@ -147,6 +147,15 @@ func (p *Project) AutoScan() bool {
|
|||||||
return isTrue(auto)
|
return isTrue(auto)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AutoSBOMGen ...
|
||||||
|
func (p *Project) AutoSBOMGen() bool {
|
||||||
|
auto, exist := p.GetMetadata(ProMetaAutoSBOMGen)
|
||||||
|
if !exist {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return isTrue(auto)
|
||||||
|
}
|
||||||
|
|
||||||
// FilterByPublic returns orm.QuerySeter with public filter
|
// FilterByPublic returns orm.QuerySeter with public filter
|
||||||
func (p *Project) FilterByPublic(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
|
func (p *Project) FilterByPublic(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
|
||||||
subQuery := `SELECT project_id FROM project_metadata WHERE name = 'public' AND value = '%s'`
|
subQuery := `SELECT project_id FROM project_metadata WHERE name = 'public' AND value = '%s'`
|
||||||
|
@ -143,7 +143,7 @@ func (p *projectMetadataAPI) validate(metas map[string]string) (map[string]strin
|
|||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
case proModels.ProMetaPublic, proModels.ProMetaEnableContentTrust, proModels.ProMetaEnableContentTrustCosign,
|
case proModels.ProMetaPublic, proModels.ProMetaEnableContentTrust, proModels.ProMetaEnableContentTrustCosign,
|
||||||
proModels.ProMetaPreventVul, proModels.ProMetaAutoScan, proModels.ProMetaReuseSysCVEAllowlist:
|
proModels.ProMetaAutoSBOMGen, proModels.ProMetaPreventVul, proModels.ProMetaAutoScan, proModels.ProMetaReuseSysCVEAllowlist:
|
||||||
v, err := strconv.ParseBool(value)
|
v, err := strconv.ParseBool(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid value: %s", value)
|
return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid value: %s", value)
|
||||||
|
Loading…
Reference in New Issue
Block a user