Lower certificate expiry severity for strong replacements - #140
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33cc313cf9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| } | ||
|
|
||
| return $true |
There was a problem hiding this comment.
Verify SAN and key usage before lowering severity
When two certificates share the subject, issuer, private-key capability, and EKUs but have different Subject Alternative Name or Key Usage extensions, this function still returns true even though the candidate may not support the original certificate's hostnames or cryptographic operations. That causes the caller to downgrade an imminent-expiry failure to a warning, or a warning to a notice, for a certificate that has no functionally compatible replacement; compare these usage-defining extensions before classifying the candidate as strong.
Useful? React with 👍 / 👎.
Motivation
Description
Get-CertExpiryEnhancedKeyUsageIdsto normalize and compare enhanced key usage OIDs for certificates.Test-CertExpiryStrongReplacementCandidateto classify a candidate as a strong replacement when issuer,HasPrivateKey, and EKU sets match.Get-CertExpiryReplacementCandidateto prefer strong candidates over longer-lived weak candidates and to surface a strong/weak decision when selecting a candidate.FAILURE -> WARNING -> NOTICE) and records aSeverity adjustment:line in the finding comments; expanded Pester coverage intests/Unit/HealthTest-CertExpiry.Tests.ps1to exercise these behaviors and candidate-preference logic.Testing
git diff --checkand local diffs to validate the changes (no diff-check failures)../tests/run-unit-tests.ps1via PowerShell, but Windows PowerShell (pwsh/ PowerShell 5.1) was not available in this Linux container so the Pester tests were not executed here.tests/Unit/HealthTest-CertExpiry.Tests.ps1covering: detection of a strong candidate and severity lowering, notice conversion for upcoming expiry, non-lowering when EKUs differ, and preferring a strong candidate over a longer-lived weak candidate (these tests should be executed on Windows PowerShell 5.1 as described inAGENTS.md).Codex Task