Skip to content

address pending comments from amp's review and fix lint errors#7

Open
Kiran01bm wants to merge 3 commits intoblock:mainfrom
Kiran01bm:kiran01bm-address-pending-rcs
Open

address pending comments from amp's review and fix lint errors#7
Kiran01bm wants to merge 3 commits intoblock:mainfrom
Kiran01bm:kiran01bm-address-pending-rcs

Conversation

@Kiran01bm
Copy link
Copy Markdown
Contributor

@Kiran01bm Kiran01bm commented Apr 12, 2026

What and Why ?

This PR applies suggestions from amp's internal code review. These changes address 3 main areas: preventing misuse of the generic EOL provider for products with non-standard schemas, eliminating code duplication in inventory sources, and improving documentation for design decisions.

This PR also bulk addresses all the lint check failures in a disctinct atomic commit.

Changes

1. EKS Non-Standard Schema Protection 🔒

Problem: EKS uses a non-standard schema on endoflife.date where cycle.EOL means "end of standard support" (NOT true EOL). If someone accidentally used the generic endoflife.Provider for EKS instead of the dedicated
EKSEOLProvider, dates would be silently wrong.

Solution:

  • Added ProductsWithNonStandardSchema = []string{"amazon-eks"} blocklist
  • Guard in ListAllVersions() rejects blocked products with clear error:
    engine eks (product: amazon-eks) uses non-standard endoflife.date schema
    and cannot use generic provider; use dedicated provider instead (e.g., EKSEOLProvider)
  • Enhanced documentation explaining standard vs. non-standard field semantics
  • Added test TestProvider_BlocksNonStandardSchema() verifying all EKS variants are blocked

2. CSV Duplication Elimination 🧹

Problem: Aurora, EKS, and ElastiCache inventory sources had ~43 lines of identical CSV-row-iteration + error-handling logic, risking copy-paste drift.

Solution:

  • Created shared parseWizReport() helper in pkg/inventory/wiz/helpers.go
  • Accepts row parser and filter functions for flexibility
  • Reduced each inventory source from ~43 lines → ~13 lines
  • Removed all //nolint:dupl comments

Impact:

  • ~90 lines of duplicated code eliminated
  • Single source of truth for CSV iteration logic
  • Future inventory sources (DocumentDB, Neptune) can reuse pattern

3. Version-Not-Found Design Documentation 📝

Problem: Missing explanation for why providers return lifecycle with empty Version rather than error when version not found.

Solution: Added comprehensive design decision comments to all three EOL providers:

// Design Decision: Return lifecycle with empty Version rather than error
// Rationale:
//   - Maintains observability: Resource tracked with UNKNOWN status vs lost entirely
//   - Graceful degradation: Workflow continues during partial API outages
//   - Policy decides: EOL provider fetches data, policy layer interprets "unknown"
//
// Alternative (rejected): Return error - would cause workflow to skip resource,
// losing visibility into resources with incomplete EOL data coverage.

Breaking Changes

None. All changes are backward compatible

  • Blocking EKS in generic provider is a new guard (wasn't working correctly before)
  • CSV refactoring is internal implementation (same behavior)
  • Documentation improvements are non-functional

@Kiran01bm Kiran01bm requested a review from bakayolo as a code owner April 12, 2026 23:34
@Kiran01bm Kiran01bm force-pushed the kiran01bm-address-pending-rcs branch from d189ca6 to 4cfa6d9 Compare April 12, 2026 23:43
Kiran01bm and others added 2 commits April 13, 2026 10:52
Co-authored-by: Claude Code <noreply@anthropic.com>
Ai-assisted: true
Co-authored-by: Claude Code <noreply@anthropic.com>
Ai-assisted: true
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 66.27907% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/inventory/wiz/eks.go 0.00% 8 Missing ⚠️
pkg/inventory/wiz/helpers.go 63.15% 4 Missing and 3 partials ⚠️
pkg/workflow/detection/activities.go 50.00% 2 Missing and 2 partials ⚠️
pkg/eol/aws/eks.go 72.72% 2 Missing and 1 partial ⚠️
pkg/eol/aws/rds.go 50.00% 1 Missing and 1 partial ⚠️
pkg/eol/endoflife/client.go 50.00% 1 Missing and 1 partial ⚠️
pkg/eol/endoflife/provider.go 86.66% 1 Missing and 1 partial ⚠️
pkg/inventory/wiz/http_client.go 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
cmd/server/main.go 0.00% <ø> (ø)
pkg/inventory/wiz/aurora.go 81.98% <100.00%> (ø)
pkg/inventory/wiz/elasticache.go 80.24% <100.00%> (ø)
pkg/snapshot/store.go 3.49% <ø> (ø)
pkg/inventory/wiz/http_client.go 0.00% <0.00%> (ø)
pkg/eol/aws/rds.go 86.20% <50.00%> (ø)
pkg/eol/endoflife/client.go 63.63% <50.00%> (ø)
pkg/eol/endoflife/provider.go 85.43% <86.66%> (ø)
pkg/eol/aws/eks.go 85.55% <72.72%> (ø)
pkg/workflow/detection/activities.go 80.86% <50.00%> (ø)
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kiran01bm Kiran01bm changed the title address pending comments from amp's review address pending comments from amp's review and fix lint errors Apr 13, 2026
@revied
Copy link
Copy Markdown
Contributor

revied commented Apr 13, 2026

pkg/eol/endoflife/provider_test.gocontains() and indexOfSubstring() reimplement strings.Contains(). Can replace with:

import "strings"

// then:
if err != nil && !strings.Contains(err.Error(), "non-standard") {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants