Repository navigation
Validate proxy-auth-type value and match it case-insensitively (AST-193576) - #1621
Conversation
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>
Upgrade testify to v1.12.1, OpenTelemetry modules to v1.47.0, and yaml/v3 to v3.0.5.
cx-hitesh-madgulkar
left a comment
There was a problem hiding this comment.
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 |
… (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>
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-typeaccepted 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:
wrappers.ValidateProxyAuthType()accepts empty (treated asbasic),basic,ntlm,kerberosandkerberos-native, case-insensitively and ignoring surrounding spaces.PersistentPreRunEright afterLoadConfiguration(), so the flag,CX_PROXY_AUTH_TYPEand the config file are all covered. It runs before any proxy connection attempt and also when--ignore-proxyis set.invalid proxy authentication type "X": supported types are basic, ntlm, kerberos, kerberos-native (set via --proxy-auth-type or CX_PROXY_AUTH_TYPE).GetClientuses the same case-insensitive matching, soNTLMnow really selects NTLM.http://classic.company.com:8080works as before).Type of Change
Related Issues
AST-193576
Checklist
Additional Notes
Behavior change: anyone currently passing an unsupported
--proxy-auth-type/CX_PROXY_AUTH_TYPEvalue 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,GetClientclient 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-lintreports 0 issues on the changed lines.Known limitations / pre-existing:
kerberosandkerberos-nativeclient construction callsos.Exitwithout an SPN, so it isn't unit-tested; validation of those values is covered.cx hooks ..., includingcheck-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 theGetClient()fallback as is: an unsupported value still falls back to basic for those commands, with only a verbose-mode log line (stderr).internal/wrappers,TestSetAgentNameAndOrigin,TestGetDefaultEnginesandTestGetEnabledEnginesfail independently of this change.🤖 Generated with Claude Code