fix(EC-1993): reject past --effective-time values by default#3424
fix(EC-1993): reject past --effective-time values by default#3424cuipinghuo wants to merge 1 commit into
Conversation
Backdating --effective-time suppresses time-gated security rules at both the CLI level (severity demotion) and the Rego level (when_ns propagation). Reject effective-time values more than 5 minutes in the past unless --allow-past-effective-time is explicitly set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 6:26 PM UTC · Completed 6:31 PM UTC |
📝 WalkthroughWalkthroughThe change adds ChangesEffective-time control
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant validateImageCmd
participant policy.NewPolicy
participant parseEffectiveTime
participant rejectPastTime
validateImageCmd->>policy.NewPolicy: pass AllowPastEffectiveTime
policy.NewPolicy->>parseEffectiveTime: parse EffectiveTime
parseEffectiveTime->>rejectPastTime: validate timestamp
rejectPastTime-->>parseEffectiveTime: accept or return error
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review — commentPR: fix(EC-1993): reject past --effective-time values by default SummaryThis PR adds a security mitigation to prevent users from backdating The core logic in Findings1. Duplicate effective-time validation in
|
| if err != nil { | ||
| return fmt.Errorf("invalid effective time format: %w", err) | ||
| } | ||
| if !allowPastEffectiveTime { |
There was a problem hiding this comment.
[medium] correctness
Duplicate effective-time validation: compare.go implements its own past-time rejection using time.Now() directly and a hardcoded 5-minute threshold, independently from the shared rejectPastTime function and pastEffectiveTimeGracePeriod constant in internal/policy/policy.go. This creates two places to maintain the threshold (risking drift) and prevents clock-mocking in tests. No test coverage exists for this code path in compare.go.
Suggested fix: Refactor to delegate effective-time parsing to a shared utility from the policy package (e.g., export ParseAndValidateEffectiveTime), or at minimum reference the existing pastEffectiveTimeGracePeriod constant and add test coverage for the compare command validation path.
Backdating --effective-time suppresses time-gated security rules at both
the CLI level (severity demotion) and the Rego level (when_ns
propagation). Reject effective-time values more than 5 minutes in the
past unless --allow-past-effective-time is explicitly set.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
What:
Why:
and shifts the time reference for all Rego rules via when_ns (Rego level), effectively bypassing
security checks at the integration test gate where users control IntegrationTestScenario params
Tickets: