Skip to content

Accept port 1 when validating published port ranges#2018

Open
devops-thiago wants to merge 1 commit into
apple:mainfrom
devops-thiago:fix-publish-port-one
Open

Accept port 1 when validating published port ranges#2018
devops-thiago wants to merge 1 commit into
apple:mainfrom
devops-thiago:fix-publish-port-one

Conversation

@devops-thiago

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Fixes #2014.

Parser.publishPort validates the lower bound of a parsed port range with a strict greater-than:

guard hostPortRangeStart > 1, ...
guard containerPortRangeStart > 1, ...

TCP and UDP port numbers start at 1, so --publish 1:80 and --publish 8080:1 are both rejected as invalid ranges. The same comparison rejects a range that starts at port 1, such as --publish 1-100:1-100.

Port 0 stays rejected under >= 1, since it means "any port" rather than a specific one. The existing tests that assert port 0 is refused cover that and still pass.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

testPublishPortOne publishes port 1 on both sides and checks the parsed host port, container port, and range length. The existing publish-port tests continue to pass, including testPublishPortRangeZeroHostPortStart and testPublishPortRangeZeroContainerPortStart, which confirm port 0 is still refused.

The lower bound for a published port range was checked with a strict
greater-than, so port 1 was reported as an invalid range on both the host
and container sides. TCP and UDP port numbers start at 1.

Port 0 remains rejected, since it means "any port" rather than a specific
one.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: --publish rejects port 1 as out of range

1 participant