Skip to content

Wildcard --maphost values (* and *:*) are unreachable from the CLI #23

Description

@korya

Problem

hostMapping.Matches explicitly supports wildcard sources:

if r.Src == "*" || r.Src == "*:*" {
    return true
}

and TestHostMapping_Matches covers them. But parseHostMappings requires a : in the source and requires the source port to parse as an integer, so neither form can ever be constructed from the command line.

Reproduction

$ http-assert --maphost '*=127.0.0.1:8791' --assert-ok http://nope.invalid/ok
Error: Invalid value for --maphost flag: [*=127.0.0.1:8791]
[exit=71]

$ http-assert --maphost '*:*=127.0.0.1:8791' --assert-ok http://nope.invalid/ok
Error: Invalid value for --maphost flag: [*:*=127.0.0.1:8791]
[exit=71]

--maphost '*:80=127.0.0.1:8791' works correctly.

Why it went unnoticed

Tests cover the matcher but not the parser→matcher round trip, so the two halves disagree without failing CI.

Affected code

main.go — parseHostMappings vs hostMapping.Matches

Suggested fix

Decide which behaviour is intended. Either allow * / *:* through the parser, or delete the unreachable branches in Matches and their tests.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions