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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connector): validate connector name before converting ssl certs #11939

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

thalesmg
Copy link
Contributor

@thalesmg thalesmg commented Nov 13, 2023

Fixes https://emqx.atlassian.net/browse/EMQX-11336

See also: #11540

Summary

馃 Generated by Copilot at d108dd2

This pull request adds a new feature to validate the bridge and connector names using a regular expression and fixes a bug in the V1 HTTP API for creating bridges with SSL options. It updates the schema, the emqx_bridge and emqx_connector modules, and the corresponding test suites. It also adds new test cases for different bridge and connector types and configuration paths.

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

Checklist for CI (.github/workflows) changes

  • If changed package build workflow, pass this action (manual trigger)
  • Change log has been added to changes/ dir for user-facing artifacts update

@thalesmg thalesmg force-pushed the fix-name-validation-r53-20231113 branch 3 times, most recently from 9b18ac3 to ad8a6a5 Compare November 13, 2023 19:43
@thalesmg thalesmg marked this pull request as ready for review November 13, 2023 20:07
@thalesmg thalesmg requested review from JimMoen and a team as code owners November 13, 2023 20:07
case Path of
[?ROOT_KEY, _ConnectorType, ConnectorName] ->
validate_connector_name(ConnectorName);
_ ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something to expect? When? Otherwise, wouldn't it be better to just crash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I don't think this should be reached. I'll removed it.

Copy link
Contributor Author

@thalesmg thalesmg Nov 14, 2023

Choose a reason for hiding this comment

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

Actually, no, it may happen if someone does emqx_conf:update([connectors, type], ...). So better to just skip it, as we can't do validation in that case.

@thalesmg thalesmg force-pushed the fix-name-validation-r53-20231113 branch from ad8a6a5 to 1ab970c Compare November 14, 2023 12:26
@thalesmg thalesmg force-pushed the fix-name-validation-r53-20231113 branch from 1ab970c to d6e9bbb Compare November 14, 2023 12:30
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 6863608478

  • 53 of 57 (92.98%) changed or added relevant lines in 4 files are covered.
  • 31 unchanged lines in 12 files lost coverage.
  • Overall coverage increased (+0.005%) to 82.713%

Changes Missing Coverage Covered Lines Changed/Added Lines %
apps/emqx_bridge/src/emqx_bridge_app.erl 7 8 87.5%
apps/emqx_connector/src/emqx_connector.erl 25 28 89.29%
Files with Coverage Reduction New Missed Lines %
apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_consumer_worker.erl 1 93.88%
apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_impl_consumer.erl 1 89.02%
apps/emqx_bridge/src/emqx_bridge.erl 1 84.06%
apps/emqx_connector/src/emqx_connector_jwt_worker.erl 1 89.47%
apps/emqx_ft/src/emqx_ft.erl 1 86.72%
apps/emqx_modules/src/emqx_delayed.erl 1 94.96%
apps/emqx/src/emqx_cm.erl 1 89.5%
apps/emqx/src/emqx_connection.erl 1 83.42%
apps/emqx/src/emqx_os_mon.erl 1 91.78%
apps/emqx_gateway_mqttsn/src/emqx_mqttsn_frame.erl 3 63.48%
Totals Coverage Status
Change from base Build 6861295443: 0.005%
Covered Lines: 35584
Relevant Lines: 43021

馃挍 - Coveralls

@thalesmg thalesmg merged commit 35aaca1 into emqx:release-53 Nov 14, 2023
156 checks passed
@thalesmg thalesmg deleted the fix-name-validation-r53-20231113 branch November 14, 2023 16:01
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

6 participants