-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Write Chain Target: Validate that signed report metadata matches request metadata #14066
Conversation
@@ -82,36 +115,11 @@ func TestWriteTarget(t *testing.T) { | |||
require.NotNil(t, response) | |||
}) | |||
|
|||
t.Run("succeeds with empty report", func(t *testing.T) { |
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.
Removed because we no longer support a use case in which an empty report is passed to the target capability.
…t-metadata # Conflicts: # core/capabilities/targets/write_target.go # core/capabilities/targets/write_target_test.go
Quality Gate passedIssues Measures |
if len(data) < metadata.Length() { | ||
return metadata, fmt.Errorf("data too short: %d bytes", len(data)) | ||
} | ||
return metadata, binary.Read(bytes.NewReader(data[:metadata.Length()]), binary.BigEndian, &metadata) |
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 didn't know that binary.Read() makes is so easy, TIL :)
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.
We should be able to use something similar in cap encoder too
return buf.Bytes(), nil | ||
} | ||
|
||
func (rm ReportV1Metadata) Length() int { |
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.
nit: Feels a bit wasteful, could be a const... likely doesn't matter.
https://smartcontract-it.atlassian.net/browse/KS-400