ruby-macho 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/macho.rb +7 -6
- data/lib/macho/exceptions.rb +5 -4
- data/lib/macho/fat_file.rb +7 -9
- data/lib/macho/headers.rb +3 -0
- data/lib/macho/load_commands.rb +1 -0
- data/lib/macho/sections.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b98417732314a92f3493ffd08e9221edbd342941bee24245b88b07fb292c2f8
|
4
|
+
data.tar.gz: cc17a19152fac25565b9a2759f7aa9aa2674318623e6bf620527e32e1796acda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7135b6f32de153de839197779a1770e4a18c071a063ec8fa0b88791171fc6d45e208dd8df7a4338ca1f663d74cc25b2b78c791c61873598177f314f01c4ed108
|
7
|
+
data.tar.gz: 16132d807fd316cddd68638cdf9877e638134b438c5fddeb7901619cd8f52aba244ca6d2e7613981bd7d645612bce66434dc2f17400bea8fcd750e7444e782d1
|
data/lib/macho.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "open3"
|
4
|
+
|
4
5
|
require_relative "macho/structure"
|
5
6
|
require_relative "macho/view"
|
6
7
|
require_relative "macho/headers"
|
@@ -15,7 +16,7 @@ require_relative "macho/tools"
|
|
15
16
|
# The primary namespace for ruby-macho.
|
16
17
|
module MachO
|
17
18
|
# release version
|
18
|
-
VERSION = "2.
|
19
|
+
VERSION = "2.4.0"
|
19
20
|
|
20
21
|
# Opens the given filename as a MachOFile or FatFile, depending on its magic.
|
21
22
|
# @param filename [String] the file being opened
|
@@ -52,10 +53,10 @@ module MachO
|
|
52
53
|
return if RUBY_PLATFORM !~ /darwin/
|
53
54
|
raise ArgumentError, "#{filename}: no such file" unless File.file?(filename)
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
_, _, status = Open3.capture3("codesign", "--sign", "-", "--force",
|
57
|
+
"--preserve-metadata=entitlements,requirements,flags,runtime",
|
58
|
+
filename)
|
58
59
|
|
59
|
-
raise
|
60
|
+
raise CodeSigningError, "#{filename}: signing failed!" unless status.success?
|
60
61
|
end
|
61
62
|
end
|
data/lib/macho/exceptions.rb
CHANGED
@@ -9,6 +9,11 @@ module MachO
|
|
9
9
|
class ModificationError < MachOError
|
10
10
|
end
|
11
11
|
|
12
|
+
# Raised when codesigning fails. Certain environments
|
13
|
+
# may want to rescue this to treat it as non-fatal.
|
14
|
+
class CodeSigningError < MachOError
|
15
|
+
end
|
16
|
+
|
12
17
|
# Raised when a Mach-O file modification fails but can be recovered when
|
13
18
|
# operating on multiple Mach-O slices of a fat binary in non-strict mode.
|
14
19
|
class RecoverableModificationError < ModificationError
|
@@ -27,10 +32,6 @@ module MachO
|
|
27
32
|
|
28
33
|
# Raised when a file is not a Mach-O.
|
29
34
|
class NotAMachOError < MachOError
|
30
|
-
# @param error [String] the error in question
|
31
|
-
def initialize(error)
|
32
|
-
super error
|
33
|
-
end
|
34
35
|
end
|
35
36
|
|
36
37
|
# Raised when a file is too short to be a valid Mach-O file.
|
data/lib/macho/fat_file.rb
CHANGED
@@ -66,7 +66,7 @@ module MachO
|
|
66
66
|
offset += (macho.serialize.bytesize + macho_pads[macho])
|
67
67
|
end
|
68
68
|
|
69
|
-
machos.each do |macho|
|
69
|
+
machos.each do |macho| # rubocop:disable Style/CombinableLoops
|
70
70
|
bin << Utils.nullpad(macho_pads[macho])
|
71
71
|
bin << macho.serialize
|
72
72
|
end
|
@@ -398,16 +398,14 @@ module MachO
|
|
398
398
|
errors = []
|
399
399
|
|
400
400
|
machos.each_with_index do |macho, index|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
e.macho_slice = index
|
401
|
+
yield macho
|
402
|
+
rescue RecoverableModificationError => e
|
403
|
+
e.macho_slice = index
|
405
404
|
|
406
|
-
|
407
|
-
|
405
|
+
# Strict mode: Immediately re-raise. Otherwise: Retain, check later.
|
406
|
+
raise e if strict
|
408
407
|
|
409
|
-
|
410
|
-
end
|
408
|
+
errors << e
|
411
409
|
end
|
412
410
|
|
413
411
|
# Non-strict mode: Raise first error if *all* Mach-O slices failed.
|
data/lib/macho/headers.rb
CHANGED
@@ -500,6 +500,7 @@ module MachO
|
|
500
500
|
|
501
501
|
# @api private
|
502
502
|
def initialize(magic, nfat_arch)
|
503
|
+
super()
|
503
504
|
@magic = magic
|
504
505
|
@nfat_arch = nfat_arch
|
505
506
|
end
|
@@ -551,6 +552,7 @@ module MachO
|
|
551
552
|
|
552
553
|
# @api private
|
553
554
|
def initialize(cputype, cpusubtype, offset, size, align)
|
555
|
+
super()
|
554
556
|
@cputype = cputype
|
555
557
|
@cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK
|
556
558
|
@offset = offset
|
@@ -648,6 +650,7 @@ module MachO
|
|
648
650
|
# @api private
|
649
651
|
def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds,
|
650
652
|
flags)
|
653
|
+
super()
|
651
654
|
@magic = magic
|
652
655
|
@cputype = cputype
|
653
656
|
# For now we're not interested in additional capability bits also to be
|
data/lib/macho/load_commands.rb
CHANGED
data/lib/macho/sections.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-macho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for viewing and manipulating Mach-O files in Ruby.
|
14
14
|
email: william@yossarian.net
|
@@ -42,7 +42,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '2.
|
45
|
+
version: '2.5'
|
46
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - ">="
|