Skip to content

Commit

Permalink
fix(emqx_schema): use non negative integer type for 'depth' SSL option
Browse files Browse the repository at this point in the history
Closes: EMQX-10276
  • Loading branch information
SergeTupchiy committed Jun 15, 2023
1 parent e42cc58 commit 64bbe21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/emqx/src/emqx_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ common_ssl_opts_schema(Defaults, Type) ->
)},
{"depth",
sc(
integer(),
non_neg_integer(),
#{
default => Df("depth", 10),
desc => ?DESC(common_ssl_opts_schema_depth)
Expand Down
8 changes: 8 additions & 0 deletions apps/emqx/test/emqx_schema_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ ssl_opts_version_gap_test_() ->
|| S <- [Sc, RanchSc]
].

ssl_opts_cert_depth_test() ->
Sc = emqx_schema:server_ssl_opts_schema(#{}, false),
Reason = #{expected_type => "non_neg_integer()"},
?assertThrow(
{_Sc, [#{kind := validation_error, reason := Reason}]},
validate(Sc, #{<<"depth">> => -1})
).

bad_cipher_test() ->
Sc = emqx_schema:server_ssl_opts_schema(#{}, false),
Reason = {bad_ciphers, ["foo"]},
Expand Down
1 change: 1 addition & 0 deletions changes/ce/fix-11051.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add validation to ensure that certificate 'depth' (listener SSL option) is a non negative integer.

0 comments on commit 64bbe21

Please sign in to comment.