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 reported codesmells #221
Conversation
Remove the `decoded_segments` method from the `JWT` module. The code is replaced by the `JWT::Decode` class.
ECDSA_ALGORITHMS = %w(ES256 ES384 ES512).freeze | ||
HMAC_ALGORITHMS = %w[HS256 HS512256 HS384 HS512].freeze | ||
RSA_ALGORITHMS = %w[RS256 RS384 RS512].freeze | ||
ECDSA_ALGORITHMS = %w[ES256 ES384 ES512].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%w
-literals should be delimited by (
and )
.
RSA_ALGORITHMS = %w(RS256 RS384 RS512).freeze | ||
ECDSA_ALGORITHMS = %w(ES256 ES384 ES512).freeze | ||
HMAC_ALGORITHMS = %w[HS256 HS512256 HS384 HS512].freeze | ||
RSA_ALGORITHMS = %w[RS256 RS384 RS512].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%w
-literals should be delimited by (
and )
.
HMAC_ALGORITHMS = %w(HS256 HS512256 HS384 HS512).freeze | ||
RSA_ALGORITHMS = %w(RS256 RS384 RS512).freeze | ||
ECDSA_ALGORITHMS = %w(ES256 ES384 ES512).freeze | ||
HMAC_ALGORITHMS = %w[HS256 HS512256 HS384 HS512].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%w
-literals should be delimited by (
and )
.
require 'jwt/error' | ||
|
||
module JWT | ||
# JWT verify methods | ||
class Verify | ||
class << self | ||
%w(verify_aud verify_expiration verify_iat verify_iss verify_jti verify_not_before verify_sub).each do |method_name| | ||
%w[verify_aud verify_expiration verify_iat verify_iss verify_jti verify_not_before verify_sub].each do |method_name| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%w
-literals should be delimited by (
and )
.
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec| | |||
spec.files = `git ls-files -z`.split("\x0") | |||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | |||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | |||
spec.require_paths = %w(lib) | |||
spec.require_paths = %w[lib] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%w
-literals should be delimited by (
and )
.
Decode method always triggered payload verification even if the verify parameter is set to true.
else | ||
raise JWT::VerificationError, 'Algorithm not supported' | ||
end | ||
verify_hmac(algo, key, signing_input, signature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 (not -9) spaces for indentation.
SecurityUtils.verify_rsa(algo, key, signing_input, signature) | ||
elsif ECDSA_ALGORITHMS.include?(algo) | ||
verify_ecdsa(algo, key, signing_input, signature) | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align else
with if
.
verify_hmac(algo, key, signing_input, signature) | ||
elsif RSA_ALGORITHMS.include?(algo) | ||
SecurityUtils.verify_rsa(algo, key, signing_input, signature) | ||
elsif ECDSA_ALGORITHMS.include?(algo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align elsif
with if
.
raise JWT::VerificationError, 'Algorithm not supported' | ||
end | ||
verify_hmac(algo, key, signing_input, signature) | ||
elsif RSA_ALGORITHMS.include?(algo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align elsif
with if
.
verify_ecdsa(algo, key, signing_input, signature) | ||
else | ||
raise JWT::VerificationError, 'Algorithm not supported' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end
at 48, 6 is not aligned with if
at 40, 17.
# | ||
# @see: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/security_utils.rb | ||
module SecurityUtils | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at module body beginning.
iss = @payload['iss'] | ||
|
||
return if Array(options_iss).map(&:to_s).include?(iss.to_s) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
raise(JWT::InvalidIssuerError, "Invalid issuer. Expected #{options_iss}, received #{@payload['iss'] || '<none>'}") | ||
|
||
iss = @payload['iss'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
else | ||
yield(header) | ||
end | ||
yield(header, payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 (not -4) spaces for indentation.
yield(header) | ||
end | ||
yield(header, payload) | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align else
with if
.
yield(header, payload) | ||
else | ||
yield(header) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end
at 56, 6 is not aligned with if
at 52, 12.
OpenSSL::ASN1.decode(signature).value.map { |value| value.value.to_s(2).rjust(byte_size, "\x00") }.join | ||
end | ||
|
||
def raw_to_asn1(signature, private_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT::SecurityUtils#raw_to_asn1 has the name 'raw_to_asn1'
Ebert has finished reviewing this Pull Request and has found:
But beware that this branch is 2 commits behind the You can see more details about this review at https://ebertapp.io/github/jwt/ruby-jwt/pulls/221. |
Remove parameters as they are already instance vars.
No description provided.