wiremock / wiremock/wiremock

Allow/Deny Proxy targets not working for DomainNameWildCard

Open
#2,248 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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
  1. 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
  1. Make a proxy call to the allowed proxy target:
curl --location 'http://wiremock.org' -x 'http://localhost:9090'

Expected:

  • Successful response with wiremock.org content

Actual:

The target proxy address is denied in WireMock's configuration.
References

Wiremock documentation references

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.