Skip to content

security: address code scanning and secret scanning alerts - #25

Merged
rathboma merged 2 commits into
mainfrom
security/fix-code-scanning-alerts
May 8, 2026
Merged

security: address code scanning and secret scanning alerts#25
rathboma merged 2 commits into
mainfrom
security/fix-code-scanning-alerts

Conversation

@rathboma

@rathboma rathboma commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Triaged the open GitHub code scanning and secret scanning alerts and fixed the legitimate ones.

Code scanning

Secret scanning

Both alerts were placeholder Atlas URIs in blog posts that nonetheless match the Atlas URI detector:

  • docs/blog/posts/mongodb-atlas-cloud-deployment-management.md: switched to <user>:<pass> placeholders inside the SQL sample.
  • docs/blog/posts/mongodb-vector-search-ai-applications-semantic-similarity.md and docs/blog/posts/mongodb-gridfs-file-management-sql.md: switched the JS samples to read process.env.MONGODB_URI, which is what we'd recommend in real code anyway.

Already-dismissed / not addressed

  • Bump js-yaml from 3.14.1 to 3.14.2 #33 js/polynomial-redos — already dismissed.
  • All other alerts (js/hardcoded-credentials, the workflow permissions on ci.yml, lib parser fixed, etc.) are already in the fixed state.

Test plan

  • yarn typecheck
  • yarn workspace @queryleaf/lib test:unit
  • yarn workspace @queryleaf/postgres-server test:unit
  • yarn workspace @queryleaf/lib build and yarn workspace @queryleaf/postgres-server build
  • CI green
  • Confirm code scanning re-runs and clears the listed alerts

- Add explicit `permissions: contents: read` to test.yml and publish.yml
  workflows. Grant `contents: write` on the publish job for releases.
- Redact password / SQL payloads in protocol-handler debug logs so
  the password message and credential-bearing SQL never hit clear-text
  output. Same redaction applied to lib/parser.ts logging.
- Replace Math.random() with crypto.randomInt for the backend secret
  key in BackendKeyData — that key authenticates CancelRequest, so it
  needs to be unguessable.
- Stop logging full SQL strings in postgres-server integration test
  mocks; log query length only.
- Replace `mongodb+srv://username:password@cluster.mongodb.net` style
  placeholders in three blog posts so they no longer trip the Atlas
  URI secret scanner. Switched code samples to env vars and the SQL
  sample to `<user>:<pass>` placeholders.
Comment thread packages/postgres-server/tests/integration/minimal-integration.test.ts Dismissed
Comment thread packages/postgres-server/tests/integration/minimal.integration.test.ts Dismissed
Pull the credential-masking regex into packages/lib/src/redact.ts and
re-export it from the lib's public surface so postgres-server can pull
it in instead of carrying its own copy.

Also extend the basic.test.ts mock to spread the real module before
overriding QueryLeaf, otherwise the new redactSql import resolves to
undefined inside the handler under test.
@rathboma
rathboma merged commit d9b03f8 into main May 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants