Skip to content

fix(doctor): a credential at rest is a FAILURE, not a healthy environment - #150

Open
chitcommit wants to merge 2 commits into
mainfrom
fix/doctor-credential-hard-block
Open

chitcommit wants to merge 2 commits into
mainfrom
fix/doctor-credential-hard-block

Conversation

@chitcommit

@chitcommit chitcommit commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

can doctor defined a complete dev environment as one that had already committed the violation.

Its token checks reported a value found in process.env or config.sync.{notionToken,githubToken} as healthy:

✓ NOTION_TOKEN: Set in environment
✓ GITHUB_TOKEN: Set in config

…and reported a clean environment as a warning whose remediation instructed the operator to create the violation:

⚠ GITHUB_TOKEN: Not configured
  → Set GITHUB_TOKEN environment variable or run: chitty sync setup

Both polarities were backwards. A credential must never be written into config, runtime, documentation or otherwise — so presence is the defect and absence is the healthy state.

What changed

The check is inverted, and the existing exit-code path does the enforcing: counts as failed, failed > 0 exits 1. A violating environment can no longer report itself ready.

Verified against real behaviour, both directions

environment result exit
clean ✓ no credential at rest in config or environment — 8 passed 0
token present ✗ credential present in runtime environment — hard block — 1 failed 1

Constraints honoured deliberately

This check runs over exactly the material it must never touch:

  • Only presence is tested. No value is read, logged, printed, or compared.
  • Nothing is removed or rewritten. Grep-and-destroy is unsound here — config may legitimately hold an item-ID reference rather than a value, and deleting on a name match would destroy the reference while leaving the real secret in place.

What it deliberately does NOT do

The remediation points at where credential material belongs — a node-sealed attachment, bound to the node and inert if copied off it — and explicitly tells the operator not to set the variable.

That attachment does not exist yet, and this PR does not check for it or stub it. A check against an undefined capability passes vacuously, which is precisely the failure mode this change removes.

Scope

This changes a health check's polarity to match stated policy. It does not design credential architecture — that is ChittyConnect's, and the attachment is owned there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01H6EB22mDgirBYomHn3hfyJ

Summary by CodeRabbit

  • New Features

    • Enhanced credential diagnostics to check both runtime settings and configuration.
    • Reports where credentials are detected and provides guidance for removing or provisioning them.
    • Never displays or changes credential values.
  • Bug Fixes

    • Credential checks now correctly fail when authentication tokens are present and pass when the environment is clean.

…ment

`can doctor` defined a complete dev environment as one that had already
committed the violation. Its token checks reported a value found in
`process.env` or in `config.sync.{notionToken,githubToken}` as:

    ✓ NOTION_TOKEN: Set in environment
    ✓ GITHUB_TOKEN: Set in config

and reported a CLEAN environment as a warning whose remediation instructed the
operator to create the violation:

    ⚠ GITHUB_TOKEN: Not configured
      → Set GITHUB_TOKEN environment variable or run: chitty sync setup

Both polarities were backwards. A credential must never be written into config,
runtime, documentation or otherwise — so presence is the defect and absence is
the healthy state. This inverts the check and lets the existing exit-code path
do the enforcing: ✗ counts as failed, failed>0 exits 1, so a violating
environment can no longer report itself ready.

Verified against real behaviour, both directions:

  clean env      ✓ no credential at rest in config or environment   8 passed, exit 0
  token present  ✗ credential present in runtime environment        1 failed, exit 1

Constraints honoured deliberately, because this check runs over exactly the
material it must never touch:

  - only PRESENCE is tested. No value is read, logged, printed or compared.
  - nothing is removed or rewritten. Grep-and-destroy is unsound here: config
    may legitimately hold an item-ID REFERENCE rather than a value, and deleting
    on a name match would destroy the reference while leaving the real secret.

The remediation now points at where credential material actually belongs — a
node-sealed attachment, bound to the node and inert if copied off it — and
explicitly tells the operator NOT to set the environment variable. That
attachment does not exist yet; this commit deliberately does not check for it or
stub it, because a check against an undefined capability would pass vacuously,
which is the failure mode this change exists to remove.

Scope note: this changes a health check's polarity to match stated policy. It
does not design credential architecture — that is ChittyConnect's, and the
attachment itself is owned there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H6EB22mDgirBYomHn3hfyJ
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@chitcommit, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 40dbbb2d-fd5f-43df-92e8-e3d4ec62ca87

📥 Commits

Reviewing files that changed from the base of the PR and between 5f52197 and f512ae8.

📒 Files selected for processing (2)
  • src/commands/doctor.ts
  • tests/doctor.test.ts
📝 Walkthrough

Walkthrough

The doctor command now treats configured or runtime NOTION_TOKEN and GITHUB_TOKEN values as hard failures. It reports their locations and removal guidance without reading or modifying credential values.

Changes

Credential exposure checks

Layer / File(s) Summary
Credential presence validation
src/commands/doctor.ts
The doctor command fails when NOTION_TOKEN or GITHUB_TOKEN exists in configuration or the runtime environment. It passes when both credentials are absent and reports removal guidance without exposing values.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and test results, but it omits most required template sections, including type, related issue, checklist, and test configuration. Use the repository template and complete the missing sections, including change type, related issue, test configuration, checklist, performance, breaking changes, and additional notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: credential presence now causes a doctor check failure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/doctor-credential-hard-block

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@src/commands/doctor.ts`:
- Around line 141-142: Update the credential presence checks in the doctor
command to use own-property checks on process.env and config.sync rather than
retrieving values through boolean coercion. Preserve the existing configPath
guard, treat empty-but-present environment variables and config keys as
configured, and remove the credential key instead of assigning an empty value.
🪄 Autofix

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 Plus

Run ID: 427e4ac4-967a-43cf-b792-ae445b2daa26

📥 Commits

Reviewing files that changed from the base of the PR and between 8b81072 and 5f52197.

📒 Files selected for processing (1)
  • src/commands/doctor.ts

Comment thread src/commands/doctor.ts Outdated
The credential-at-rest hard block used `!!process.env[cs.env]` and a
similarly truthy-coerced config lookup to decide presence. Both treat an
env var or config key set to the empty string as absent, so `GITHUB_TOKEN=`
(present, empty) reported ✓ "no credential at rest" instead of the intended
hard-block failure — silently defeating the check's own stated contract that
presence, not value, is what's being tested.

Switch to own-property checks (`hasOwnProperty` on process.env, and a new
hasNestedOwnProperty helper for the config path) that detect presence
without ever reading the credential value, closing the empty-string gap
while keeping the "value is never read" guarantee.

Flagged by coderabbitai review on PR #150.
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