bindef 0.0.1 → 0.0.6
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/LICENSE +29 -2
- data/README.md +7 -1
- data/bin/bd +7 -2
- data/lib/bindef.rb +10 -4
- data/lib/bindef/extras/ctrl.rb +1 -1
- data/lib/bindef/extras/int128.rb +1 -1
- data/lib/bindef/extras/string.rb +1 -1
- data/lib/bindef/extras/tlv.rb +1 -1
- data/lib/bindef/version.rb +1 -1
- metadata +33 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05652fe2741d34eb181ce1511ed815b6fae22bec659cc232973cbeca32b642aa
|
4
|
+
data.tar.gz: 2ac64883af476f0d7ad2371ebb1bdde116c737f7b93b304f6cbf67e6f275ab22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec1c23f12c5b579e2dcd4f7a3f6f7f62f4c36f4c006b8e5c56ece06e2c36ba602b524b8c3f2844ed24798903c6f9afad335c95b80a2690ec86007269704f15f
|
7
|
+
data.tar.gz: 543f80a5e086a9ef85ec34a820cc1163e05c1a36837c2e5d914b45772273a8cea22da751bc1827794fb7b3a73675497208e0292ea4564fa5e89baca93dc96fd7
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
The MIT License (MIT)
|
1
|
+
The MIT License (MIT) with restrictions
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2020 William Woodruff <william @ yossarian.net>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -19,3 +19,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
THE SOFTWARE.
|
22
|
+
|
23
|
+
The following terms additionally apply and override any above terms for
|
24
|
+
applicable parties:
|
25
|
+
|
26
|
+
You may not use, copy, modify, merge, publish, distribute, sublicense,
|
27
|
+
and/or sell copies of the Software in a military or law enforcement context,
|
28
|
+
defined as follows:
|
29
|
+
|
30
|
+
1. A military context is a professional context where the intended application
|
31
|
+
of the Software is integration or use with or by military software, tools
|
32
|
+
(software or hardware), or personnel. This includes contractors and
|
33
|
+
subcontractors as well as research affiliates of any military organization.
|
34
|
+
|
35
|
+
2. A law enforcement context is a professional context where the intended
|
36
|
+
application of the Software is integration or use with or by law enforcement
|
37
|
+
software, tools (software or hardware), or personnel. This includes
|
38
|
+
contractors and subcontractors as well as research affiliates of any law
|
39
|
+
enforcement organization.
|
40
|
+
|
41
|
+
Entities that sell or license to military or law enforcement organizations
|
42
|
+
may use the Software under the original terms, but only in contexts that do
|
43
|
+
not assist or supplement the sold or licensed product.
|
44
|
+
|
45
|
+
Students and academics who are affiliated with research institutions may use
|
46
|
+
the Software under the original terms, but only in contexts that do not assist
|
47
|
+
or supplement collaboration or affiliation with any military or law
|
48
|
+
enforcement organization.
|
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
bindef
|
2
2
|
========
|
3
3
|
|
4
|
+

