Centralize and harden vault secret identifier validation#22119
Centralize and harden vault secret identifier validation#22119russell-stern wants to merge 4 commits intodevelopfrom
Conversation
|
✅ No conflicts with other open PRs targeting |
|
| }, | ||
| } | ||
| fetcher := &callbackBlobFetcher{fn: func([]byte) error { return nil }} | ||
| result, err := r.broadcastBlobPayloads(t.Context(), fetcher, 1, payloads, ids) |
There was a problem hiding this comment.
🤔 This will never fail I think -- your callbackBlobFetcher isn't the real fetcher that would be injected, so in other words even if you passed a payload that was too big, the test would still succeed
I would suggest instead checking against the plugin limit value instantiated by the NewReportingPlugin function
There was a problem hiding this comment.
I have that check below but you're right the runBroadcast isn't actually testing anything. I removed the call altogether and since the blob limit is per payload the batch size doesn't matter. I removed the loop that created multiple payloads and we're just checking against the max size payload for each request type
b6f88a8 to
1bc64cc
Compare
prashantkumar1982
left a comment
There was a problem hiding this comment.
Thanks for these new validation tests :)
But looking at these, I think we should do this validation in more layers in our stack. See detailed comments.
| name string | ||
| id *vaultcommon.SecretIdentifier | ||
| maxIDLen int | ||
| maxOwnerLen int |
There was a problem hiding this comment.
These 3 limits on max values should ideally be tested inside the validator too.
OCR plugin is too deep in our stack to be the only place to validate these.
I mean look at this code:
chainlink/core/capabilities/vault/validator.go
Lines 59 to 61 in 01f4475
This code too should be checking these limits and failing.
@cedric-cordenier what do you think?
|
I see you updated files related to
|
e2ff881 to
98b873e
Compare
|
|
||
| // ownerOverrideLimiter is a BoundLimiter that applies different size limits based on the owner in context. | ||
| // This lets tests verify that the validator correctly threads the owner through context to the limiter. | ||
| type ownerOverrideLimiter struct { |
There was a problem hiding this comment.
I'm not sure that faking this is a good idea. What do the tests actually evaluate if we skip past coverage of a real limiter? Typically we just pass a settings.Getter to the limits factory.
There was a problem hiding this comment.
This is testing to make sure that we're passing in the owner into the context during the validation calls. There were places where we weren't and weren't applying higher limits for owners that had it set. This is only used in tests that are testing if we're applying the right limits per owner
| return capabilities.CapabilityResponse{}, errors.New("unsupported method: can only call GetSecrets via capability interface") | ||
| } | ||
|
|
||
| r := &vaultcommon.GetSecretsRequest{} |
There was a problem hiding this comment.
I know we've been missing this code always.
But we should call validation on this request object too.
Reason is because this field is also coming from a workflow user, and can have invalid details.
@cedric-cordenier : We were always missing validation for GetSecrets() path whcih comes via workflows. The content is not validated anywhere before plugin.
0f7644e to
9e578d6
Compare
|




Uh oh!
There was an error while loading. Please reload this page.