Skip to content

Commit

Permalink
Merge pull request #291 from anchore/config-raw-mime-type
Browse files Browse the repository at this point in the history
feat: add option to disable RAW MIME type
  • Loading branch information
bradleyjones authored Aug 6, 2024
2 parents 3489873 + ed276f0 commit f38b662
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/adapter/anchore/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions pkg/adapter/anchore/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -299,5 +302,7 @@ func GetConfig() (AdapterConfig, error) {

cfg.UseAnchoreConfiguredCreds, _ = GetEnvBoolean(UseAnchoreConfigCredsEnvVarName, UseAnchoreConfigCredsDefault)

cfg.EnableRawMimeType, _ = GetEnvBoolean(EnableRawMimeTypeEnvVarName, EnableRawMimeTypeDefault)

return cfg, nil
}

0 comments on commit f38b662

Please sign in to comment.