Allow/Deny Proxy targets not working for DomainNameWildCard
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.4k
- Forks
- 1.5k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 16
Description
Proposal
Summary
Domain name and domain name wildcards are not currently supported when allowing/denying proxy targets. Eventhough they are referenced in documentation.
Description
Ip addresses are working fine.
When a domain name or wildcard is used to allow a proxy target, the proxy target is denied with error message:
The target proxy address is denied in WireMock's configuration.
When a domain name or wildcard is used to deny a proxy target, the proxy target is proxied successfully.
Issue
ProxyResponseRenderer:151 uses the host address all the time, even for domain matching.
When --allow-proxy-targets wiremock.org is used, ProxyResponseRenderer uses 185.199.110.153 to evaluate the DomainNameWildCard:121 pattern.
Solution
Make ProxyResponseRenderer:151 to use a hostname for DomainNameWildCard pattern evaluation, and keep using host address for SingleIp and IpRange pattern evaluation.
Configuration used
Standalone
java -jar wiremock-jre8-standalone-2.35.0.jar \
--port 9090 \
--enable-browser-proxying \
--allow-proxy-targets *.wiremock.org,wiremock.org \
--deny-proxy-targets wiremock.io
Java
new WireMockServer(
options()
.port(9090)
.enableBrowserProxying(true)
.limitProxyTargets(
NetworkAddressRules
.builder()
.allow("*.wiremock.com.org")
.allow("wiremock.com.org")
.deny("wiremock.io")
.build()));
Reproduction steps
- Start a wiremock server with allow proxy target configuration:
java -jar wiremock-jre8-standalone-2.35.0.jar \
--port 9090 \
--enable-browser-proxying \
--allow-proxy-targets wiremock.org
- Make a proxy call to the allowed proxy target:
curl --location 'http://wiremock.org' -x 'http://localhost:9090'
Expected:
- Successful response with
wiremock.orgcontent
Actual:
The target proxy address is denied in WireMock's configuration.
References
Wiremock documentation references
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/main/java/com/github/tomakehurst/wiremock/http/ProxyResponseRenderer.java at the referenced line, then inspect DomainNameWildCard in src/main/java/com/github/tomakehurst/wiremock/common/NetworkAddressRange.java. Reproduce the behavior with the documented --allow-proxy-targets configuration and curl request. Done means hostname wildcards and domain names are evaluated correctly while single IP addresses and IP ranges retain host-address matching.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100