Skip to content
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

Wizard: Firewall ports input (HMS-5332) #2750

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

regexowl
Copy link
Collaborator

@regexowl regexowl commented Jan 15, 2025

This adds chipping input for ports on the Firewall step.

JIRA: HMS-5332

@regexowl
Copy link
Collaborator Author

/jira-epic HMS-5168

@schutzbot schutzbot changed the title Wizard: Firewall ports input Wizard: Firewall ports input (HMS-5332) Jan 15, 2025
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.88%. Comparing base (f5fa3d7) to head (e427198).

Files with missing lines Patch % Lines
src/store/wizardSlice.ts 73.68% 5 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2750      +/-   ##
==========================================
+ Coverage   84.86%   84.88%   +0.01%     
==========================================
  Files         184      185       +1     
  Lines       20827    20886      +59     
  Branches     2022     2031       +9     
==========================================
+ Hits        17675    17729      +54     
- Misses       3130     3135       +5     
  Partials       22       22              
Files with missing lines Coverage Δ
...ageWizard/steps/Firewall/components/PortsInput.tsx 100.00% <100.00%> (ø)
...ponents/CreateImageWizard/steps/Firewall/index.tsx 100.00% <100.00%> (ø)
...nents/CreateImageWizard/utilities/requestMapper.ts 94.84% <100.00%> (+0.12%) ⬆️
src/Components/CreateImageWizard/validators.ts 94.11% <100.00%> (+0.21%) ⬆️
src/store/wizardSlice.ts 88.70% <73.68%> (-0.41%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f5fa3d7...e427198. Read the comment docs.

lucasgarfield
lucasgarfield previously approved these changes Jan 15, 2025
Copy link
Collaborator

@lucasgarfield lucasgarfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Couple of nitpicks where we can tighten things up thanks to Typescript, and then should be ready for mergin'.

export const isPortValid = (port: string) => {
return (
port !== undefined &&
/^(\d{1,5}|[a-z]{1,4})(-\d{1,5})?:[a-z]{1,4}$/.test(port)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how you figured out the appropriate regex for this but it seems to work! 😅 I tested with these (from our docs):

[customizations.firewall]
ports = ["22:tcp", "80:tcp", "imap:tcp", "53:tcp", "53:udp", "30000-32767:tcp", "30000-32767:udp"]

It would be nice to add a comment with a reference, if you used one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked up port ranges, tried to look up list of protocols and put together this. It's not super tight though, I was already thinking about this - do we want to make the regexes very tight (which would usually mean quite long) or reasonably tight and more readable?

Like for example, this is a nicely tight regex for the port range: https://regex101.com/r/laGZzP/1 which we would need to further customize to fit our use case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonably tight and more readable! I think our validation goal should be removing footguns (mostly to prevent build failures) while being as un-opinionated as possible otherwise.

src/Components/CreateImageWizard/validators.ts Outdated Show resolved Hide resolved
});
});

describe('Firewall request generated correctly', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to also put the test for edit mode in this PR? Import mode, too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote edit mode tests when all parts of the step functionality were implemented. That way I wouldn't forget to update them later. Similar with import mode tests, those need a PR to setup on-prem import first.

Would prefer to continue the same workflow here to keep the PRs compact, but I'd say both approaches make sense. So whatever feels better I guess 🤷 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's fine then! Just want to make sure we don't forget. 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I'm following the same checklist we applied to steps that are already in stage-stable 😎

@lucasgarfield lucasgarfield dismissed their stale review January 15, 2025 21:03

Accidentally approved, meant to request changes.

Copy link
Collaborator

@lucasgarfield lucasgarfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally chose "Approve" in my last review. Please see comments I left for requested changes! 😄

@regexowl
Copy link
Collaborator Author

Thanks for the comments!

The smaller nit picks brought up a though - could we / should we tighten up type definitions in the API? We're currently using a mix of imported and custom types in the wizardSlice. The former usually allow undefined as a value, the later mostly don't, which causes inconsistencies in how we handle similar data. 🤔

@lucasgarfield
Copy link
Collaborator

Thanks for the comments!

The smaller nit picks brought up a though - could we / should we tighten up type definitions in the API? We're currently using a mix of imported and custom types in the wizardSlice. The former usually allow undefined as a value, the later mostly don't, which causes inconsistencies in how we handle similar data. 🤔

Let's start a discussion about this, maybe we can try to actually use the Github discussions feature! 😅
https://github.com/orgs/osbuild/discussions/41#discussion-7831601

This adds chipping input for ports on the Firewall step.
@lucasgarfield lucasgarfield merged commit 4802d08 into osbuild:main Jan 16, 2025
15 of 16 checks passed
@regexowl regexowl deleted the firewall-ports branch January 17, 2025 07:57
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.

2 participants