Skip to content

Validate proxy-auth-type value and match it case-insensitively (AST-193576) - #1621

Merged
cx-sumit-morchhale merged 7 commits into
stagingfrom
bug/AST-193576-proxy-auth-type-validation
Nov 25, 2026
Merged

cx-sumit-morchhale merged 7 commits into
stagingfrom
bug/AST-193576-proxy-auth-type-validation

Conversation

@cx-atish-jadhav

@cx-atish-jadhav cx-atish-jadhav commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

By submitting this pull request, you agree to the terms within the Checkmarx Code of Conduct. Please review the contributing guidelines for guidance on creating high-quality pull requests.

Description

--proxy-auth-type accepted any value. Anything unsupported (e.g. NotARealAuthType) silently fell through to the basic proxy client, and valid values typed in another case (e.g. NTLM) were ignored the same way, so the wrong login method was used with no hint. The command then retried against the proxy and failed with an unrelated connection error.

What changed:

  • New wrappers.ValidateProxyAuthType() accepts empty (treated as basic), basic, ntlm, kerberos and kerberos-native, case-insensitively and ignoring surrounding spaces.
  • It is called in the root PersistentPreRunE right after LoadConfiguration(), so the flag, CX_PROXY_AUTH_TYPE and the config file are all covered. It runs before any proxy connection attempt and also when --ignore-proxy is set.
  • Unsupported values fail with a non-zero exit and: invalid proxy authentication type "X": supported types are basic, ntlm, kerberos, kerberos-native (set via --proxy-auth-type or CX_PROXY_AUTH_TYPE).
  • GetClient uses the same case-insensitive matching, so NTLM now really selects NTLM.
  • Proxy addresses are not touched (e.g. http://classic.company.com:8080 works as before).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Related Issues

AST-193576

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules
  • I have updated the CLI help for new/changed functionality in this PR (if applicable)
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

Additional Notes

Behavior change: anyone currently passing an unsupported --proxy-auth-type / CX_PROXY_AUTH_TYPE value will now get an error instead of silently using basic. Plugins that wrap the CLI may be worth a heads-up.

Tests added (all pass locally on top of staging):

  • internal/wrappers/client_test.go: supported, unsupported and uppercase values, GetClient client selection, --ignore-proxy, proxy address passed through unchanged.
  • internal/commands/root_test.go: end-to-end through the real startup hook via flag, env var and config file; empty/unset; uppercase; --ignore-proxy; several proxy address forms. The five "must be rejected" tests fail without the fix.
  • test/integration/auth_test.go: invalid value (also with --ignore-proxy) is rejected before any connection; needs no credentials.

golangci-lint reports 0 issues on the changed lines.

Known limitations / pre-existing:

  • kerberos and kerberos-native client construction calls os.Exit without an SPN, so it isn't unit-tested; validation of those values is covered.
  • Agent-hook commands (cx hooks ..., including check-auth) are intentionally out of scope. They skip the root pre-run hook by design, their stdout/exit codes are a contract with IDE and AI-agent integrations, and each integration handles authentication failures differently. To avoid changing that behavior or accidentally blocking users or disabling security guardrails, this PR does not add validation there and leaves the GetClient() fallback as is: an unsupported value still falls back to basic for those commands, with only a verbose-mode log line (stderr).
  • In internal/wrappers, TestSetAgentNameAndOrigin, TestGetDefaultEngines and TestGetEnabledEngines fail independently of this change.

🤖 Generated with Claude Code

An unsupported --proxy-auth-type value (e.g. "NotARealAuthType") was silently
treated as basic, and valid values typed in another case (e.g. "NTLM") were
ignored the same way. Validate the value right after the configuration is
loaded, so the flag, CX_PROXY_AUTH_TYPE and the config file are all covered,
and reject unsupported values before any proxy connection is attempted, also
when --ignore-proxy is set. GetClient now uses the same case-insensitive
matching. Proxy addresses are not affected.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cx-atish-jadhav
cx-atish-jadhav requested a review from a team as a code owner November 20, 2026 09:04
Upgrade testify to v1.12.1, OpenTelemetry modules to v1.47.0, and yaml/v3 to v3.0.5.

@cx-hitesh-madgulkar cx-hitesh-madgulkar 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.

Pls check the case where, proxy type is unknown?
I think it still silently fallback to basic proxy rather than giving any error

Comment thread internal/commands/root.go Resolved
Comment thread internal/wrappers/client.go Resolved
Comment thread internal/wrappers/client.go Resolved
Comment thread internal/commands/root_test.go Resolved
@cx-atish-jadhav

Copy link
Copy Markdown
Contributor Author

Pls check the case where, proxy type is unknown? I think it still silently fallback to basic proxy rather than giving any error

An unknown value is rejected on regular commands. For example, cx auth validate --proxy-auth-type NotARealAuthType exits 1 with invalid proxy authentication type "NotARealAuthType": supported types are basic, ntlm, kerberos, kerberos-native .... The only place that still falls back to basic is GetClient, and only for commands that skip the root pre-run hook (the agent-hook commands). I've added a verbose log line there and a comment in the follow-up commit

cx-atish-jadhav and others added 2 commits November 25, 2026 12:49
… (AST-193576)

Skip the proxy-auth-type validation for configure, version, help, completion
and the shell-completion commands, so an invalid stored value cannot lock a
user out of the very commands needed to repair it. Mention the config-file key
in the error message, and note at the GetClient fallback (with a verbose-only
log line) that commands skipping the root pre-run hook still fall back to
basic. Agent-hook commands are intentionally left unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cx-sumit-morchhale
cx-sumit-morchhale merged commit 3837802 into staging Nov 25, 2026
24 of 25 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.

4 participants