diff --git a/pkg/adapter/anchore/adapter.go b/pkg/adapter/anchore/adapter.go index 0b8addd..1b64b6d 100644 --- a/pkg/adapter/anchore/adapter.go +++ b/pkg/adapter/anchore/adapter.go @@ -681,6 +681,12 @@ func nowISOFormat() string { func (s *HarborScannerAdapter) GetMetadata() (harbor.ScannerAdapterMetadata, error) { adapterMeta := adapter.AdapterMetadata + + // Disable RawReportMimeType if not enabled + if !s.Configuration.EnableRawMimeType { + adapterMeta.Capabilities[0].ProducesMIMETypes = []string{adapter.HarborVulnReportv1MimeType} + } + var err error var feedsUpdated time.Time diff --git a/pkg/adapter/anchore/config.go b/pkg/adapter/anchore/config.go index a48702d..b27a248 100644 --- a/pkg/adapter/anchore/config.go +++ b/pkg/adapter/anchore/config.go @@ -28,6 +28,7 @@ type AdapterConfig struct { AnchoreClientConfig client.Config // Credentials and client configuration CacheConfig CacheConfiguration UseAnchoreConfiguredCreds bool // If true, the adapter will ignore the dynamic credentials that are provided by harbor for each scan and will instead expect that the admin has configured Anchore with credentials out-of-band. Default is False. + EnableRawMimeType bool // If true, the scanner adapter will not attempt produce the Raw Mime type. Default is False. } const ( @@ -56,6 +57,8 @@ const ( DefaultDescriptionCacheEnabled = true DefaultDescriptionCacheTTL = 60 * 60 * 24 DefaultDescriptionCacheItemCount = 10000 + EnableRawMimeTypeEnvVarName = "SCANNER_ADAPTER_ENABLE_RAW_MIME_TYPE" + EnableRawMimeTypeDefault = true ReportCacheEnabledEnvVarName = "SCANNER_ADAPTER_REPORT_CACHE_ENABLED" ReportCacheItemCount = "SCANNER_ADAPTER_REPORT_CACHE_COUNT" ReportCacheTTL = "SCANNER_ADAPTER_REPORT_CACHE_TTL" @@ -299,5 +302,7 @@ func GetConfig() (AdapterConfig, error) { cfg.UseAnchoreConfiguredCreds, _ = GetEnvBoolean(UseAnchoreConfigCredsEnvVarName, UseAnchoreConfigCredsDefault) + cfg.EnableRawMimeType, _ = GetEnvBoolean(EnableRawMimeTypeEnvVarName, EnableRawMimeTypeDefault) + return cfg, nil }