-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Maven plugin 11.0.0 does not respect nonProxyHosts #7072
Comments
I have the same problem... |
I have the following properties set in the JDK
It looks like http[s].proxy[Host/Port] are enforced, but not http.nonProxyHosts |
|
@miniupnp as we use Apache HTTPClient I can imagine JDK net.properties not taking effect (those are meant to configure core JDK HTTP classes' default configuration) @stklcode Can you check if on your side they also have the appropriate effect ( In my local testing I've used a squid docker container (see https://github.com/jeremylong/DependencyCheck/tree/main/src/test/manual-test-proxy-auth) and have seen both JAVA_TOOLS_OPTIONS and bypassing proxy
and
using proxy
and
|
Tested all (reasonable) combinations of http.* and https.* properties (all target URLs are HTTPS)
... intersting 🤔 Results exactly the same for Wondering why the property-based config works fine while DependencyCheck/maven/src/main/java/org/owasp/dependencycheck/maven/BaseDependencyCheckMojo.java Lines 2205 to 2221 in d2fce20
Update: Removing the --- a/maven/src/main/java/org/owasp/dependencycheck/maven/BaseDependencyCheckMojo.java
+++ b/maven/src/main/java/org/owasp/dependencycheck/maven/BaseDependencyCheckMojo.java
@@ -2219,24 +2219,6 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
System.setProperty("http.nonProxyHosts", mavenProxy.getNonProxyHosts());
}
}
-
- settings.setString(Settings.KEYS.PROXY_SERVER, mavenProxy.getHost());
- settings.setString(Settings.KEYS.PROXY_PORT, Integer.toString(mavenProxy.getPort()));
- final String userName = mavenProxy.getUsername();
- String password = mavenProxy.getPassword();
- if (password != null && !password.isEmpty()) {
- if (settings.getBoolean(Settings.KEYS.PROXY_DISABLE_SCHEMAS, true)) {
- System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
- }
- try {
- password = decryptPasswordFromSettings(password);
- } catch (SecDispatcherException ex) {
- password = handleSecDispatcherException("proxy", mavenProxy.getId(), password, ex);
- }
- }
- settings.setStringIfNotNull(Settings.KEYS.PROXY_USERNAME, userName);
- settings.setStringIfNotNull(Settings.KEYS.PROXY_PASSWORD, password);
- settings.setStringIfNotNull(Settings.KEYS.PROXY_NON_PROXY_HOSTS, mavenProxy.getNonProxyHosts());
} else if (System.getProperty("http.proxyHost") != null) {
//else use standard Java system properties
settings.setString(Settings.KEYS.PROXY_SERVER, System.getProperty("http.proxyHost", "")); Update 2: The problem should be here: DependencyCheck/utils/src/main/java/org/owasp/dependencycheck/utils/Downloader.java Lines 149 to 153 in d2fce20
We explicitly override proxy server and credentials, but missing Because of the override the system properties are ignored and the nonProxyHosts are missing. So either we omit setting the "legacy" properties (see patch above) or we add a proper ProxySelector/RoutePlanner. |
@stklcode Right... that's anyhow a bug in the 'legacy compatibility mode' part of the Downloader. That should most certainly still honour the That it didn't work for all kinds of 'legacy' configurations went undetected for me as I have full access on my dev environment and during development only create a setup matching the documented modern proxy config with JAVA_TOOL_OPTIONS from the documentation. |
Thanks for digging a bit deeper, I hope to work on a fix tomorrow to ensure that the legacy compatibility code does take nonProxyHosts into account, not sure when Jeremy would have the time to cut a new release after that. Good to know that at least the -D option is also working for you in the documented proxy config. |
The Apache HTTPClient based downloader supports http(s).proxy* properties, so we do not need to use legacy logic. In legeacy mode http.nonProxyHosts is not honored, so setting both leads to issues due to missing proxy selectors. Omit populating legacy properties resolves this issue. In addition we have to move the password decryption from Maven settings up, so it actually works. Signed-off-by: Stefan Kalscheuer <stefan@stklcode.de>
Using You are right, the legacy stuff should work, too. But should we consider not populating both new and old configs? Using Maven e.g. the password property is missing potential decryption when setting This commit does repair all valid scenarios from properties and Maven for me: stklcode@196b029 Can create a PR if desired. |
The Apache HTTPClient based downloader supports http(s).proxy* properties, so we do not need to use legacy logic. In legeacy mode http.nonProxyHosts is not honored, so setting both leads to issues due to missing proxy selectors. Omit populating legacy properties resolves this issue. In addition we have to move the password decryption from Maven settings up, so it actually works. Signed-off-by: Stefan Kalscheuer <stefan@stklcode.de>
Sure PR would be welcomed, need a second look tomorrow with a fresh and energetic mind, but high-over review makes me suspect that on the second look I can accept your proposed change as the right patch for this issue. |
…emylong#7074) The Apache HTTPClient based downloader supports http(s).proxy* properties, so we do not need to use legacy logic. In legacy mode http.nonProxyHosts is not honored, so setting both leads to issues due to missing proxy selectors. Omit populating legacy properties resolves this issue. In addition, we have to move the password decryption from Maven settings up, so it actually works. Signed-off-by: Stefan Kalscheuer <stefan@stklcode.de>
Fix confirmed, the initial scenario runs fine again with v11.1.0 |
Describe the bug
After updating the Maven Plugin from 10.0.4 to 11.0.0 the proxy logic seems to be broken.
Scenario:
https://cache.example.com/nvdcve-{0}.json.gz
So we have to rely on
nonProxyHosts
to properly route the connections.With 11.0.0 we receive 503 responses from the proxy (the cache is online and available).
Disabling the global proxy makes these calls work again, but
www.cisa.gov
andjeremylong.github.io
fail with connection errors (as expected without proxy)With 10.0.4 it works as expected. I suspect some missing link from the HTTP client switch, but I didn't yet look deeper into it.
Version of dependency-check used
The problem occurs using version 11.0.0 of the maven plugin.
To Reproduce
Steps to reproduce the behavior:
Same behavior without the Maven settings and explicit proxy properties
Expected behavior
Local NVD CVE database should be updated from NVD cache, and external CISA resources and the checks run as usual.
Additional context
Tested with Java 17.0.12 and 21.0.4 and Apache Maven 3.9.9
No additional proxy-relatved environment variables or properties set.
The text was updated successfully, but these errors were encountered: