New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: correct port validation #7077
Conversation
68754d2
to
1cfcb44
Compare
package.json
Outdated
@@ -183,6 +183,7 @@ | |||
"getos": "^3.2.1", | |||
"got": "^14.2.1", | |||
"hpagent": "^1.2.0", | |||
"is-elevated": "^4.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of this library as it has no support, not been updated since Aug 11, 2021, it fetched two other library the is-admin
and is-root
which have the same problem.
The is-admin
is running the following on windows fsutil dirty query C:
and the is-root
is simply checking the user uid..
I don't know what is our policy for adding packages cc @benoitf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not proceed with this library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, the library is OK from maintenance POV as they're managed by sindresorhus so there is support
but I'm not sure why we would need that library, I mean, in which case people run Podman Desktop with admin privileges ?
I would not allow ports < 1024 in all cases (Windows, macOS or Linux)
also Podman Desktop could be run in admin mode but the gvproxy in user mode so it would fail anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not allow ports < 1024 in all cases (Windows, macOS or Linux)
This simplifies the whole checks, will going to update the PR by removing this check.
I just rely on that scenario, that all ports, that are below 1024 by default requires administrative permissions to expose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vzhukovs yes but I think it's simpler/easier/more robust to not allow that anyway using Podman Desktop
thanks for updating the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benoitf new changes are in place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why we need to have an object being returned that provides the value and an optional error message vs the method returning the value or throw an error ?
I mean, why we can't rely on catching an error vs returning an object ?
Because, we will have situation, when the method will return It's just to simplify the processing the final checking result. Because when the port is not available, there should be a reason why. WDYT? |
I'd say the same thing as @benoitf: there doesn't seem to be a need for a new type to return both a boolean and a message: either the port is free and we need no message or it's not and we need a message. We don't need to expose any underlying errors directly - we can catch them and |
@deboer-tim @axel7083 new changes are in place |
Signed-off-by: Vladyslav Zhukovskyi <[email protected]>
Signed-off-by: Vladyslav Zhukovskyi <[email protected]>
if (isNaN(port) || port > 65535) { | ||
throw new Error('The port must have an integer value within the range from 1025 to 65535.'); | ||
} else if (port < 1024) { | ||
throw new Error('The port must be greater than 1024.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice having custom message 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
Side note: I wonder if we should use NumberInput here (in another PR), would block non-numerical entry and provide +/- for small changes.
Submitted an issue for this proposal: #7198 |
What does this PR do?
The following changes request provides better port validation process for Run Images dialog.
Screenshot / video of UI
What issues does this PR fix or reference?
#6390
How to test this PR?
Try to create two different containers with same exposed port to check that new port is proposed in Run Image dialog and validation of input works proper.