|
5
|
+
[](https://badge.fury.io/rb/bindef)
|
6
|
+
[](https://github.com/woodruffw/bindef/actions?query=workflow%3ACI)
|
7
|
+
[](https://codecov.io/gh/woodruffw/bindef)
|
8
|
+
[](https://codeclimate.com/github/woodruffw/bindef/maintainability)
|
9
|
+
|
4
10
|
`bindef` is a DSL and command-line tool for building binary files.
|
5
11
|
|
6
12
|
It's inspired by [t2b](https://github.com/thosakwe/t2b), but with a few crucial differences:
|
@@ -31,7 +37,7 @@ pragma endian: :big
|
|
31
37
|
u32 0xFF000000
|
32
38
|
```
|
33
39
|
|
34
|
-
The [
|
40
|
+
The [example directory](example/) has more. Read the [SYNTAX](SYNTAX.md) file for a
|
35
41
|
complete listing of commands and pragmas.
|
36
42
|
|
37
43
|
## Installation
|
data/bin/bd
CHANGED
@@ -25,7 +25,7 @@ OptionParser.new do |parser|
|
|
25
25
|
options[:input] = File.open(input, "r")
|
26
26
|
end
|
27
27
|
|
28
|
-
parser.on "-o", "--output FILE", String, "Write output to FILE (default:
|
28
|
+
parser.on "-o", "--output FILE", String, "Write output to FILE (default: stdout)" do |output|
|
29
29
|
abort("Error: #{output} exists, not overwriting") if File.file?(output)
|
30
30
|
options[:output] = File.open(output, "wb")
|
31
31
|
end
|
@@ -41,6 +41,11 @@ OptionParser.new do |parser|
|
|
41
41
|
parser.on "-e", "--extra ext1,ext2,ext3", Array, "Extra command set(s) to load" do |extras|
|
42
42
|
extras.each { |e| require "bindef/extras/#{e}" }
|
43
43
|
end
|
44
|
+
|
45
|
+
parser.on "-V", "--version" do
|
46
|
+
puts "bd (bindef) version #{Bindef::VERSION}"
|
47
|
+
exit
|
48
|
+
end
|
44
49
|
end.parse!
|
45
50
|
|
46
51
|
bindef = Bindef.new(options[:output],
|
@@ -48,7 +53,7 @@ bindef = Bindef.new(options[:output],
|
|
48
53
|
verbose: options[:verbose],
|
49
54
|
warnings: options[:warnings])
|
50
55
|
|
51
|
-
options[:error].puts "W: output looks like a tty" if options[:output].tty? && options[:
|
56
|
+
options[:error].puts "W: output looks like a tty" if options[:output].tty? && options[:warnings]
|
52
57
|
|
53
58
|
begin
|
54
59
|
bindef.instance_eval options[:input].read, "input", 1
|
data/lib/bindef.rb
CHANGED
@@ -48,6 +48,7 @@ class Bindef
|
|
48
48
|
# Builds a string containing the given value packed into the given format.
|
49
49
|
# @param value [Object] the value to emit
|
50
50
|
# @param fmt [String] the `Array#pack` format to emit it in
|
51
|
+
# @api private
|
51
52
|
def blobify(value, fmt)
|
52
53
|
[value].pack(fmt)
|
53
54
|
end
|
@@ -66,6 +67,11 @@ class Bindef
|
|
66
67
|
raise CommandError, "unknown command: #{args.join(" ")}"
|
67
68
|
end
|
68
69
|
|
70
|
+
# @api private
|
71
|
+
def respond_to_missing?(*_args)
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
69
75
|
# Changes the values of the given pragma keys.
|
70
76
|
# @see PRAGMA_SCHEMA
|
71
77
|
# @param hsh [Hash] the keys and values to update the pragma state with
|
@@ -84,10 +90,10 @@ class Bindef
|
|
84
90
|
pragmas[key] = value
|
85
91
|
end
|
86
92
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
93
|
+
return unless block_given?
|
94
|
+
|
95
|
+
yield
|
96
|
+
pragmas.replace old_pragmas
|
91
97
|
end
|
92
98
|
|
93
99
|
# Emits a string.
|
data/lib/bindef/extras/ctrl.rb
CHANGED
data/lib/bindef/extras/int128.rb
CHANGED
data/lib/bindef/extras/string.rb
CHANGED
data/lib/bindef/extras/tlv.rb
CHANGED
data/lib/bindef/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bindef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: yard
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,9 +73,9 @@ files:
|
|
45
73
|
- lib/bindef/extras/tlv.rb
|
46
74
|
- lib/bindef/schemas.rb
|
47
75
|
- lib/bindef/version.rb
|
48
|
-
homepage:
|
76
|
+
homepage: https://github.com/woodruffw/bindef
|
49
77
|
licenses:
|
50
|
-
-
|
78
|
+
- Nonstandard
|
51
79
|
metadata: {}
|
52
80
|
post_install_message:
|
53
81
|
rdoc_options: []
|
@@ -64,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
92
|
- !ruby/object:Gem::Version
|
65
93
|
version: '0'
|
66
94
|
requirements: []
|
67
|
-
|
68
|
-
rubygems_version: 2.7.6
|
95
|
+
rubygems_version: 3.1.2
|
69
96
|
signing_key:
|
70
97
|
specification_version: 4
|
71
98
|
summary: bindef - A DSL and command-line tool for generating binary files
|