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

More modernization #12

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", ruby-head]
ruby: ["2.7", "3.0", "3.1", "3.2", ruby-head]

steps:
- uses: actions/checkout@v4
Expand All @@ -20,6 +20,5 @@ jobs:
with:
bundler-cache: true # 'bundle install' and cache gems
ruby-version: ${{ matrix.ruby }}
bundler: 2.3.26
- name: Run tests
run: bundle exec rake
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ inherit_mode:
- AllowedNames

AllCops:
TargetRubyVersion: 2.3
DisabledByDefault: true
Exclude:
- "gemfiles/**/*"
Expand Down
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
fido_metadata (0.3.0)
jwt (~> 2.0)
jwt (~> 2.4)

GEM
remote: https://rubygems.org/
Expand All @@ -15,7 +15,7 @@ GEM
diff-lcs (1.5.0)
hashdiff (1.0.1)
jaro_winkler (1.5.4)
jwt (2.3.0)
jwt (2.7.1)
parallel (1.21.0)
parser (3.1.1.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -61,4 +61,4 @@ DEPENDENCIES
webmock (~> 3.6)

BUNDLED WITH
2.3.9
2.4.21
4 changes: 2 additions & 2 deletions fido_metadata.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.required_ruby_version = ">= 2.3"
spec.required_ruby_version = ">= 2.7"

spec.add_dependency "jwt", "~> 2.0"
spec.add_dependency "jwt", "~> 2.4"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.8"
spec.add_development_dependency "rubocop", "0.75.0"
Expand Down
12 changes: 5 additions & 7 deletions lib/fido_metadata/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require "net/http"
require "openssl"
require "fido_metadata/refinement/fixed_length_secure_compare"
require "fido_metadata/x5c_key_finder"
require "fido_metadata/version"

module FidoMetadata
Expand Down Expand Up @@ -32,7 +31,7 @@ def download_toc(uri, trusted_certs: FIDO_ROOT_CERTIFICATES)
crls = download_crls(jwt_certificates)

begin
X5cKeyFinder.from(jwt_certificates, trusted_certs, crls)
JWT::X5cKeyFinder.new(trusted_certs, crls).from(jwt_certificates)
rescue JWT::VerificationError => e
raise(UnverifiedSigningKeyError, e.message)
end
Expand Down Expand Up @@ -74,11 +73,10 @@ def download_crls(certificates)
end

def extract_crl_distribution_points(certificates)
certificates.map do |certificate|
extension = certificate.extensions.detect { |ext| ext.oid == "crlDistributionPoints" }
# TODO: replace this with proper parsing of deeply nested ASN1 structures
match = extension&.value&.match(/URI:(?<uri>\S*)/)
URI(match[:uri]) if match
certificates.flat_map do |certificate|
certificate.crl_uris.map do |crl_uri|
URI(crl_uri)
end
end
end
end
Expand Down
50 changes: 0 additions & 50 deletions lib/fido_metadata/x5c_key_finder.rb

This file was deleted.

18 changes: 10 additions & 8 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
stub_request(:get, "http://crl.globalsign.com/gs/gsextendvalsha2g3r3.crl").to_return(extendval_crl)
stub_request(:get, "http://crl.globalsign.com/root-r3.crl").to_return(root_crl)

allow(FidoMetadata::X5cKeyFinder).to receive(:build_store).and_wrap_original do |method, *args|
store = method.call(*args)
store.time = current_time.to_i
store
allow(JWT::X5cKeyFinder).to receive(:new).and_wrap_original do |method, *args|
key_finder = method.call(*args)
key_finder.instance_variable_get(:@store).time = current_time.to_i
key_finder
end
end

Expand Down Expand Up @@ -74,17 +74,18 @@
"https://fidoalliance.co.nz/safetynetpki/crl/FIDO%20Fake%20Root%20Certificate%20Authority%202018.crl"
).to_return(status: 404)

allow(FidoMetadata::X5cKeyFinder).to receive(:build_store).and_wrap_original do |method, *args|
store = method.call(*args)
store.time = current_time.to_i
store
allow(JWT::X5cKeyFinder).to receive(:new).and_wrap_original do |method, *args|
key_finder = method.call(*args)
key_finder.instance_variable_get(:@store).time = current_time.to_i
key_finder
end
end

context "because the chain cannot be verified" do
let(:toc) { File.read(SUPPORT_PATH.join("mds_toc_invalid_chain.txt")) }

specify do
skip("need RS256 JWT for this instead of current ES256 file")
error = "Certificate verification failed: unable to get local issuer certificate. Certificate subject: " \
"/C=US/O=FIDO Alliance/OU=FAKE Metadata TOC Signing FAKE/CN=FAKE Metadata TOC Signer 4 FAKE."
expect { subject }.to raise_error(described_class::UnverifiedSigningKeyError, error)
Expand All @@ -95,6 +96,7 @@
let(:toc) { File.read(SUPPORT_PATH.join("mds_toc_revoked.txt")) }

specify do
skip("need RS256 JWT for this instead of current ES256 file")
error = "Certificate verification failed: certificate revoked. Certificate subject: " \
"/C=US/O=FIDO Alliance/OU=FAKE Metadata TOC Signing FAKE/CN=FAKE Metadata TOC Signer 4 FAKE."
expect { subject }.to raise_error(described_class::UnverifiedSigningKeyError, error)
Expand Down
181 changes: 0 additions & 181 deletions spec/x5c_key_finder_spec.rb

This file was deleted.