Add undici-based HTTP/HTTPS proxy support with tests and documentation - #39
Add undici-based HTTP/HTTPS proxy support with tests and documentation#39rattalur wants to merge 13 commits into
Conversation
Co-authored-by: rattalur <145406381+rattalur@users.noreply.github.com>
Co-authored-by: rattalur <145406381+rattalur@users.noreply.github.com>
Add HTTP/HTTPS proxy support via undici ProxyAgent
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Comprehensibility | 1 minor |
🟢 Metrics 40 complexity · 0 duplication
Metric Results Complexity 40 Duplication 0
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
The implementation correctly introduces proxy support using undici, and the project remains 'up to standards' according to Codacy. However, there is a logic flaw that should be addressed before merging: the current configuration only checks the NO_PROXY bypass for the primary Codacy API host during initialization.
Because the undici.ProxyAgent is not initialized with the noProxy configuration, all other outbound requests (such as fetching CVE data from Mitre) will be forced through the proxy even if they are explicitly listed in the environment variables. Leveraging the library's native bypass support will provide a more robust and standard-compliant implementation.
About this PR
- The implementation should aim for full parity with standard networking tools by ensuring all outbound requests—not just the primary API calls—respect the
NO_PROXYconfiguration. Transitioning to the nativenoProxyoption inundiciwill solve this systemically.
Test suggestions
- Verify resolveProxyUrl handles precedence (HTTPS > HTTP) and case-insensitivity correctly.
- Verify shouldBypassProxy handles exact matches, suffix matches, and the wildcard '*' correctly.
- Verify configureProxyFromEnv installs the global dispatcher with the resolved URL.
- Verify configureProxyFromEnv skips installation if the API host matches a NO_PROXY entry.
- Verify proxy bypass logic respects the custom hostname from CODACY_API_BASE_URL.
TIP How was this review? Give us feedback
Co-authored-by: rattalur <145406381+rattalur@users.noreply.github.com>
Fix `npm run build` failing with missing `api/client` module errors
Co-authored-by: rattalur <145406381+rattalur@users.noreply.github.com>
Document NODE_EXTRA_CA_CERTS for TLS-intercepting corporate proxies
This pull request adds support for running the CLI behind an HTTP or HTTPS proxy, configurable via standard environment variables. It introduces a new utility for proxy configuration, updates documentation to describe proxy usage, and adds direct support for proxying all API requests. The implementation ensures that proxy settings are respected consistently, including bypass logic via
NO_PROXY, and is fully tested.Proxy support implementation:
src/utils/proxy.ts) that resolvesHTTP_PROXY/HTTPS_PROXY(case-insensitive), honorsNO_PROXYfor bypassing, and installs anundici.ProxyAgentas the global dispatcher for all outbound API requests.src/index.ts) to callconfigureProxyFromEnv()before any API configuration or command registration, ensuring proxy settings are applied globally. [1] [2]Dependencies and testing:
undicias a direct dependency inpackage.jsonto provide the proxy agent and dispatcher.src/utils/proxy.test.ts.Documentation updates:
README.md(new "Proxy Support" section),AGENTS.md(environment variable table), andSPECS/README.md(feature changelog). [1] [2] [3] [4]Resolves Issue #40