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

fix(s3): disallow partially defined credentials in schema #12574

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

keynslug
Copy link
Contributor

Fixes EMQX-11888.

Release version: e5.6

Summary

Running S3 client with only partially defined credentials does not make sense and usually causes crashes somewhere down the stack. Better to disallow this on the schema level.

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Added property-based tests for code which performs user input validation
  • Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • Schema changes are backward compatible (not entirely, but this is again the point of the PR)

@keynslug keynslug requested a review from a team as a code owner February 23, 2024 10:59
@keynslug keynslug force-pushed the fix/EMQX-11888/no-partial-creds branch from fe3619e to 3684637 Compare February 23, 2024 11:18
AccessKeyId = hocon_maps:get("s3.access_key_id", Config),
SecretAccessKey = hocon_maps:get("s3.secret_access_key", Config),
case {AccessKeyId, SecretAccessKey} of
{_Defined, undefined} ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we guard that Defined =/= undefined here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right! 🫠 Thanks.

@@ -169,6 +170,27 @@ desc(s3_upload) ->
desc(transport_options) ->
"Options for the HTTP transport layer used by the S3 client".

validations() ->
Copy link
Member

Choose a reason for hiding this comment

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

Since the values are not cross roots, so there is no maybe need to add a root level validator which is evaluated by all config checks even if it's not checking this root.
IIRC, we can implement roots/0 like this.

roots() ->
  [{s3, hoconsc:mk(hoconsc:ref(s3), #{validator => fun(Conf) -> ... end})].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by "cross roots"?

Copy link
Member

Choose a reason for hiding this comment

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

I mean if one needs to verify root1.key1 = bar is valid given root0.key0 = foo, then it's a cross-root validation,
one would have to add a global validator.

e.g. the recently added cluster.discoverty_strategy = dns vs node.name = emqx@FQDN check.

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.

None yet

3 participants