fix: resolve CodeQL alerts for logging, format strings, and ReDoS - #37
Conversation
Stop logging Error.message (pg/HTTP errors embed DSNs and API keys), pass user-controlled values as console format arguments instead of interpolating them into the format string, bound the relative-ago regex, and use exact Set membership in the domain extraction test. Co-authored-by: Skiipy <steven@expertlocal.ca>
|
PR author is not in the allowed authors list. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: ZenSystemAI/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds hashed error summaries, updates API and service logging call sites, moves Gemini credentials out of URLs, bounds relative-time parsing, and updates related tests. ChangesSanitized error logging
Credential-safe Gemini requests
Bounded temporal parsing
Domain test assertion update
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change reduces secret exposure, format-string injection, and regular-expression denial-of-service risk without introducing a known merge-blocking issue; it is merge-ready after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
CodeQL still flagged errorSummary() because Error.name/code inherit taint from GEMINI_API_KEY in request URLs. Log a SHA-256 fingerprint instead, send the Gemini key via x-goog-api-key, and omit URLs from timeout errors. Co-authored-by: Skiipy <steven@expertlocal.ca>
|
@coderabbitai review |
Summary
Fixes the open CodeQL alerts on
main(#2–#13): clear-text logging of secrets in error messages, format-string injection viaconsole.error, polynomial ReDoS in the temporal resolver, and a hostnameincludes()check in a unit test.Follow-up: CodeQL still flagged
errorSummary()because Error fields inherit taint fromGEMINI_API_KEYin request URLs. This PR now logs a SHA-256 fingerprint only, sends the Gemini key viax-goog-api-key, and omits URLs from timeout errors.Errorobjects from pg/HTTP clients can embed DSNs and API keys.logErrorlogs a 12-character SHA-256 fingerprint ofname/code/message(hashing is a CodeQL sanitizer), using a constantconsole.errorformat string. Call sites pass theErrorobject instead oferr.message.x-request-idand entity names were interpolated intoconsole.error’s format argument, so a value containing%scould consume later arguments. Those values are now%sdata arguments.(\d+)\s+(day|week|month|year)s?\s+agoon search queries is quadratic. The digit and whitespace repetitions are now bounded (\d{1,5},\s{1,8}).Array.includes('acme-corp.com'), which CodeQL treats as incomplete hostname sanitization. It now usesSet.has(exact match).x-goog-api-keyinstead of?key=so timeout errors cannot leak the API key.CodeRabbit reviewed HEAD (
2ec7a9e) with no actionable comments. All CI checks passed.Type of change
Checklist
API unit tests: 349 passed (includes
log.test.jscoverage for the format-string and fingerprint contracts).Summary by CodeRabbit