-
Notifications
You must be signed in to change notification settings - Fork 53
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
wizrad: add validation to ssh key field (HMS-5349) #2764
Conversation
/jira-epic HMS-4181 |
9171d04
to
512a04e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
@@ Coverage Diff @@
## main #2764 +/- ##
==========================================
+ Coverage 84.75% 84.76% +0.01%
==========================================
Files 187 187
Lines 21270 21285 +15
Branches 2088 2095 +7
==========================================
+ Hits 18027 18042 +15
Misses 3221 3221
Partials 22 22
Continue to review full report in Codecov by Sentry.
|
1018e74
to
f10fad2
Compare
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.
Added some comments
export const isSshKeyValid = (sshKey: string) => { | ||
const isLengthValid = sshKey !== undefined && sshKey.length >= 2; | ||
const isPatternValid = | ||
/^(ssh-(rsa|dss|ed25519)|ecdsa-sha2-nistp(256|384|521)) \S+/.test(sshKey); |
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.
Do you have any source for the regex? If so, could you please add it to a comment so we can reference it if needed?
I wonder if we should try do to a full match instead of a partial one, should be safer that way. We would need to add a few more things to allow for the label part of the key. So maybe something like:
^(ssh-(rsa|dss|ed25519)|ecdsa-sha2-nistp(256|384|521))\s+[A-Za-z0-9+\/=]+\s+\S+$
What do you think?
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 tried this - 'ssh-rsa d' value with your suggestion and it isnt valid.
I took this pattern from 'edge' , they also check the ssh key validation
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.
Hmm, comment might be optional doesn't it 🤔 this should work then
^(ssh-(rsa|dss|ed25519)|ecdsa-sha2-nistp(256|384|521))\s+[A-Za-z0-9+\/=]+(\s+\S+)?$
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.
do you think about this comment?
// 1. Key types: ssh-rsa, ssh-dss, ssh-ed25519, or ecdsa-sha2-nistp(256|384|521).
// 2. Base64-encoded key material.
// 3. Optional comment at the end.
src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx
Outdated
Show resolved
Hide resolved
src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx
Outdated
Show resolved
Hide resolved
b7fe00e
to
a2d67d8
Compare
663b854
to
9063e9f
Compare
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.
Looks good! One more nitpick
src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx
Outdated
Show resolved
Hide resolved
9063e9f
to
b2fa4d5
Compare
2902012
to
0b5fdf7
Compare
Just a heads up, #2772 got merged yesterday so lint autofix should work again without adding unwanted changes :) |
0b5fdf7
to
0f86336
Compare
Did you close the PR on purpose? |
I meant to delete the brach and close it by mistake |
this commit add validation to ssh key field
JIRA: HMS-5349