fix: Handle 429 Error in Enrich Malware in vet and Report Quota Error after Scan Completion#674
Conversation
SafeDep Report SummaryPackage Details
This report is generated by SafeDep Github App |
vet Summary ReportThis report is generated by vet Policy Checks
Malicious Package AnalysisMalicious package analysis was performed using SafeDep Cloud API Malicious Package Analysis Report
Changed PackagesChanged Packages
|
There was a problem hiding this comment.
Pull request overview
This PR addresses Malysis malware-analysis quota exhaustion by counting denied on-demand submissions and surfacing a quota message at the end of a scan (console/summary/markdown summary), while also refactoring malware enricher wiring to reuse a query enricher instance.
Changes:
- Add quota-exceeded tracking on
PackageManifestand aggregate/display it in console, summary, and markdown-summary reporters. - Update Malysis malware enricher construction to pass a query enricher (intended as a fallback / shared component).
- Bump several Go module dependencies (grpc/protobuf/oauth2 and related indirect deps).
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scan.go | Refactors malware enricher setup; introduces shared query enricher construction. |
| pkg/scanner/enrich_malware.go | Adds ResourceExhausted/quota handling and new constructor parameter for query enricher. |
| pkg/scanner/enrich_malware_test.go | Updates tests for the new NewMalysisMalwareEnricher signature. |
| pkg/models/models.go | Adds manifest-level internal quota counter and accessor methods (with RWMutex). |
| pkg/reporter/common.go | Adds quota error counter type and quota-limit message renderer. |
| pkg/reporter/console.go | Accumulates and prints quota-limit message on finish. |
| pkg/reporter/summary.go | Accumulates and prints quota-limit message on finish. |
| pkg/reporter/markdown_summary.go | Adds quota-limit message section to markdown summary output. |
| pkg/reporter/summary_test.go | Adds unit test for quota-limit message rendering. |
| go.mod / go.sum | Dependency updates consistent with go mod tidy output. |
Comments suppressed due to low confidence (2)
pkg/scanner/enrich_malware.go:83
malysisMalwareAnalysisQueryEnricheris stored on the struct but never used, yet the comment says it is used as a fallback for entitlement issues. Either implement the fallback behavior (e.g., invoke the query enricher on entitlement errors) or remove/adjust this field/comment to avoid a misleading API expansion.
var _ PackageMetaEnricher = (*malysisMalwareEnricher)(nil)
pkg/scanner/enrich_malware.go:175
- New quota-limit behavior should have a focused unit test (e.g., simulate a
codes.ResourceExhaustedsubmission error and assert it increments the manifest counter and does not fail the enrichment). This will also prevent regressions around gRPC error wrapping/status extraction.
return fmt.Errorf("failed to submit package for analysis: %w", err)
}
// Wait for the analysis to complete
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #674 +/- ##
=====================================
Coverage 8.79% 8.80%
=====================================
Files 302 302
Lines 42445 42484 +39
=====================================
+ Hits 3735 3739 +4
- Misses 38383 38418 +35
Partials 327 327 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@abhisek resolved comments. |

fixes https://github.com/safedep/control-tower/issues/758