seccomp-tools 1.6.1 → 1.6.2
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 +21 -0
- data/README.md +4 -4
- data/lib/seccomp-tools/asm/compiler.rb +7 -7
- data/lib/seccomp-tools/asm/sasm.tab.rb +4 -2
- data/lib/seccomp-tools/asm/scanner.rb +7 -7
- data/lib/seccomp-tools/bpf.rb +2 -2
- data/lib/seccomp-tools/cli/asm.rb +1 -1
- data/lib/seccomp-tools/cli/cli.rb +1 -3
- data/lib/seccomp-tools/cli/disasm.rb +1 -1
- data/lib/seccomp-tools/cli/dump.rb +2 -2
- data/lib/seccomp-tools/cli/emu.rb +12 -4
- data/lib/seccomp-tools/consts/sys_nr/amd64.rb +1 -1
- data/lib/seccomp-tools/disasm/context.rb +3 -3
- data/lib/seccomp-tools/disasm/disasm.rb +1 -1
- data/lib/seccomp-tools/dumper.rb +2 -2
- data/lib/seccomp-tools/emulator.rb +4 -4
- data/lib/seccomp-tools/instruction/ld.rb +1 -1
- data/lib/seccomp-tools/instruction/ret.rb +1 -1
- data/lib/seccomp-tools/logger.rb +1 -1
- data/lib/seccomp-tools/syscall.rb +2 -2
- data/lib/seccomp-tools/version.rb +1 -1
- metadata +48 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e367e58696b5e8ff43054439401688981bcc960c0f80882384054245f21efbe4
|
|
4
|
+
data.tar.gz: 3af03e40f20244cf2bdbc82254a514d84c6792d87bd167305c4b0edd9a356f35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d8542e0a5330c40418947ed864a32fb9b125ed6b25aead0faadcb7743cae4c3b03a17a7dfaf41a90e0585e7ffb407e2af00cbc931e9e3c2334f0f176cf368c7
|
|
7
|
+
data.tar.gz: c08c293b669e59d253daec6351f4b43a4ae3d34fe9b25bc9663e5a3f21361f90b15d578cf0c4be1e468b50e8ceb7b3b6e36117eb7aa7bea66dd38fa1cc8680b5
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
[](https://github.com/david942j/seccomp-tools/actions)
|
|
2
|
-
[](https://codeclimate.com/github/david942j/seccomp-tools/coverage)
|
|
2
|
+
[](https://qlty.sh/gh/david942j/projects/seccomp-tools)
|
|
3
|
+
[](https://qlty.sh/gh/david942j/projects/seccomp-tools)
|
|
5
4
|
[](https://inch-ci.org/github/david942j/seccomp-tools)
|
|
6
5
|
[](https://www.rubydoc.info/github/david942j/seccomp-tools/)
|
|
7
6
|
[](http://choosealicense.com/licenses/mit/)
|
|
@@ -31,7 +30,7 @@ $ gem install seccomp-tools
|
|
|
31
30
|
|
|
32
31
|
If you failed when compiling, try:
|
|
33
32
|
```
|
|
34
|
-
sudo apt install gcc ruby-dev
|
|
33
|
+
sudo apt install gcc ruby-dev make
|
|
35
34
|
```
|
|
36
35
|
and install seccomp-tools again.
|
|
37
36
|
|
|
@@ -348,6 +347,7 @@ $ seccomp-tools emu --help
|
|
|
348
347
|
# Supported architectures are <aarch64|amd64|i386|s390x>.
|
|
349
348
|
# Default: amd64
|
|
350
349
|
# -q, --[no-]quiet Run quietly, only show emulation result.
|
|
350
|
+
# -i, --ip=VAL Set instruction pointer.
|
|
351
351
|
|
|
352
352
|
$ seccomp-tools emu spec/data/libseccomp.bpf write 0x3
|
|
353
353
|
# line CODE JT JF K
|
|
@@ -12,6 +12,9 @@ module SeccompTools
|
|
|
12
12
|
#
|
|
13
13
|
# Compile seccomp rules.
|
|
14
14
|
class Compiler
|
|
15
|
+
# The farthest distance of a relative jump in BPF.
|
|
16
|
+
JUMP_DISTANCE_MAX = 255
|
|
17
|
+
|
|
15
18
|
# Instantiate a {Compiler} object.
|
|
16
19
|
#
|
|
17
20
|
# @param [String] source
|
|
@@ -21,7 +24,7 @@ module SeccompTools
|
|
|
21
24
|
# @param [Symbol] arch
|
|
22
25
|
# Architecture.
|
|
23
26
|
def initialize(source, filename, arch)
|
|
24
|
-
@scanner = Scanner.new(source, arch, filename:
|
|
27
|
+
@scanner = Scanner.new(source, arch, filename:)
|
|
25
28
|
@arch = arch
|
|
26
29
|
@symbols = {}
|
|
27
30
|
end
|
|
@@ -115,7 +118,7 @@ module SeccompTools
|
|
|
115
118
|
code |= Const::BPF::OP.fetch(a, 0)
|
|
116
119
|
code |= Const::BPF::MISCOP.fetch(a, 0)
|
|
117
120
|
end
|
|
118
|
-
BPF.new({ code
|
|
121
|
+
BPF.new({ code:, k:, jt:, jf: }, @arch, @line)
|
|
119
122
|
end
|
|
120
123
|
|
|
121
124
|
# A = -A
|
|
@@ -144,7 +147,7 @@ module SeccompTools
|
|
|
144
147
|
|
|
145
148
|
def emit_alu(op, val)
|
|
146
149
|
src, k = val.x? ? [:x, 0] : [:k, val.to_i]
|
|
147
|
-
emit(:alu, convert_alu_op(op), src, k:
|
|
150
|
+
emit(:alu, convert_alu_op(op), src, k:)
|
|
148
151
|
end
|
|
149
152
|
|
|
150
153
|
def convert_alu_op(op)
|
|
@@ -169,9 +172,6 @@ module SeccompTools
|
|
|
169
172
|
emit(:ret, src, k: val.to_i)
|
|
170
173
|
end
|
|
171
174
|
|
|
172
|
-
# The farthest distance of a relative jump in BPF.
|
|
173
|
-
JUMP_DISTANCE_MAX = 255
|
|
174
|
-
|
|
175
175
|
def emit_cmp(cmp, jt_sym, jf_sym)
|
|
176
176
|
jt = jt_sym[0]
|
|
177
177
|
jf = jf_sym[0]
|
|
@@ -187,7 +187,7 @@ module SeccompTools
|
|
|
187
187
|
val = cmp[1]
|
|
188
188
|
src = val.x? ? :x : :k
|
|
189
189
|
k = val.x? ? 0 : val.to_i
|
|
190
|
-
emit(:jmp, jop, src, jt
|
|
190
|
+
emit(:jmp, jop, src, jt:, jf:, k:)
|
|
191
191
|
end
|
|
192
192
|
|
|
193
193
|
# == != >= <= > < &
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#
|
|
2
2
|
# DO NOT MODIFY!!!!
|
|
3
|
-
# This file is automatically generated by Racc 1.
|
|
4
|
-
# from Racc grammar file "".
|
|
3
|
+
# This file is automatically generated by Racc 1.8.1
|
|
4
|
+
# from Racc grammar file "sasm.y".
|
|
5
5
|
#
|
|
6
6
|
|
|
7
7
|
require 'racc/parser.rb'
|
|
@@ -311,6 +311,7 @@ Racc_arg = [
|
|
|
311
311
|
racc_shift_n,
|
|
312
312
|
racc_reduce_n,
|
|
313
313
|
racc_use_result_var ]
|
|
314
|
+
Ractor.make_shareable(Racc_arg) if defined?(Ractor)
|
|
314
315
|
|
|
315
316
|
Racc_token_to_s_table = [
|
|
316
317
|
"$end",
|
|
@@ -387,6 +388,7 @@ Racc_token_to_s_table = [
|
|
|
387
388
|
"alu_op",
|
|
388
389
|
"args",
|
|
389
390
|
"number" ]
|
|
391
|
+
Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
|
|
390
392
|
|
|
391
393
|
Racc_debug_parser = false
|
|
392
394
|
|
|
@@ -18,25 +18,25 @@ module SeccompTools
|
|
|
18
18
|
# Keywords with special meanings in our assembly. Keywords are all case-insensitive.
|
|
19
19
|
KEYWORDS = %w[a x if else return mem args args_h data len sys_number arch instruction_pointer].freeze
|
|
20
20
|
# Regexp for matching keywords.
|
|
21
|
-
KEYWORD_MATCHER = /\A\b(#{KEYWORDS.join('|')})\b/i
|
|
21
|
+
KEYWORD_MATCHER = /\A\b(#{KEYWORDS.join('|')})\b/i
|
|
22
22
|
# Action strings can be used in a return statement. Actions must be in upper case.
|
|
23
23
|
# See {SeccompTools::Const::BPF::ACTION}.
|
|
24
24
|
ACTIONS = Const::BPF::ACTION.keys.map(&:to_s)
|
|
25
25
|
# Regexp for matching actions.
|
|
26
|
-
ACTION_MATCHER = /\A\b(#{ACTIONS.join('|')})\b
|
|
26
|
+
ACTION_MATCHER = /\A\b(#{ACTIONS.join('|')})\b/
|
|
27
27
|
# Special constants for checking the current architecture. See {SeccompTools::Const::Audit::ARCH}. These constants
|
|
28
28
|
# are case-insensitive.
|
|
29
29
|
AUDIT_ARCHES = Const::Audit::ARCH.keys
|
|
30
30
|
# Regexp for matching arch values.
|
|
31
|
-
AUDIT_ARCH_MATCHER = /\A\b(#{AUDIT_ARCHES.join('|')})\b/i
|
|
31
|
+
AUDIT_ARCH_MATCHER = /\A\b(#{AUDIT_ARCHES.join('|')})\b/i
|
|
32
32
|
# Comparisons.
|
|
33
33
|
COMPARE = %w[== != >= <= > <].freeze
|
|
34
34
|
# Regexp for matching comparisons.
|
|
35
|
-
COMPARE_MATCHER = /\A(#{COMPARE.join('|')})
|
|
35
|
+
COMPARE_MATCHER = /\A(#{COMPARE.join('|')})/
|
|
36
36
|
# All valid arithmetic operators.
|
|
37
37
|
ALU_OP = %w[+ - * / | ^ << >>].freeze
|
|
38
38
|
# Regexp for matching ALU operators.
|
|
39
|
-
ALU_OP_MATCHER = /\A(#{ALU_OP.map { |o| ::Regexp.escape(o) }.join('|')})
|
|
39
|
+
ALU_OP_MATCHER = /\A(#{ALU_OP.map { |o| ::Regexp.escape(o) }.join('|')})/
|
|
40
40
|
# Supported architectures
|
|
41
41
|
ARCHES = SeccompTools::Syscall::ABI.keys.map(&:to_s)
|
|
42
42
|
|
|
@@ -149,14 +149,14 @@ module SeccompTools
|
|
|
149
149
|
<<-EOS
|
|
150
150
|
#{@filename}:#{tok.line + 1}:#{tok.col + 1} #{msg}
|
|
151
151
|
#{line}
|
|
152
|
-
#{' ' * calculate_spaces(@lines[tok.line][0...tok.col]) + '^' * tok.str.size}
|
|
152
|
+
#{(' ' * calculate_spaces(@lines[tok.line][0...tok.col])) + ('^' * tok.str.size)}
|
|
153
153
|
EOS
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
private
|
|
157
157
|
|
|
158
158
|
def calculate_spaces(str)
|
|
159
|
-
str.size + str.count("\t") * (TAB_WIDTH - 1)
|
|
159
|
+
str.size + (str.count("\t") * (TAB_WIDTH - 1))
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
end
|
data/lib/seccomp-tools/bpf.rb
CHANGED
|
@@ -108,8 +108,8 @@ module SeccompTools
|
|
|
108
108
|
# @yieldparam [Context] ctx
|
|
109
109
|
# Context after this instruction.
|
|
110
110
|
# @return [void]
|
|
111
|
-
def branch(context, &
|
|
112
|
-
inst.branch(context).each(&
|
|
111
|
+
def branch(context, &)
|
|
112
|
+
inst.branch(context).each(&)
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
# Corresponding instruction object.
|
|
@@ -10,7 +10,7 @@ module SeccompTools
|
|
|
10
10
|
# Summary of this command.
|
|
11
11
|
SUMMARY = 'Seccomp bpf assembler.'
|
|
12
12
|
# Usage of this command.
|
|
13
|
-
USAGE = "asm - #{SUMMARY}\n\nUsage: seccomp-tools asm IN_FILE [options]"
|
|
13
|
+
USAGE = "asm - #{SUMMARY}\n\nUsage: seccomp-tools asm IN_FILE [options]".freeze
|
|
14
14
|
|
|
15
15
|
def initialize(*)
|
|
16
16
|
super
|
|
@@ -10,7 +10,7 @@ module SeccompTools
|
|
|
10
10
|
# Summary of this command.
|
|
11
11
|
SUMMARY = 'Disassemble seccomp bpf.'
|
|
12
12
|
# Usage of this command.
|
|
13
|
-
USAGE = "disasm - #{SUMMARY}\n\nUsage: seccomp-tools disasm BPF_FILE [options]"
|
|
13
|
+
USAGE = "disasm - #{SUMMARY}\n\nUsage: seccomp-tools disasm BPF_FILE [options]".freeze
|
|
14
14
|
|
|
15
15
|
def initialize(*)
|
|
16
16
|
super
|
|
@@ -15,7 +15,7 @@ module SeccompTools
|
|
|
15
15
|
SUMMARY = 'Automatically dump seccomp bpf from execution file(s).'
|
|
16
16
|
# Usage of this command.
|
|
17
17
|
USAGE = "dump - #{SUMMARY}\nNOTE : This function is only available on Linux." \
|
|
18
|
-
"\n\nUsage: seccomp-tools dump [exec] [options]"
|
|
18
|
+
"\n\nUsage: seccomp-tools dump [exec] [options]".freeze
|
|
19
19
|
|
|
20
20
|
def initialize(*)
|
|
21
21
|
super
|
|
@@ -72,7 +72,7 @@ module SeccompTools
|
|
|
72
72
|
case option[:format]
|
|
73
73
|
when :inspect then output { "\"#{bpf.bytes.map { |b| format('\\x%02X', b) }.join}\"\n" }
|
|
74
74
|
when :raw then output { bpf }
|
|
75
|
-
when :disasm then output { SeccompTools::Disasm.disasm(bpf, arch:
|
|
75
|
+
when :disasm then output { SeccompTools::Disasm.disasm(bpf, arch:) }
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
if option[:pid].nil?
|
|
@@ -15,7 +15,7 @@ module SeccompTools
|
|
|
15
15
|
# Summary of this command.
|
|
16
16
|
SUMMARY = 'Emulate seccomp rules.'
|
|
17
17
|
# Usage of this command.
|
|
18
|
-
USAGE = "emu - #{SUMMARY}\n\nUsage: seccomp-tools emu [options] BPF_FILE [sys_nr [arg0 [arg1 ... arg5]]]"
|
|
18
|
+
USAGE = "emu - #{SUMMARY}\n\nUsage: seccomp-tools emu [options] BPF_FILE [sys_nr [arg0 [arg1 ... arg5]]]".freeze
|
|
19
19
|
|
|
20
20
|
def initialize(*)
|
|
21
21
|
super
|
|
@@ -33,6 +33,10 @@ module SeccompTools
|
|
|
33
33
|
opt.on('-q', '--[no-]quiet', 'Run quietly, only show emulation result.') do |v|
|
|
34
34
|
option[:verbose] = 0 if v
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
opt.on('-i', '--ip=VAL', Integer, 'Set instruction pointer.') do |val|
|
|
38
|
+
option[:instruction_pointer] = val
|
|
39
|
+
end
|
|
36
40
|
end
|
|
37
41
|
end
|
|
38
42
|
|
|
@@ -50,9 +54,13 @@ module SeccompTools
|
|
|
50
54
|
sys = evaluate_sys_nr(sys) if sys
|
|
51
55
|
args.map! { |v| Integer(v) }
|
|
52
56
|
trace = Set.new
|
|
53
|
-
res = SeccompTools::Emulator.new(
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
res = SeccompTools::Emulator.new(
|
|
58
|
+
insts,
|
|
59
|
+
sys_nr: sys,
|
|
60
|
+
args:,
|
|
61
|
+
instruction_pointer: option[:instruction_pointer] && Integer(option[:instruction_pointer]),
|
|
62
|
+
arch: option[:arch]
|
|
63
|
+
).run
|
|
56
64
|
|
|
57
65
|
if option[:verbose] >= 1
|
|
58
66
|
disasm = SeccompTools::Disasm.disasm(raw, arch: option[:arch]).lines
|
|
@@ -338,4 +338,4 @@ X32_MODE_BIT = 0x40000000
|
|
|
338
338
|
pkey_alloc: 330,
|
|
339
339
|
pkey_free: 331,
|
|
340
340
|
statx: 332
|
|
341
|
-
}.tap { |h| h.keys.each { |k| h["x32_#{k}"
|
|
341
|
+
}.tap { |h| h.keys.each { |k| h[:"x32_#{k}"] = h[k] | X32_MODE_BIT } }
|
|
@@ -36,7 +36,7 @@ module SeccompTools
|
|
|
36
36
|
# Defines hash function.
|
|
37
37
|
# @return [Integer]
|
|
38
38
|
def hash
|
|
39
|
-
@rel
|
|
39
|
+
[@rel, @val].hash
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# Defines +eql?+.
|
|
@@ -78,7 +78,7 @@ module SeccompTools
|
|
|
78
78
|
values[reg] = if rel == :mem
|
|
79
79
|
values[val]
|
|
80
80
|
else
|
|
81
|
-
Value.new(rel
|
|
81
|
+
Value.new(rel:, val:)
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
|
|
@@ -164,7 +164,7 @@ module SeccompTools
|
|
|
164
164
|
# For +Set+ to get the hash value.
|
|
165
165
|
# @return [Integer]
|
|
166
166
|
def hash
|
|
167
|
-
values
|
|
167
|
+
[values, known_data].hash
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
end
|
data/lib/seccomp-tools/dumper.rb
CHANGED
|
@@ -101,7 +101,7 @@ module SeccompTools
|
|
|
101
101
|
child, status = Process.wait2
|
|
102
102
|
cont = true
|
|
103
103
|
# TODO: Test if clone / vfork works
|
|
104
|
-
if [Ptrace::EVENT_CLONE, Ptrace::EVENT_FORK, Ptrace::EVENT_VFORK].include?(status >> 16)
|
|
104
|
+
if [Ptrace::EVENT_CLONE, Ptrace::EVENT_FORK, Ptrace::EVENT_VFORK].include?(status.to_i >> 16)
|
|
105
105
|
# New child launched!
|
|
106
106
|
# newpid = SeccompTools::Ptrace.geteventmsg(child)
|
|
107
107
|
elsif status.stopped? && status.stopsig & 0x80 != 0
|
|
@@ -132,7 +132,7 @@ module SeccompTools
|
|
|
132
132
|
def handle_child(*args)
|
|
133
133
|
Ptrace.traceme_and_stop
|
|
134
134
|
exec(*args)
|
|
135
|
-
rescue # rubocop:disable Style/RescueStandardError
|
|
135
|
+
rescue # rubocop:disable Style/RescueStandardError
|
|
136
136
|
Logger.error("Failed to execute #{args.join(' ')}")
|
|
137
137
|
exit(1)
|
|
138
138
|
end
|
|
@@ -98,7 +98,7 @@ module SeccompTools
|
|
|
98
98
|
|
|
99
99
|
def alu(op, src)
|
|
100
100
|
if op == :neg
|
|
101
|
-
set(:a, 2**32 - get(:a))
|
|
101
|
+
set(:a, (2**32) - get(:a))
|
|
102
102
|
else
|
|
103
103
|
src = get(:x) if src == :x
|
|
104
104
|
set(:a, get(:a).__send__(op, src))
|
|
@@ -140,14 +140,14 @@ module SeccompTools
|
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
def data_of(index)
|
|
143
|
-
raise IndexError, "Invalid index: #{index}" unless (
|
|
143
|
+
raise IndexError, "Invalid index: #{index}" unless index.nobits?(3) && index.between?(0, 63)
|
|
144
144
|
|
|
145
145
|
index /= 4
|
|
146
146
|
case index
|
|
147
147
|
when 0 then @sys_nr || undefined('sys_number')
|
|
148
148
|
when 1 then @arch || undefined('arch')
|
|
149
|
-
when 2 then @ip & 0xffffffff || undefined('instruction_pointer')
|
|
150
|
-
when 3 then @ip >> 32 || undefined('instruction_pointer')
|
|
149
|
+
when 2 then (@ip & 0xffffffff) || undefined('instruction_pointer')
|
|
150
|
+
when 3 then (@ip >> 32) || undefined('instruction_pointer')
|
|
151
151
|
else
|
|
152
152
|
val = @args[(index - 4) / 2] || undefined("args[#{(index - 4) / 2}]")
|
|
153
153
|
(val >> (index.even? ? 0 : 32)) & 0xffffffff
|
|
@@ -70,7 +70,7 @@ module SeccompTools
|
|
|
70
70
|
when 8 then 'instruction_pointer'
|
|
71
71
|
when 12 then 'instruction_pointer >> 32'
|
|
72
72
|
else
|
|
73
|
-
idx = Array.new(12) { |i| i * 4 + 16 }.index(k)
|
|
73
|
+
idx = Array.new(12) { |i| (i * 4) + 16 }.index(k)
|
|
74
74
|
return 'INVALID' if idx.nil?
|
|
75
75
|
|
|
76
76
|
args_name(idx)
|
data/lib/seccomp-tools/logger.rb
CHANGED
|
@@ -24,7 +24,7 @@ module SeccompTools
|
|
|
24
24
|
str.strip.empty? ? str : prep + str
|
|
25
25
|
end
|
|
26
26
|
color = severity.downcase.to_sym
|
|
27
|
-
msg =
|
|
27
|
+
msg = "[#{SeccompTools::Util.colorize(severity, t: color)}] #{message.join}"
|
|
28
28
|
msg << "\n" unless msg.end_with?("\n")
|
|
29
29
|
msg
|
|
30
30
|
end
|
|
@@ -58,8 +58,8 @@ module SeccompTools
|
|
|
58
58
|
def dump_bpf
|
|
59
59
|
addr = args[2]
|
|
60
60
|
len = Ptrace.peekdata(pid, addr, 0) & 0xffff # len is unsigned short
|
|
61
|
-
filter = Ptrace.peekdata(pid, addr + bits / 8, 0) & ((1 << bits) - 1)
|
|
62
|
-
Array.new(len) { |i| Ptrace.peekdata(pid, filter + i * 8, 0) }.pack('Q*')
|
|
61
|
+
filter = Ptrace.peekdata(pid, addr + (bits / 8), 0) & ((1 << bits) - 1)
|
|
62
|
+
Array.new(len) { |i| Ptrace.peekdata(pid, filter + (i * 8), 0) }.pack('Q*')
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
# @return [Symbol]
|
metadata
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: seccomp-tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- david942j
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: ostruct
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
13
26
|
- !ruby/object:Gem::Dependency
|
|
14
27
|
name: rake
|
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,6 +107,20 @@ dependencies:
|
|
|
94
107
|
- - "~>"
|
|
95
108
|
- !ruby/object:Gem::Version
|
|
96
109
|
version: '0.9'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: logger
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
type: :runtime
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
97
124
|
- !ruby/object:Gem::Dependency
|
|
98
125
|
name: os
|
|
99
126
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,6 +141,20 @@ dependencies:
|
|
|
114
141
|
- - ">="
|
|
115
142
|
- !ruby/object:Gem::Version
|
|
116
143
|
version: 1.1.1
|
|
144
|
+
- !ruby/object:Gem::Dependency
|
|
145
|
+
name: racc
|
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
|
147
|
+
requirements:
|
|
148
|
+
- - "~>"
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
version: '1.8'
|
|
151
|
+
type: :runtime
|
|
152
|
+
prerelease: false
|
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
154
|
+
requirements:
|
|
155
|
+
- - "~>"
|
|
156
|
+
- !ruby/object:Gem::Version
|
|
157
|
+
version: '1.8'
|
|
117
158
|
description: |
|
|
118
159
|
Provide useful tools to analyze seccomp rules.
|
|
119
160
|
Visit https://github.com/david942j/seccomp-tools for more details.
|
|
@@ -125,6 +166,7 @@ extensions:
|
|
|
125
166
|
- ext/ptrace/extconf.rb
|
|
126
167
|
extra_rdoc_files: []
|
|
127
168
|
files:
|
|
169
|
+
- LICENSE
|
|
128
170
|
- README.md
|
|
129
171
|
- bin/seccomp-tools
|
|
130
172
|
- ext/ptrace/extconf.rb
|
|
@@ -174,7 +216,6 @@ files:
|
|
|
174
216
|
- lib/seccomp-tools/templates/asm.s390x.asm
|
|
175
217
|
- lib/seccomp-tools/util.rb
|
|
176
218
|
- lib/seccomp-tools/version.rb
|
|
177
|
-
homepage:
|
|
178
219
|
licenses:
|
|
179
220
|
- MIT
|
|
180
221
|
metadata:
|
|
@@ -182,7 +223,7 @@ metadata:
|
|
|
182
223
|
documentation_uri: https://www.rubydoc.info/github/david942j/seccomp-tools/master
|
|
183
224
|
homepage_uri: https://github.com/david942j/seccomp-tools
|
|
184
225
|
source_code_uri: https://github.com/david942j/seccomp-tools
|
|
185
|
-
|
|
226
|
+
rubygems_mfa_required: 'true'
|
|
186
227
|
rdoc_options: []
|
|
187
228
|
require_paths:
|
|
188
229
|
- lib
|
|
@@ -190,15 +231,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
190
231
|
requirements:
|
|
191
232
|
- - ">="
|
|
192
233
|
- !ruby/object:Gem::Version
|
|
193
|
-
version: '
|
|
234
|
+
version: '3.1'
|
|
194
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
236
|
requirements:
|
|
196
237
|
- - ">="
|
|
197
238
|
- !ruby/object:Gem::Version
|
|
198
239
|
version: '0'
|
|
199
240
|
requirements: []
|
|
200
|
-
rubygems_version: 3.
|
|
201
|
-
signing_key:
|
|
241
|
+
rubygems_version: 3.6.9
|
|
202
242
|
specification_version: 4
|
|
203
243
|
summary: seccomp-tools
|
|
204
244
|
test_files: []
|