fix(cloud-security): make CloudWatch metric-filter auto-fix reliable#3050
Merged
Conversation
Customer (aymenrc) reported AWS auto-fix falling back to manual steps with "required parameters were not properly provided… metric transformations were not properly provided to the CloudWatch Logs API" on the CIS CloudWatch metric-filter checks. That finding IS meant to be auto-fixable (PutMetricFilter + CreateTopic + PutMetricAlarm — all standard API calls), so this is a bug, not an inherently-manual finding. Root cause: PutMetricFilterCommand was absent from REQUIRED_PARAMS, so a step with a missing/mis-shaped `metricTransformations` wasn't caught before execution — it went to AWS, got rejected, and fell back to manual steps. The model commonly emits metricTransformations as a single object instead of an array, or metricValue as the number 1 instead of "1", both of which AWS rejects. - aws-command-executor: add PutMetricFilterCommand to REQUIRED_PARAMS (logGroupName, filterName, filterPattern, metricTransformations) so a missing field fails fast and triggers the existing AI repair pass; and add a deterministic normalizer (normalizeMetricFilterTransformations) that wraps a single transformation object in an array and coerces metricValue to a string. - ai-remediation.prompt: explicit PutMetricFilter shape guidance (metricTransformations array, string metricValue, real logGroupName). - Tests: REQUIRED_PARAMS enforcement + normalizer cases. Full cloud-security suite green (310 passing); changed files typecheck clean. Not yet verified against a live failing finding — covers the failure class. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Jun 5, 2026
Contributor
|
🎉 This PR is included in version 3.73.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Customer (aymenrc) reported AWS auto-fix falling back to manual steps with "required parameters were not properly provided… metric transformations were not properly provided to the CloudWatch Logs API" on the CIS CloudWatch metric-filter checks (e.g. "CloudTrail config changes — metric filter missing").
That finding is meant to be auto-fixable — the fix is three standard API calls (
logs:PutMetricFilter+sns:CreateTopic+cloudwatch:PutMetricAlarm,cloudwatch.adapter.ts:155), not[MANUAL]. So this is a bug, not an inherently-manual finding.Root cause
PutMetricFilterCommandwas not in the executor'sREQUIRED_PARAMS, so a step with a missing or mis-shapedmetricTransformationswasn't caught before execution — it went to AWS, got rejected, and the system fell back to manual steps. The model commonly emitsmetricTransformationsas a single object instead of an array, ormetricValueas the number1instead of"1"— both of which AWS rejects.Fix
aws-command-executor.tsPutMetricFilterCommandtoREQUIRED_PARAMS(logGroupName,filterName,filterPattern,metricTransformations) → a missing field now fails fast and triggers the existing AI repair pass instead of dumping to manual steps.normalizeMetricFilterTransformations(Rule 5 innormaliseInputParams): wrap a single transformation object in an array, and coercemetricValueto a string. Deterministic guardrail before the SDK call (mirrors the Config-recorder guardrail).ai-remediation.prompt.ts: explicitPutMetricFiltershape guidance —metricTransformationsas an array, stringmetricValue, reallogGroupNamefrom the read step.REQUIRED_PARAMSenforcement + normalizer cases (object→array, number→string, well-formed untouched, absent no-op).Notes / caveats
Full cloud-security suite green (310 passing); changed files typecheck clean.
🤖 Generated with Claude Code
Summary by cubic
Fixes unreliable auto-fix for CloudWatch Logs metric filters by validating required params and normalizing
metricTransformations, preventing fallbacks to manual steps on CIS checks.PutMetricFilterCommandtoREQUIRED_PARAMS(logGroupName,filterName,filterPattern,metricTransformations) to fail early and trigger the repair pass.normalizeMetricFilterTransformationsto wrap a single object into an array and coercemetricValueto a string.ai-remediation.prompt.tswith explicitPutMetricFiltershape guidance and using the reallogGroupNamefrom the read step.Written for commit 837ecde. Summary will update on new commits.