Skip to content

Potential fix for code scanning alert no. 3: Clear-text logging of sensitive information#146

Merged
utkarsh232005 merged 1 commit into
mainfrom
alert-autofix-3
Jun 8, 2026
Merged

Potential fix for code scanning alert no. 3: Clear-text logging of sensitive information#146
utkarsh232005 merged 1 commit into
mainfrom
alert-autofix-3

Conversation

@utkarsh232005

@utkarsh232005 utkarsh232005 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Potential fix for https://github.com/KDM-cli/kdm-cli/security/code-scanning/3

Best fix: stop emitting any value derived from provider.password in logs.
In src/commands/auth.ts, replace the “Password” line to print only presence status, and update masking helper accordingly (or stop using it for output). This preserves functionality (users still know whether credentials are configured) without leaking secret fragments.

Concrete changes:

  • In getMaskedSecret, return only '(set)' or '(not set)', without reading or slicing secret contents beyond existence check.
  • Keep line 314 structure intact but now it logs only safe status from getMaskedSecret(p).

No new imports or dependencies are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Summary by CodeRabbit

  • Bug Fixes
    • The auth list command now displays provider credential status as "(set)" or "(not set)" instead of masked values.

…nsitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@utkarsh232005 utkarsh232005 marked this pull request as ready for review June 8, 2026 13:45
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (2)
Validation error: Invalid input: expected string, received undefined at "reviews.path_instructions[3].path"; Invalid input: expected string, received undefined at "reviews.path_instructions[3].instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

The auth list command's credential display is simplified: getMaskedSecret now returns plain status strings (set) or (not set) based on password presence instead of returning masked character patterns. This reduces output verbosity while maintaining the distinction between configured and unconfigured credentials.

Changes

Credential Presence Status Display

Layer / File(s) Summary
Credential presence status display
src/commands/auth.ts
getMaskedSecret function is refactored to return credential presence indicators—(set) when credentials exist, (not set) otherwise—removing the previous masking logic that showed partial prefix/suffix patterns.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A masked secret hops away,
Status tags take center stage today,
(set) or (not set) we now shall see,
Simpler truths, no masquerade—just be!
The auth list hops more light and free! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the primary change: modifying how sensitive credentials are displayed to prevent clear-text logging of sensitive information.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 alert-autofix-3

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 and usage tips.

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Hi @utkarsh232005, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/commands/auth.ts (1)

389-389: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update command description to reflect new behavior.

The description states "List configured AI providers with masked secrets," but the implementation now displays credential presence status ((set) or (not set)) rather than masked secrets. Update the description for accuracy.

📝 Suggested description update
-    .description('List configured AI providers with masked secrets')
+    .description('List configured AI providers with credential status')
🤖 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 `@src/commands/auth.ts` at line 389, Update the command description string used
in the auth command builder (the .description(...) call in src/commands/auth.ts)
to accurately reflect the current behavior: it no longer shows masked secrets
but instead displays credential presence status like "(set)" or "(not set)".
Replace the existing text "List configured AI providers with masked secrets"
with a concise phrase such as "List configured AI providers and show credential
presence (set/not set)" so the description matches the implementation.
🤖 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/auth.ts`:
- Around line 69-76: Update the test in src/__tests__/auth.test.ts to match the
new output of getMaskedSecret: replace the expectation that checks for the
obfuscated key string (e.g., 'supe...ikey') with the literal '(set)' when
provider.password is present; locate the assertion referencing auth list output
and change its expected value to '(set)' so it aligns with the
getMaskedSecret(provider: AIProviderConfig) implementation.

---

Outside diff comments:
In `@src/commands/auth.ts`:
- Line 389: Update the command description string used in the auth command
builder (the .description(...) call in src/commands/auth.ts) to accurately
reflect the current behavior: it no longer shows masked secrets but instead
displays credential presence status like "(set)" or "(not set)". Replace the
existing text "List configured AI providers with masked secrets" with a concise
phrase such as "List configured AI providers and show credential presence
(set/not set)" so the description matches the implementation.
🪄 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 Plus

Run ID: 646b5795-3f9b-4a7b-b905-9c17c4e6b839

📥 Commits

Reviewing files that changed from the base of the PR and between 58b06ec and 3763b6c.

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

Comment thread src/commands/auth.ts
Comment on lines 69 to 76
/**
* Masks secrets/API keys to avoid leaking them in plain text display.
* Returns a non-sensitive credential status for display.
* @param provider The AI provider configuration.
* @returns Masked representation.
* @returns '(set)' when a password exists, otherwise '(not set)'.
*/
const getMaskedSecret = (provider: AIProviderConfig): string => {
const secret = provider.password;
if (!secret) return '(not set)';
if (secret.length <= 8) return '********';
return `${secret.substring(0, 4)}...${secret.substring(secret.length - 4)}`;
return provider.password ? '(set)' : '(not set)';
};

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find test assertions that expect the old masked secret format

# Search for test files asserting on masked credential patterns
rg -n -C3 --type=ts --glob='**/*test*' -e 'supe.*ikey|stringContaining.*\.\.\.' -e 'getMaskedSecret' -e 'auth.*list'

Repository: KDM-cli/kdm-cli

Length of output: 1057


Update auth list test expectations for credential status output.
src/__tests__/auth.test.ts currently asserts expect(...).toHaveBeenCalledWith(...'supe...ikey'), but getMaskedSecret now returns '(set)' when provider.password exists (and '(not set)' otherwise). Change the assertion to expect '(set)' to match the new output format.

🤖 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 `@src/commands/auth.ts` around lines 69 - 76, Update the test in
src/__tests__/auth.test.ts to match the new output of getMaskedSecret: replace
the expectation that checks for the obfuscated key string (e.g., 'supe...ikey')
with the literal '(set)' when provider.password is present; locate the assertion
referencing auth list output and change its expected value to '(set)' so it
aligns with the getMaskedSecret(provider: AIProviderConfig) implementation.

@utkarsh232005 utkarsh232005 merged commit dbbb64f into main Jun 8, 2026
34 of 36 checks passed
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🤖 I'm sorry @utkarsh232005, but I was unable to process your request. Please see the logs for more details.

@utkarsh232005 utkarsh232005 deleted the alert-autofix-3 branch June 9, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant