mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
feat: Add malysis cache implementation with proxy flow integration (#346)
* feat: Add malysis cache implementation with proxy flow integration * fix: Code review fixes
This commit is contained in:
@@ -28,7 +28,7 @@ func newMalysisAnalyzer(config MalysisQueryAnalyzerConfig,
|
||||
creds, closeResolver, err := resolveCredentials()
|
||||
if err != nil {
|
||||
log.Debugf("SafeDep Cloud credentials unavailable, using community malysis analyzer: %v", err)
|
||||
return community, nil
|
||||
return withCache(community, config), nil
|
||||
}
|
||||
defer func() {
|
||||
if closeErr := closeResolver(); closeErr != nil {
|
||||
@@ -42,5 +42,13 @@ func newMalysisAnalyzer(config MalysisQueryAnalyzerConfig,
|
||||
}
|
||||
|
||||
log.Debugf("SafeDep Cloud credentials found, using authenticated malysis analyzer with community fallback")
|
||||
return newMalysisFallbackAnalyzer(authenticated, community), nil
|
||||
return withCache(newMalysisFallbackAnalyzer(authenticated, community), config), nil
|
||||
}
|
||||
|
||||
// withCache wraps a in a read-through cache decorator when one is configured.
|
||||
func withCache(a PackageVersionAnalyzer, config MalysisQueryAnalyzerConfig) PackageVersionAnalyzer {
|
||||
if config.Cache == nil {
|
||||
return a
|
||||
}
|
||||
return newMalysisCachingAnalyzer(a, config.Cache)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user