Repository navigation
Release: signed build provenance for every published file #36
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # frozen_string_literal: true | ||
| # | ||
| # Fails when a file in the repository is a program: a Windows PE (.exe, .dll, .NET | ||
| # assemblies included), an ELF or Mach-O binary, a Java class or WebAssembly. Everything | ||
| # IronRuby ships is compiled from the sources here, the NuGet packages the projects pin and | ||
| # the .NET runtime, so the tree itself holds nothing that runs but cannot be read. Images, | ||
| # fonts and documents are not programs and are let through. CI runs it on every change: | ||
| # | ||
| # ruby Util/check-no-executables.rb # every file git tracks | ||
| # ruby Util/check-no-executables.rb FILE... # only these | ||
| # | ||
| # A file is recognised by its first bytes, not by its name, so a program cannot pass by | ||
| # being called notes.txt, and an extension-only placeholder such as | ||
| # Tests/Experiments/Loader/Extensions/fcntl.so - which is text - is not flagged. | ||
|
|
||
| def kind_of(file, size) | ||
| head = file.read(4096) || "".b | ||
| return "ELF" if head.start_with?("\x7FELF".b) | ||
| return "WebAssembly" if head.start_with?("\0asm".b) | ||
| if head.start_with?("MZ".b) && head.bytesize >= 0x40 | ||
| # The PE signature is where e_lfanew says, which may be past what was read. | ||
| pe = head.byteslice(0x3c, 4).unpack1("V") | ||
| if pe + 4 <= size | ||
| signature = pe + 4 <= head.bytesize ? head.byteslice(pe, 4) : (file.seek(pe) && file.read(4)) | ||
| return "PE (Windows program or .NET assembly)" if signature == "PE\0\0".b | ||
| end | ||
| end | ||
| case head.byteslice(0, 4)&.unpack1("N") | ||
| when 0xFEEDFACE, 0xFEEDFACF, 0xCEFAEDFE, 0xCFFAEDFE then "Mach-O" | ||
| when 0xCAFEBABE then "Mach-O universal binary or Java class" | ||
| when 0xCAFEBABF then "Mach-O universal binary (64-bit offsets)" | ||
| end | ||
| end | ||
|
|
||
| paths = ARGV.empty? ? `git ls-files -z`.split("\0") : ARGV | ||
| abort "check-no-executables: git ls-files failed" if ARGV.empty? && !$?.success? | ||
|
|
||
| found = paths.filter_map do |path| | ||
| next unless File.file?(path) | ||
| size = File.size(path) | ||
| kind = File.open(path, "rb") { |file| kind_of(file, size) } | ||
| "#{path}: #{kind}" if kind | ||
| end | ||
|
|
||
| if found.empty? | ||
| puts "check-no-executables: #{paths.size} files, no programs among them" | ||
| else | ||
| warn "check-no-executables: #{found.size} program(s) in the repository - build them from source instead:" | ||
| found.each { |line| warn " #{line}" } | ||
| exit 1 | ||
| end | ||
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.