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

Fix not found error for attestation build summary URL #5365

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions app/models/attestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def display_data # rubocop:disable Metrics/MethodLength
commit = extensions["1.3.6.1.4.1.57264.1.3"]
ref = extensions["1.3.6.1.4.1.57264.1.14"]
san = extensions["subjectAltName"]
build_file_url = extensions["1.3.6.1.4.1.57264.1.21"]
build_summary_url = extensions["1.3.6.1.4.1.57264.1.21"]
build_file_url = build_summary_url.sub(%r{attempts/\d+\z}, "workflow")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the test data and resources, "1.3.6.1.4.1.57264.1.9" or "1.3.6.1.4.1.57264.1.18" might be reasonable for this purpose. However, I can't know the actual response for now. So, using the existing resource here.

"1.3.6.1.4.1.57264.1.9" =>
".Xhttps://github.com/sigstore/sigstore-ruby/.github/workflows/release.yml@refs/tags/v0.1.1",
"1.3.6.1.4.1.57264.1.10" =>
".(f106999a2210a9a17b32b172f95518859a85ffed",
"1.3.6.1.4.1.57264.1.11" =>
".githubHosted",
"1.3.6.1.4.1.57264.1.12" =>
".)https://github.com/sigstore/sigstore-ruby",
"1.3.6.1.4.1.57264.1.13" =>
".(f106999a2210a9a17b32b172f95518859a85ffed",
"1.3.6.1.4.1.57264.1.14" =>
"..refs/tags/v0.1.1",
"1.3.6.1.4.1.57264.1.15" =>
"..766398650",
"1.3.6.1.4.1.57264.1.16" =>
"..https://github.com/sigstore",
"1.3.6.1.4.1.57264.1.17" =>
"..71096353",
"1.3.6.1.4.1.57264.1.18" =>
".Xhttps://github.com/sigstore/sigstore-ruby/.github/workflows/release.yml@refs/tags/v0.1.1",

https://github.com/sigstore/fulcio/blob/86a028b47a5ad67acf78ab30f6a7939fbf3411b0/docs/oid-info.md?plain=1#L124-L166

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual data from dump

attestation = Rubygem.find_by_name('gem_server_conformance').find_version_by_slug!('0.1.5').attestations.first

extensions = attestation.sigstore_bundle.leaf_certificate.openssl.extensions.to_h do |ext|
  [ext.oid, if (ext.oid =~ /\A1\.3\.6\.1\.4\.1\.57264\.1\.(\d+)\z/) && ::Regexp.last_match(1).to_i >= 8
              OpenSSL::ASN1.decode(ext.value_der).value
            else
              ext.value
            end]
end

extensions.slice("1.3.6.1.4.1.57264.1.9", "1.3.6.1.4.1.57264.1.18", "1.3.6.1.4.1.57264.1.21")
{"1.3.6.1.4.1.57264.1.9" =>
  "https://github.com/rubygems/gem_server_conformance/.github/workflows/push_gem.yml@refs/tags/v0.1.5",
 "1.3.6.1.4.1.57264.1.18" =>
  "https://github.com/rubygems/gem_server_conformance/.github/workflows/push_gem.yml@refs/tags/v0.1.5",
 "1.3.6.1.4.1.57264.1.21" =>
  "https://github.com/rubygems/gem_server_conformance/actions/runs/12419161302/attempts/1"}

9 and 18 returned URL will be a not found error in github.


case issuer
when "https://token.actions.githubusercontent.com"
Expand All @@ -38,9 +39,9 @@ def display_data # rubocop:disable Metrics/MethodLength
{
ci_platform: "GitHub Actions",
source_commit_string: "#{repo}@#{commit[0, 7]}",
source_commit_url: "https://github.com/#{repo}/tree/#{commit}",
source_commit_url: "https://github.com/#{repo}/commit/#{commit}",
build_file_string:, build_file_url:,
build_summary_url: "https://github.com/#{repo}/actions/runs/#{build_file_string}"
build_summary_url:
}
else
raise "Unhandled issuer: #{issuer.inspect}"
Expand Down
Loading