Add AWS Support evidence package helper#80
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces an AWS Support Evidence Package feature for generating redacted incident remediation reports. It adds documentation, a Node.js build script that reads a manifest and produces sanitized Markdown, a validation script with test fixture, and a README entry. ChangesAWS Evidence Package Feature
Sequence DiagramsequenceDiagram
participant User as User/Pipeline
participant CheckScript as check-aws-support-evidence-package
participant BuildScript as build-aws-support-evidence-package
participant TempManifest as Temp Manifest JSON
participant Output as Redacted Markdown
User->>CheckScript: npm run check
CheckScript->>CheckScript: Load fixture, append probe note
CheckScript->>TempManifest: Write modified manifest
CheckScript->>BuildScript: Execute with manifest path
BuildScript->>TempManifest: Load and parse JSON
BuildScript->>BuildScript: Redact account IDs, access keys, secrets
BuildScript->>BuildScript: Format sections (keys, env vars, CloudTrail, IAM, notes)
BuildScript->>Output: Write redacted Markdown to stdout
CheckScript->>Output: Assert required sections present
CheckScript->>Output: Assert forbidden patterns absent
CheckScript->>User: ✓ Check passed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
Privacy-safe demo for the offline CLI slice: node tools/build-aws-support-evidence-package.mjs tools/fixtures/aws-support-evidence-package.sample.json | sed -n '1,80p'
node tools/check-aws-support-evidence-package.mjsExpected behavior shown by the local run: I am keeping this as a terminal demo transcript instead of a UI recording because the tool is intentionally offline and uses only synthetic fixture data; no live AWS account, candidate data, screenshots, private exports, account IDs, access keys, or secret values were opened or recorded. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
tools/check-aws-support-evidence-package.mjs (1)
19-22: ⚡ Quick winConsider adding a timeout to prevent indefinite hangs.
The
execFileSynccall has no timeout. If the build script encounters an infinite loop or blocks on I/O, this validation script will hang indefinitely.⏱️ Proposed fix to add timeout
const output = execFileSync(process.execPath, [ "tools/build-aws-support-evidence-package.mjs", tmpManifest, -], { encoding: "utf8" }); +], { encoding: "utf8", timeout: 10000 });A 10-second timeout should be more than sufficient for generating a redacted Markdown report from a small JSON manifest.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/check-aws-support-evidence-package.mjs` around lines 19 - 22, The execFileSync call using process.execPath to run "tools/build-aws-support-evidence-package.mjs" with tmpManifest and encoding "utf8" can hang indefinitely; add a timeout option (e.g., 10000 ms) to the options object passed to execFileSync so the call throws if it exceeds the limit; update the call site where execFileSync(...) is invoked to include { encoding: "utf8", timeout: 10000 } (or similar) to prevent indefinite blocking.tools/build-aws-support-evidence-package.mjs (1)
14-14: 💤 Low valueWrap manifest load in try/catch for actionable errors.
A missing path or invalid JSON currently surfaces a raw Node stack trace (
ENOENT,SyntaxError: Unexpected token …). Since this tool is invoked manually during an incident workflow, a friendly diagnostic is worth the few extra lines.♻️ Proposed fix
-const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); +let manifest; +try { + manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); +} catch (err) { + console.error( + `Failed to load manifest at ${manifestPath}: ${err.message}`, + ); + process.exit(1); +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/build-aws-support-evidence-package.mjs` at line 14, The manifest loading line using JSON.parse(fs.readFileSync(manifestPath, "utf8")) should be wrapped in a try/catch so missing files or bad JSON produce a clear, actionable error; catch errors around reading/parsing manifestPath, log a friendly diagnostic that includes manifestPath and the caught error.message (and optionally error.stack for debug), and then exit with a non‑zero status (or rethrow) instead of letting a raw stack trace surface; update the code where manifest is declared to assign inside the try block and reference manifestPath, fs.readFileSync, and JSON.parse when implementing the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tools/build-aws-support-evidence-package.mjs`:
- Around line 30-51: The table cells are not escaped, so any pipe or newline in
values will break Markdown; update line(value) to first call redact(value ||
"not provided"), then escape all pipe characters (replace "|" with "\|") and
collapse all newline characters (replace sequences of \r?\n with a single space)
before returning; this change will automatically fix output for list(values) and
table(headers, rows) since they call line(), so ensure line() is the single
place performing escaping and newline normalization.
In `@tools/check-aws-support-evidence-package.mjs`:
- Around line 15-22: The temp directory created as tmpDir (and tmpManifest) is
never removed; wrap the creation, write, and execFileSync call plus the
subsequent validation logic currently after line 24 inside a try block, add a
finally block that always removes tmpDir and its contents (e.g., using
fs.rmSync(tmpDir, { recursive: true, force: true }) or equivalent) so cleanup
runs on success or error, and ensure any thrown errors are propagated after
cleanup; reference tmpDir, tmpManifest, execFileSync, and the build script
invocation ("tools/build-aws-support-evidence-package.mjs") when applying the
change.
---
Nitpick comments:
In `@tools/build-aws-support-evidence-package.mjs`:
- Line 14: The manifest loading line using
JSON.parse(fs.readFileSync(manifestPath, "utf8")) should be wrapped in a
try/catch so missing files or bad JSON produce a clear, actionable error; catch
errors around reading/parsing manifestPath, log a friendly diagnostic that
includes manifestPath and the caught error.message (and optionally error.stack
for debug), and then exit with a non‑zero status (or rethrow) instead of letting
a raw stack trace surface; update the code where manifest is declared to assign
inside the try block and reference manifestPath, fs.readFileSync, and JSON.parse
when implementing the change.
In `@tools/check-aws-support-evidence-package.mjs`:
- Around line 19-22: The execFileSync call using process.execPath to run
"tools/build-aws-support-evidence-package.mjs" with tmpManifest and encoding
"utf8" can hang indefinitely; add a timeout option (e.g., 10000 ms) to the
options object passed to execFileSync so the call throws if it exceeds the
limit; update the call site where execFileSync(...) is invoked to include {
encoding: "utf8", timeout: 10000 } (or similar) to prevent indefinite blocking.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 29bd3743-4a88-42b8-8cf1-0deb079f3224
📒 Files selected for processing (5)
README.mddocs/security/aws-support-evidence-package.mdtools/build-aws-support-evidence-package.mjstools/check-aws-support-evidence-package.mjstools/fixtures/aws-support-evidence-package.sample.json
|
Follow-up after review automation:
Revalidated locally after those commits:
The PR now shows CodeRabbit and GitGuardian green on the latest head. |
/claim #55
Scope
This is a separate offline AWS Support evidence-package slice for the final restriction-removal checklist in #55. It does not overlap with the existing Civil ID, S3 env, SQS, MediaConvert, SES/mailers, Xero, Cloudinary, secret-scanning, bucket-guardrail, service-token, CloudTrail, IAM access-key review, S3 posture, Slack, or recovery-audit PRs.
No live AWS/IAM calls, key rotation/deletion, bucket policy changes, candidate data, access keys, secret keys, screenshots, private exports, account IDs, raw CloudTrail records, payment/tax data, or Civil ID files were accessed or included.
Summary
tools/build-aws-support-evidence-package.mjs, an offline CLI that reads a private JSON evidence manifest and emits a redacted Markdown package for AWS Support.Validation
node tools/check-aws-support-evidence-package.mjsnode --check tools/build-aws-support-evidence-package.mjsnode --check tools/check-aws-support-evidence-package.mjsgit diff --checkSummary by CodeRabbit
New Features
Documentation