ruby-macho 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73c21b87da2cf6cdac1c2123d846fa6fd8eb2863c4fe87d0170fa6162d110329
4
- data.tar.gz: 0a59a2d38d59665eee474aad3f394aa54f1f2da5926c01b65824a75992da3e61
3
+ metadata.gz: 8b98417732314a92f3493ffd08e9221edbd342941bee24245b88b07fb292c2f8
4
+ data.tar.gz: cc17a19152fac25565b9a2759f7aa9aa2674318623e6bf620527e32e1796acda
5
5
  SHA512:
6
- metadata.gz: ac41936e243431a8346059b40e32fa6ed33c7f9f1f9dbbb9efcd7d1391d40931a6bdc33bf8fb5f676fb87af305cb92d18df9fe47151724cfb141996db47a2bd5
7
- data.tar.gz: 4feeb4b940e38cb0fe641b28ae08dff26a17d213e6c8602442912ce59d7de756618adbd36feac62846ee1b8f0aa0bb2f0a765f5b74fe462b371954184eaa65bc
6
+ metadata.gz: 7135b6f32de153de839197779a1770e4a18c071a063ec8fa0b88791171fc6d45e208dd8df7a4338ca1f663d74cc25b2b78c791c61873598177f314f01c4ed108
7
+ data.tar.gz: 16132d807fd316cddd68638cdf9877e638134b438c5fddeb7901619cd8f52aba244ca6d2e7613981bd7d645612bce66434dc2f17400bea8fcd750e7444e782d1
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "English"
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.3.0"
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
- system("codesign", "--sign", "-", "--force",
56
- "--preserve-metadata=entitlements,requirements,flags,runtime",
57
- filename)
56
+ _, _, status = Open3.capture3("codesign", "--sign", "-", "--force",
57
+ "--preserve-metadata=entitlements,requirements,flags,runtime",
58
+ filename)
58
59
 
59
- raise ModificationError, "#{filename}: signing failed!" unless $CHILD_STATUS.success?
60
+ raise CodeSigningError, "#{filename}: signing failed!" unless status.success?
60
61
  end
61
62
  end
@@ -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.
@@ -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
- begin
402
- yield macho
403
- rescue RecoverableModificationError => e
404
- e.macho_slice = index
401
+ yield macho
402
+ rescue RecoverableModificationError => e
403
+ e.macho_slice = index
405
404
 
406
- # Strict mode: Immediately re-raise. Otherwise: Retain, check later.
407
- raise e if strict
405
+ # Strict mode: Immediately re-raise. Otherwise: Retain, check later.
406
+ raise e if strict
408
407
 
409
- errors << e
410
- end
408
+ errors << e
411
409
  end
412
410
 
413
411
  # Non-strict mode: Raise first error if *all* Mach-O slices failed.
@@ -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
@@ -231,6 +231,7 @@ module MachO
231
231
  # @param cmdsize [Integer] the size of the load command in bytes
232
232
  # @api private
233
233
  def initialize(view, cmd, cmdsize)
234
+ super()
234
235
  @view = view
235
236
  @cmd = cmd
236
237
  @cmdsize = cmdsize
@@ -118,6 +118,7 @@ module MachO
118
118
  # @api private
119
119
  def initialize(sectname, segname, addr, size, offset, align, reloff,
120
120
  nreloc, flags, reserved1, reserved2)
121
+ super()
121
122
  @sectname = sectname
122
123
  @segname = segname
123
124
  @addr = addr
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.3.0
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-10-12 00:00:00.000000000 Z
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.3'
45
+ version: '2.5'
46
46
  required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="