diff options
| author | Michael Klishin <klishinm@vmware.com> | 2023-01-19 09:10:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-19 09:10:59 -0600 |
| commit | 8bbe87ec9eb3261520f58790be0a2f9a427c25fd (patch) | |
| tree | 020fd2fdd278daf371823f12a9e6178fa1cccc99 | |
| parent | 7ace097f5bef603ab704426db68b1db2013ec63f (diff) | |
| parent | 8164df8bb24a92fa4ee61c1859a65850e2b5dd53 (diff) | |
| download | rabbitmq-server-git-8bbe87ec9eb3261520f58790be0a2f9a427c25fd.tar.gz | |
Merge pull request #6952 from rabbitmq/dialyzer-warnings-rabbitmq_auth_backend
Fix all dialyzer warnings in auth backends
7 files changed, 26 insertions, 13 deletions
diff --git a/deps/rabbitmq_auth_backend_http/BUILD.bazel b/deps/rabbitmq_auth_backend_http/BUILD.bazel index aabae0710f..27a78c2301 100644 --- a/deps/rabbitmq_auth_backend_http/BUILD.bazel +++ b/deps/rabbitmq_auth_backend_http/BUILD.bazel @@ -55,13 +55,12 @@ plt( name = "base_plt", apps = EXTRA_APPS, plt = "//:base_plt", - deps = DEPS, + deps = DEPS + RUNTIME_DEPS, ) dialyze( dialyzer_opts = RABBITMQ_DIALYZER_OPTS, plt = ":base_plt", - warnings_as_errors = False, ) broker_for_integration_suites() diff --git a/deps/rabbitmq_auth_backend_http/src/rabbit_auth_backend_http.erl b/deps/rabbitmq_auth_backend_http/src/rabbit_auth_backend_http.erl index 66c6fbea27..63bead4269 100644 --- a/deps/rabbitmq_auth_backend_http/src/rabbit_auth_backend_http.erl +++ b/deps/rabbitmq_auth_backend_http/src/rabbit_auth_backend_http.erl @@ -194,10 +194,12 @@ join_tags(Tags) -> Strings = [rabbit_data_coercion:to_list(T) || T <- Tags], string:join(Strings, " "). +-spec parse_peeraddr(inet:ip_address()) -> string(). parse_peeraddr(PeerAddr) -> handle_inet_ntoa_peeraddr(inet:ntoa(PeerAddr), PeerAddr). +-spec handle_inet_ntoa_peeraddr({'error', term()} | string(), inet:ip_address()) -> string(). handle_inet_ntoa_peeraddr({error, einval}, PeerAddr) -> - rabbit_data_coercion:to_list(PeerAddr); + rabbit_data_coercion:to_list(io_lib:format("~w", [PeerAddr])); handle_inet_ntoa_peeraddr(PeerAddrStr, _PeerAddr0) -> PeerAddrStr. diff --git a/deps/rabbitmq_auth_backend_ldap/BUILD.bazel b/deps/rabbitmq_auth_backend_ldap/BUILD.bazel index 0cb72797da..4548b2b3ed 100644 --- a/deps/rabbitmq_auth_backend_ldap/BUILD.bazel +++ b/deps/rabbitmq_auth_backend_ldap/BUILD.bazel @@ -43,6 +43,7 @@ APP_MODULE = "rabbit_auth_backend_ldap_app" EXTRA_APPS = [ "eldap", + "public_key", ] DEPS = [ @@ -70,13 +71,12 @@ plt( name = "base_plt", apps = EXTRA_APPS, plt = "//:base_plt", - deps = DEPS, + deps = DEPS + RUNTIME_DEPS, ) dialyze( dialyzer_opts = RABBITMQ_DIALYZER_OPTS, plt = ":base_plt", - warnings_as_errors = False, ) broker_for_integration_suites() diff --git a/deps/rabbitmq_auth_backend_oauth2/BUILD.bazel b/deps/rabbitmq_auth_backend_oauth2/BUILD.bazel index a1f4ba4dbb..676a3e0872 100644 --- a/deps/rabbitmq_auth_backend_oauth2/BUILD.bazel +++ b/deps/rabbitmq_auth_backend_oauth2/BUILD.bazel @@ -16,6 +16,11 @@ APP_NAME = "rabbitmq_auth_backend_oauth2" APP_DESCRIPTION = "OAuth 2 and JWT-based AuthN and AuthZ backend" +EXTRA_APPS = [ + "inets", + "public_key", +] + BUILD_DEPS = [ "//deps/rabbit_common:erlang_app", "//deps/rabbitmq_cli:rabbitmqctl", @@ -37,6 +42,7 @@ rabbitmq_app( build_deps = BUILD_DEPS, runtime_deps = RUNTIME_DEPS, deps = DEPS, + extra_apps = EXTRA_APPS, ) xref( @@ -47,16 +53,17 @@ xref( plt( name = "base_plt", + apps = EXTRA_APPS, + plt = "//:base_plt", deps = without( "//deps/rabbitmq_cli:rabbitmqctl", - BUILD_DEPS + DEPS, + BUILD_DEPS + DEPS + RUNTIME_DEPS, ), ) dialyze( dialyzer_opts = RABBITMQ_DIALYZER_OPTS + ["-Wno_undefined_callbacks"], plt = ":base_plt", - warnings_as_errors = False, ) broker_for_integration_suites() diff --git a/deps/rabbitmq_auth_backend_oauth2/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AddUaaKeyCommand.erl b/deps/rabbitmq_auth_backend_oauth2/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AddUaaKeyCommand.erl index c005b9901c..a0446a6b9f 100644 --- a/deps/rabbitmq_auth_backend_oauth2/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AddUaaKeyCommand.erl +++ b/deps/rabbitmq_auth_backend_oauth2/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AddUaaKeyCommand.erl @@ -71,8 +71,6 @@ validate_json(Json) -> {validation_failure, {bad_argument, Err}} end; {error, _} -> - {validation_failure, {bad_argument, <<"Invalid JSON">>}}; - error -> {validation_failure, {bad_argument, <<"Invalid JSON">>}} end. diff --git a/deps/rabbitmq_auth_backend_oauth2/src/rabbit_auth_backend_oauth2.erl b/deps/rabbitmq_auth_backend_oauth2/src/rabbit_auth_backend_oauth2.erl index 012b91f847..345b239df3 100644 --- a/deps/rabbitmq_auth_backend_oauth2/src/rabbit_auth_backend_oauth2.erl +++ b/deps/rabbitmq_auth_backend_oauth2/src/rabbit_auth_backend_oauth2.erl @@ -167,7 +167,14 @@ validate_token_expiry(#{<<"exp">> := Exp}) when is_integer(Exp) -> end; validate_token_expiry(#{}) -> ok. --spec check_token(binary()) -> {ok, map()} | {error, term()}. +-spec check_token(binary()) -> + {'ok', map()} | + {'error', term() }| + {'refused', + 'signature_invalid' | + {'error', term()} | + {'invalid_aud', term()}}. + check_token(Token) -> Settings = application:get_all_env(?APP), case uaa_jwt:decode_and_verify(Token) of diff --git a/deps/rabbitmq_auth_backend_oauth2/src/rabbit_oauth2_scope.erl b/deps/rabbitmq_auth_backend_oauth2/src/rabbit_oauth2_scope.erl index 9b841adb0f..387c400b6f 100644 --- a/deps/rabbitmq_auth_backend_oauth2/src/rabbit_oauth2_scope.erl +++ b/deps/rabbitmq_auth_backend_oauth2/src/rabbit_oauth2_scope.erl @@ -50,7 +50,7 @@ topic_access(#resource{virtual_host = VHost, name = ExchangeName}, %% Internal ------------------------------------------------------------------- --spec get_scope_permissions([binary()]) -> [{rabbit_types:r(pattern), permission()}]. +%% -spec get_scope_permissions([binary()]) -> [{rabbit_types:r(pattern), permission()}]. get_scope_permissions(Scopes) when is_list(Scopes) -> lists:filtermap( fun(ScopeEl) -> @@ -65,7 +65,7 @@ get_scope_permissions(Scopes) when is_list(Scopes) -> concat_scopes(Scopes, Separator) when is_list(Scopes) -> lists:concat(lists:join(Separator, lists:map(fun rabbit_data_coercion:to_list/1, Scopes))). --spec parse_permission_pattern(binary()) -> {rabbit_types:r(pattern), permission()}. +-spec parse_permission_pattern(binary()) -> {rabbit_types:vhost(), binary(), binary() | none, permission()} | 'ignore'. parse_permission_pattern(<<"read:", ResourcePatternBin/binary>>) -> Permission = read, parse_resource_pattern(ResourcePatternBin, Permission); @@ -79,7 +79,7 @@ parse_permission_pattern(_Other) -> ignore. -spec parse_resource_pattern(binary(), permission()) -> - {rabbit_types:vhost(), binary(), binary() | none, permission()}. + {rabbit_types:vhost(), binary(), binary() | none, permission()} | 'ignore'. parse_resource_pattern(Pattern, Permission) -> case binary:split(Pattern, <<"/">>, [global]) of [VhostPattern, NamePattern] -> |
