diff --git a/lib/fetchers/url.rb b/lib/fetchers/url.rb index 97bfdaac8..180e6cf61 100644 --- a/lib/fetchers/url.rb +++ b/lib/fetchers/url.rb @@ -65,8 +65,8 @@ module Fetchers # https://bitbucket.org/username/repo/commits/95ce1f83d5bbe9eec34c5973f6894617e8d6d8cc is transformed to # https://bitbucket.org/username/repo/get/95ce1f83d5bbe9eec34c5973f6894617e8d6d8cc.tar.gz - GITHUB_URL_REGEX = %r{^https?://(www\.)?github\.com/(?[\w-]+)/(?[\w-]+)(\.git)?(/)?$} - GITHUB_URL_WITH_TREE_REGEX = %r{^https?://(www\.)?github\.com/(?[\w-]+)/(?[\w-]+)/tree/(?[\w\.]+)(/)?$} + GITHUB_URL_REGEX = %r{^https?://(www\.)?github\.com/(?[\w-]+)/(?[\w.-]+?)(\.git)?(/)?$} + GITHUB_URL_WITH_TREE_REGEX = %r{^https?://(www\.)?github\.com/(?[\w-]+)/(?[\w.-]+)/tree/(?[\w\.]+)(/)?$} BITBUCKET_URL_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?[\w-]+)/(?[\w-]+)(\.git)?(/)?$} BITBUCKET_URL_BRANCH_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?[\w-]+)/(?[\w-]+)/branch/(?[\w\.]+)(/)?$} BITBUCKET_URL_COMMIT_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?[\w-]+)/(?[\w-]+)/commits/(?[\w\.]+)(/)?$} diff --git a/test/unit/fetchers/url_test.rb b/test/unit/fetchers/url_test.rb index c2bed00da..2c5990e77 100644 --- a/test/unit/fetchers/url_test.rb +++ b/test/unit/fetchers/url_test.rb @@ -78,6 +78,16 @@ describe Fetchers::Url do end end + it "resolves a github url with dot" do + expect_url_transform do + github = 'https://github.com/mitre/aws-rds-oracle-mysql-ee-5.7-cis-baseline' + res = Fetchers::Url.resolve(github) + res.expects(:open).returns(mock_open) + _(res).wont_be_nil + _(res.resolved_source).must_equal({url: 'https://github.com/mitre/aws-rds-oracle-mysql-ee-5.7-cis-baseline/archive/master.tar.gz', sha256: expected_shasum}) + end + end + it "resolves a github branch url" do expect_url_transform do github = 'https://github.com/hardening-io/tests-os-hardening/tree/2.0'