-
Notifications
You must be signed in to change notification settings - Fork 372
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
pkg/index: validate sha256 values #281
pkg/index: validate sha256 values #281
Conversation
4410e93
to
58ed322
Compare
58ed322
to
5a3d370
Compare
5a3d370
to
3efd737
Compare
This is expected to have merge-conflicts with #278 as it updates some test cases deleted in that PR. |
Codecov Report
@@ Coverage Diff @@
## master #281 +/- ##
==========================================
+ Coverage 54.91% 55.49% +0.57%
==========================================
Files 19 19
Lines 874 883 +9
==========================================
+ Hits 480 490 +10
+ Misses 341 337 -4
- Partials 53 56 +3
Continue to review full report at Codecov.
|
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.
One small nit. Otherwise looks great.
pkg/index/validate.go
Outdated
@@ -93,6 +96,9 @@ func (p Platform) Validate() error { | |||
if p.Sha256 == "" { | |||
return errors.New("sha256 sum has to be set") | |||
} | |||
if !isValidSHA256(p.Sha256) { | |||
return errors.Errorf("sha256 value %s is not a valid sha256sum string", p.Sha256) |
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.
Could you mention the requirement, that the string is expected to be lower-case?
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 decided to include the pattern in the error message.
3efd737
to
bf4fa11
Compare
This makes sure the code only deals with valid lowercase sha256 values (i.e. all lowercase) while doing comparisons etc. Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
bf4fa11
to
83c2c00
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahmetb, corneliusweig The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This makes sure the code only deals with valid lowercase sha256 values
(i.e. all lowercase) while doing comparisons etc.