pwn 0.5.793 → 0.5.795
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/Gemfile +3 -3
- data/documentation/Backup-Retention.md +6 -4
- data/lib/pwn/backups.rb +56 -15
- data/lib/pwn/plugins/ai_sandbox.rb +9 -1
- data/lib/pwn/version.rb +1 -1
- data/spec/integration/spec_sandbox_isolation_spec.rb +43 -0
- data/spec/lib/pwn/backups_spec.rb +16 -3
- data/spec/lib/pwn/plugins/ai_sandbox_spec.rb +9 -0
- data/spec/lib/pwn/plugins/repl/ai_console_spec.rb +25 -6
- data/spec/lib/pwn/plugins/repl/ai_legacy_containment_spec.rb +33 -4
- data/spec/support/sandbox.rb +3 -1
- data/third_party/pwn_rdoc.jsonl +5 -0
- metadata +9 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b3dcfffe5307553d194d351676ac3eaf1691d7342fc6464b95e85703cdbbeb4
|
|
4
|
+
data.tar.gz: 1401f535f0537335601e31705528478e4e4db31ffa8a174aadc8daa79c8add88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1bd1c31a8df2a4e9c4ced9164dd404aa434d24a1858f037a7f4cbd44a2c50859504fd509776333f99834caa103f4e4f4f90b63cabf117643ea63ab3db6c715f
|
|
7
|
+
data.tar.gz: c229d034c61e8b5ad91e6082d4a3831fbe9f7323b396296e58ceab991fadb15996d624a29d446949d65d2ffa50fe8056806911cb9385b5d3f69b34267c2b197b
|
data/Gemfile
CHANGED
|
@@ -20,9 +20,9 @@ gem 'base32', '0.3.4'
|
|
|
20
20
|
gem 'bitcoin-ruby', '0.0.20'
|
|
21
21
|
gem 'brakeman', '8.1.0'
|
|
22
22
|
gem 'bson', '5.2.0'
|
|
23
|
-
gem 'bundler', '>=4.0.
|
|
23
|
+
gem 'bundler', '>=4.0.24'
|
|
24
24
|
gem 'bundler-audit', '>=0.9.3'
|
|
25
|
-
gem 'bunny', '3.
|
|
25
|
+
gem 'bunny', '3.6.0'
|
|
26
26
|
gem 'colorize', '1.1.0'
|
|
27
27
|
gem 'credit_card_validations', '10.0.0'
|
|
28
28
|
gem 'curses', '1.7.0'
|
|
@@ -88,7 +88,7 @@ gem 'ruby-audio', '1.6.1'
|
|
|
88
88
|
gem 'ruby-nmap', '1.0.3'
|
|
89
89
|
gem 'ruby-saml', '1.18.1'
|
|
90
90
|
gem 'rvm', '1.11.3.9'
|
|
91
|
-
gem 'savon', '2.
|
|
91
|
+
gem 'savon', '2.18.1'
|
|
92
92
|
gem 'selenium-devtools', '0.156.0'
|
|
93
93
|
gem 'selenium-webdriver', '4.52.0'
|
|
94
94
|
gem 'slack-ruby-client', '3.3.0'
|
|
@@ -40,10 +40,12 @@ that has no interrupted generation record, and an unpublished `.partial-`
|
|
|
40
40
|
copy that was never renamed into a restore name. Those are not certified as
|
|
41
41
|
complete; they are only eligible so one verified snapshot can be published.
|
|
42
42
|
Prepared/interrupted generations, retention-policy pins and current literal
|
|
43
|
-
evidence references remain protected.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
evidence references remain protected. A reference file that is not valid JSON
|
|
44
|
+
does not abort admission. A generation path found in that unreadable text stays
|
|
45
|
+
pinned; valid JSON still ignores a path that only appears inside quoted prose.
|
|
46
|
+
If protected folders still occupy the seven-folder limit, the next producer fails
|
|
47
|
+
before modifying its source. Unknown folder names still count toward capacity
|
|
48
|
+
and are not silently expired.
|
|
47
49
|
|
|
48
50
|
Transactions publish `prepared` before payload/source changes and `complete`
|
|
49
51
|
only after successful return. Exceptions, interrupted/blocked results and failed
|
data/lib/pwn/backups.rb
CHANGED
|
@@ -242,7 +242,15 @@ module PWN
|
|
|
242
242
|
policy = File.join(root, '.retention-policy.json')
|
|
243
243
|
raise IOError, 'Unsafe retention policy' if File.symlink?(policy)
|
|
244
244
|
|
|
245
|
-
pins =
|
|
245
|
+
pins = []
|
|
246
|
+
if File.file?(policy)
|
|
247
|
+
begin
|
|
248
|
+
parsed = JSON.parse(File.binread(policy))
|
|
249
|
+
pins = parsed.fetch('pins', [])
|
|
250
|
+
rescue JSON::ParserError, EncodingError
|
|
251
|
+
pin_raw_paths(text: File.binread(policy), root: root, pins: pins)
|
|
252
|
+
end
|
|
253
|
+
end
|
|
246
254
|
raise IOError, 'Invalid backup pins' unless pins.is_a?(Array) && pins.all? { |name| name.is_a?(String) && name.match?(/\A\d{8}_\d{6}(?:_[a-f0-9]{8})?\z/) }
|
|
247
255
|
|
|
248
256
|
pins = pins.dup
|
|
@@ -260,23 +268,56 @@ module PWN
|
|
|
260
268
|
admission = Thread.current[:pwn_maintenance_admission]
|
|
261
269
|
raise IOError, 'Backup reference budget exhausted' if admission && !admission.call(stat.size + 1)
|
|
262
270
|
|
|
263
|
-
|
|
264
|
-
values.select! { |value| value.is_a?(Hash) && (%w[prepared interrupted].include?(value['state']) || value['pinned'] == true) } if name == 'maintenance'
|
|
265
|
-
until values.empty?
|
|
266
|
-
value = values.pop
|
|
267
|
-
case value
|
|
268
|
-
when Hash then values.concat(value.values)
|
|
269
|
-
when Array then values.concat(value)
|
|
270
|
-
when String
|
|
271
|
-
match = value.match(%r{\A(?:#{Regexp.escape(root)}/|backup/)(\d{8}_\d{6}(?:_[a-f0-9]{8})?)(?:/|\z)})
|
|
272
|
-
pins << match[1] if match
|
|
273
|
-
end
|
|
274
|
-
end
|
|
271
|
+
collect_references(file: file, root: root, pins: pins, maintenance: name == 'maintenance')
|
|
275
272
|
end
|
|
276
273
|
end
|
|
277
274
|
pins.uniq
|
|
278
|
-
|
|
279
|
-
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
private_class_method def self.collect_references(opts = {})
|
|
278
|
+
file = opts[:file]
|
|
279
|
+
body = File.binread(file)
|
|
280
|
+
if file.end_with?('.jsonl')
|
|
281
|
+
body.split("\n".b).each do |line|
|
|
282
|
+
next if line.strip.empty?
|
|
283
|
+
|
|
284
|
+
begin
|
|
285
|
+
walk_reference(value: JSON.parse(line), root: opts[:root], pins: opts[:pins], maintenance: opts[:maintenance])
|
|
286
|
+
rescue JSON::ParserError, EncodingError
|
|
287
|
+
pin_raw_paths(text: line, root: opts[:root], pins: opts[:pins])
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
else
|
|
291
|
+
begin
|
|
292
|
+
walk_reference(value: JSON.parse(body), root: opts[:root], pins: opts[:pins], maintenance: opts[:maintenance])
|
|
293
|
+
rescue JSON::ParserError, EncodingError
|
|
294
|
+
pin_raw_paths(text: body, root: opts[:root], pins: opts[:pins])
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
private_class_method def self.walk_reference(opts = {})
|
|
300
|
+
values = [opts[:value]]
|
|
301
|
+
values.select! { |value| value.is_a?(Hash) && (%w[prepared interrupted].include?(value['state']) || value['pinned'] == true) } if opts[:maintenance]
|
|
302
|
+
root = opts[:root]
|
|
303
|
+
pins = opts[:pins]
|
|
304
|
+
until values.empty?
|
|
305
|
+
value = values.pop
|
|
306
|
+
case value
|
|
307
|
+
when Hash then values.concat(value.values)
|
|
308
|
+
when Array then values.concat(value)
|
|
309
|
+
when String
|
|
310
|
+
match = value.match(%r{\A(?:#{Regexp.escape(root)}/|backup/)(\d{8}_\d{6}(?:_[a-f0-9]{8})?)(?:/|\z)})
|
|
311
|
+
pins << match[1] if match
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
private_class_method def self.pin_raw_paths(opts = {})
|
|
317
|
+
text = opts[:text].to_s.b
|
|
318
|
+
root = opts[:root].to_s.b
|
|
319
|
+
pattern = Regexp.new("(?:#{Regexp.escape(root)}/|backup/)(\\d{8}_\\d{6}(?:_[a-f0-9]{8})?)(?:/|\\z)")
|
|
320
|
+
text.scan(pattern).each { |row| opts[:pins] << row[0] }
|
|
280
321
|
end
|
|
281
322
|
|
|
282
323
|
# Unreferenced complete generations, published pre-generation snapshots, and
|
|
@@ -87,7 +87,7 @@ module PWN
|
|
|
87
87
|
attach_function :openat, %i[int string int uint], :int
|
|
88
88
|
attach_function :mkdirat, %i[int string uint], :int
|
|
89
89
|
end
|
|
90
|
-
flags =
|
|
90
|
+
flags = directory_open_flags
|
|
91
91
|
identities = protected_roots.map do |path|
|
|
92
92
|
stat = File.stat(path)
|
|
93
93
|
[stat.dev, stat.ino]
|
|
@@ -114,6 +114,14 @@ module PWN
|
|
|
114
114
|
directory&.close unless directory&.closed?
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
+
# O_DIRECTORY is 1<<16 on x86_64 and 1<<14 on aarch64/arm. 1<<16 is O_DIRECT
|
|
118
|
+
# there, and open("/", O_DIRECT) returns EINVAL.
|
|
119
|
+
private_class_method def self.directory_open_flags(opts = {})
|
|
120
|
+
platform = opts[:platform] || RUBY_PLATFORM
|
|
121
|
+
directory = platform.match?(/\Aaarch64|\Aarm-/) ? (1 << 14) : (1 << 16)
|
|
122
|
+
File::RDONLY | File::NOFOLLOW | directory | (1 << 19)
|
|
123
|
+
end
|
|
124
|
+
|
|
117
125
|
# Mandatory repository boundary, independent of the optional profile.
|
|
118
126
|
# The block runs only in a child; cwd and restrictions never affect the UI.
|
|
119
127
|
public_class_method def self.protect_call(opts = {})
|
data/lib/pwn/version.rb
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'offline spec mission isolation' do
|
|
6
|
+
before do
|
|
7
|
+
@outside = Dir.mktmpdir('pwn-outside-mission-')
|
|
8
|
+
stub_const('PWN::AI::Agent::Mission::ROOT', File.join(@outside, 'missions'))
|
|
9
|
+
stub_const('PWN::AI::Agent::OpenGoal::GOAL_FILE', File.join(@outside, 'open_goal.json'))
|
|
10
|
+
PWN::AI::Agent::Mission.begin!(id: 'outside', request: 'Unrelated active mission fixture', unattended: true)
|
|
11
|
+
PWN::AI::Agent::Mission.note_job!(id: 'outside', job_id: 'outside-job', command: 'fixture')
|
|
12
|
+
PWN::AI::Agent::OpenGoal.begin!(request: 'Unrelated active mission fixture', mission_id: 'outside')
|
|
13
|
+
@outside_files = Dir.glob(File.join(@outside, '**', '*')).select { |path| File.file?(path) }.to_h { |path| [path, File.binread(path)] }
|
|
14
|
+
allow(PWN::Plugins::Jobs).to receive(:status).and_call_original
|
|
15
|
+
allow(PWN::Plugins::Jobs).to receive(:status).with(id: 'outside-job').and_return(id: 'outside-job', status: 'RUNNING')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after { FileUtils.remove_entry(@outside) if @outside && Dir.exist?(@outside) }
|
|
19
|
+
|
|
20
|
+
context 'with the shared persistence sandbox' do
|
|
21
|
+
include_context 'pwn tmp sandbox'
|
|
22
|
+
|
|
23
|
+
it 'answers through the provider without consulting or modifying an outside live mission' do
|
|
24
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
25
|
+
allow(PWN::AI::Agent::PromptBuilder).to receive(:build).and_return('Offline fixture')
|
|
26
|
+
allow(PWN::AI::Agent::TaskSummarizer).to receive(:enabled?).and_return(false)
|
|
27
|
+
allow(PWN::AI::Agent::Loop).to receive(:maybe_refresh_extro_snapshot!)
|
|
28
|
+
allow(PWN::AI::Agent::Loop).to receive(:may_finalize?).and_return(true)
|
|
29
|
+
allow(PWN::AI::Agent::Loop).to receive(:should_auto_introspect?).and_return(false)
|
|
30
|
+
PWN::Env[:ai][:active] = :openai
|
|
31
|
+
PWN::Env[:ai][:openai] = { model: 'offline-fixture' }
|
|
32
|
+
allow(PWN::AI::OpenAI).to receive(:chat_with_tools).and_return(choices: [{ message: { role: 'assistant', content: 'Fixture answer.', tool_calls: [] } }])
|
|
33
|
+
sid = PWN::Sessions.create(title: 'Isolation fixture')[:id]
|
|
34
|
+
answer = PWN::AI::Agent::Loop.run(request: 'what color is a lemon?', session_id: sid, enabled_toolsets: [])
|
|
35
|
+
expect(answer).to eq('Fixture answer.')
|
|
36
|
+
expect(PWN::AI::OpenAI).to have_received(:chat_with_tools).once
|
|
37
|
+
expect(PWN::AI::Agent::Mission::ROOT).to eq(File.join(@tmp, 'missions'))
|
|
38
|
+
expect(PWN::AI::Agent::OpenGoal::GOAL_FILE).to eq(File.join(@tmp, 'open_goal.json'))
|
|
39
|
+
expect(PWN::Plugins::Jobs).not_to have_received(:status).with(id: 'outside-job')
|
|
40
|
+
@outside_files.each { |path, bytes| expect(File.binread(path)).to eq(bytes) }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -58,11 +58,24 @@ describe PWN::Backups do
|
|
|
58
58
|
expect(File).not_to exist(copies[1])
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
it '
|
|
61
|
+
it 'admits a snapshot when a reference file is not valid JSON' do
|
|
62
62
|
copies = 7.times.map { described_class.capture(path: @source) }
|
|
63
|
+
generations = copies.map { |path| File.dirname(path, 2) }
|
|
64
|
+
generations.each_with_index { |dir, index| File.utime(Time.at(1_600_000_300 + index), Time.at(1_600_000_300 + index), dir) }
|
|
63
65
|
File.write(File.join(@home, '.pwn', 'learning.jsonl'), '{broken')
|
|
64
|
-
|
|
65
|
-
expect(
|
|
66
|
+
described_class.capture(path: @source)
|
|
67
|
+
expect(File).not_to exist(generations.first)
|
|
68
|
+
expect(copies[1..].all? { |path| File.file?(path) }).to be(true)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'keeps a generation named inside unreadable reference text' do
|
|
72
|
+
copies = 7.times.map { described_class.capture(path: @source) }
|
|
73
|
+
generations = copies.map { |path| File.dirname(path, 2) }
|
|
74
|
+
generations.each_with_index { |dir, index| File.utime(Time.at(1_600_000_400 + index), Time.at(1_600_000_400 + index), dir) }
|
|
75
|
+
File.write(File.join(@home, '.pwn', 'learning.jsonl'), "{not-json #{copies[1]}")
|
|
76
|
+
described_class.capture(path: @source)
|
|
77
|
+
expect(File).to exist(copies[1])
|
|
78
|
+
expect(File).not_to exist(generations.first)
|
|
66
79
|
end
|
|
67
80
|
|
|
68
81
|
it 'uses one generation for nested producers and preserves failed result recovery' do
|
|
@@ -224,6 +224,15 @@ describe PWN::Plugins::AISandbox do
|
|
|
224
224
|
end
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
+
it 'uses aarch64 directory open bits instead of the x86_64 O_DIRECT bit' do
|
|
228
|
+
aarch64 = described_class.send(:directory_open_flags, platform: 'aarch64-linux')
|
|
229
|
+
x86_64 = described_class.send(:directory_open_flags, platform: 'x86_64-linux')
|
|
230
|
+
expect(aarch64.anybits?(1 << 14)).to be(true)
|
|
231
|
+
expect(aarch64.anybits?(1 << 16)).to be(false)
|
|
232
|
+
expect(x86_64.anybits?(1 << 16)).to be(true)
|
|
233
|
+
expect(x86_64.anybits?(1 << 14)).to be(false)
|
|
234
|
+
end
|
|
235
|
+
|
|
227
236
|
it 'pins controller directories across pathname replacement and rejects source ancestry' do
|
|
228
237
|
Dir.mktmpdir('pwn-control-fd') do |root|
|
|
229
238
|
source = File.join(root, 'source')
|
|
@@ -530,7 +530,9 @@ describe 'pwn-ai curses launch' do # rubocop:disable Metrics/BlockLength -- publ
|
|
|
530
530
|
PWN::Plugins::REPL::AIConsole.run(pry: @pry, input: input, output: output, curses: screen, getch: reader)
|
|
531
531
|
end
|
|
532
532
|
rescue expired
|
|
533
|
-
|
|
533
|
+
timeline = @console&.instance_variable_get(:@timeline).to_a.last(8).map { |type, text| [type, text.to_s[0, 400]] }
|
|
534
|
+
paint = @paint.last(120).join
|
|
535
|
+
raise expired, "execution expired phase=#{@launch_phase.inspect} session=#{@pry.config.pwn_ai_session_id} timeline=#{timeline.inspect} paint=#{paint[-240, 240] || paint}"
|
|
534
536
|
end
|
|
535
537
|
expect([$stdin, $stdout]).to eq(previous.take(2))
|
|
536
538
|
expect(PWN::Plugins::Log.raw_stderr).to equal(previous[2])
|
|
@@ -2678,34 +2680,51 @@ describe 'pwn-ai curses launch' do # rubocop:disable Metrics/BlockLength -- publ
|
|
|
2678
2680
|
PWN::Sessions.append(session_id: sid, role: 'user', content: 'Previous fixture question')
|
|
2679
2681
|
PWN::Sessions.append(session_id: sid, role: 'assistant', content: 'Previous fixture answer')
|
|
2680
2682
|
allow(PWN::Plugins::REPL).to receive(:persist_ai_selection).and_return(false)
|
|
2683
|
+
seen = File.join(@tmp, 'curses-provider-call.json')
|
|
2684
|
+
recorded = false
|
|
2681
2685
|
allow(PWN::AI::OpenAI).to receive(:chat_with_tools) do |opts|
|
|
2682
|
-
|
|
2683
|
-
|
|
2686
|
+
unless recorded
|
|
2687
|
+
recorded = true
|
|
2688
|
+
messages = Array(opts[:messages]).map { |row| { role: row[:role] || row['role'], content: (row[:content] || row['content']).to_s } }
|
|
2689
|
+
File.write(seen, JSON.generate(model: PWN::Env.dig(:ai, :openai, :model), call_model: opts[:model], messages: messages))
|
|
2690
|
+
end
|
|
2684
2691
|
{ choices: [{ message: { role: 'assistant', content: 'Selected route.', tool_calls: [] } }] }
|
|
2685
2692
|
end
|
|
2693
|
+
allow(PWN::AI::Router).to receive(:summarize).and_return('{"title":"Resumed console","summary":"Fixture summary."}')
|
|
2686
2694
|
keys = "/model openai console-fixture\n".chars
|
|
2687
2695
|
phase = :model
|
|
2688
2696
|
launch(keys) do
|
|
2689
2697
|
@launch_phase = phase
|
|
2690
2698
|
idle = @console && !@console.send(:busy?)
|
|
2699
|
+
prompt = @console&.instance_variable_get(:@model_prompt)
|
|
2691
2700
|
case phase
|
|
2692
2701
|
when :model
|
|
2693
|
-
if idle && @paint.join.include?('model=console-fixture')
|
|
2702
|
+
if idle && !prompt && @paint.join.include?('model=console-fixture') && PWN::Env.dig(:ai, :openai, :model) == 'console-fixture'
|
|
2694
2703
|
phase = :resume
|
|
2695
2704
|
keys.concat("/sessions resume resumed console\n".chars)
|
|
2696
2705
|
end
|
|
2697
2706
|
nil
|
|
2698
2707
|
when :resume
|
|
2699
|
-
if idle && @pry.config.pwn_ai_session_id == sid
|
|
2708
|
+
if idle && !prompt && @pry.config.pwn_ai_session_id == sid && PWN::Env.dig(:ai, :openai, :model) == 'console-fixture'
|
|
2700
2709
|
phase = :ask
|
|
2701
2710
|
keys.concat("what color is a lemon?\n".chars)
|
|
2702
2711
|
end
|
|
2703
2712
|
nil
|
|
2704
2713
|
else
|
|
2705
|
-
"\u0004" if
|
|
2714
|
+
"\u0004" if idle
|
|
2706
2715
|
end
|
|
2707
2716
|
end
|
|
2708
2717
|
expect(@pry.config.pwn_ai_session_id).to eq(sid)
|
|
2718
|
+
expect(File).to exist(seen), "Mission finished without calling the provider: #{@console.instance_variable_get(:@timeline).inspect}"
|
|
2719
|
+
observed = JSON.parse(File.read(seen), symbolize_names: true)
|
|
2720
|
+
expect(observed[:model]).to eq('console-fixture')
|
|
2721
|
+
expect(observed[:call_model]).to eq('console-fixture')
|
|
2722
|
+
expect(observed[:messages]).to include(
|
|
2723
|
+
hash_including(role: 'user', content: 'Previous fixture question'),
|
|
2724
|
+
hash_including(role: 'assistant', content: 'Previous fixture answer'),
|
|
2725
|
+
hash_including(role: 'user', content: 'what color is a lemon?')
|
|
2726
|
+
)
|
|
2727
|
+
expect(@paint.join).to include('Selected route.')
|
|
2709
2728
|
expect(PWN::Sessions.load(session_id: sid).map { |row| row[:content] }.join).to include('Selected route.')
|
|
2710
2729
|
end
|
|
2711
2730
|
|
|
@@ -27,6 +27,37 @@ describe 'regex-ReAct mission containment' do
|
|
|
27
27
|
Pry.config.hooks.get_hook(:after_read, :pwn_ai_hook).call(request, pry)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def wait_for_descendant_pid(marker)
|
|
31
|
+
Timeout.timeout(10) do
|
|
32
|
+
loop do
|
|
33
|
+
text = File.read(marker) if File.file?(marker)
|
|
34
|
+
pid = text.to_s[/^NSpid:[ \t]+([1-9]\d*)(?:[ \t]+\d+)+\n/, 1]
|
|
35
|
+
return pid.to_i if pid
|
|
36
|
+
|
|
37
|
+
sleep 0.01
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'waits for the descendant PID contents rather than an empty readiness file' do
|
|
43
|
+
marker = File.join(@tmp, 'partial-ready')
|
|
44
|
+
File.write(marker, '')
|
|
45
|
+
read_empty = Queue.new
|
|
46
|
+
writer = Thread.new do
|
|
47
|
+
read_empty.pop
|
|
48
|
+
File.write(marker, "NSpid:\t12345\t1\n")
|
|
49
|
+
end
|
|
50
|
+
allow(File).to receive(:read).and_call_original
|
|
51
|
+
allow(File).to receive(:read).with(marker).and_wrap_original do |original, path|
|
|
52
|
+
text = original.call(path)
|
|
53
|
+
read_empty << true if text.empty?
|
|
54
|
+
text
|
|
55
|
+
end
|
|
56
|
+
expect(wait_for_descendant_pid(marker)).to eq(12_345)
|
|
57
|
+
ensure
|
|
58
|
+
writer&.kill&.join
|
|
59
|
+
end
|
|
60
|
+
|
|
30
61
|
it 'fails closed before calling a provider when mission containment is unavailable' do
|
|
31
62
|
allow(PWN::Plugins::AISandbox::MissionProcess).to receive(:new).and_raise(PWN::Plugins::AISandbox::NotStarted, 'enable user/PID namespaces')
|
|
32
63
|
expect(PWN::AI::Ollama).not_to receive(:chat)
|
|
@@ -137,8 +168,7 @@ describe 'regex-ReAct mission containment' do
|
|
|
137
168
|
nil
|
|
138
169
|
end
|
|
139
170
|
marker = File.join(@tmp, '.pwn', 'workspaces', 'runtime', 'pty-ready')
|
|
140
|
-
|
|
141
|
-
host_pid = File.read(marker)[/^NSpid:\s+(\d+)/, 1].to_i
|
|
171
|
+
host_pid = wait_for_descendant_pid(marker)
|
|
142
172
|
writer.write("\x03")
|
|
143
173
|
Timeout.timeout(10) { sleep 0.01 until output.include?('CANCELLED READY') }
|
|
144
174
|
expect { Process.kill(0, host_pid) }.to raise_error(Errno::ESRCH)
|
|
@@ -179,8 +209,7 @@ describe 'regex-ReAct mission containment' do
|
|
|
179
209
|
rescue Interrupt
|
|
180
210
|
:cancelled
|
|
181
211
|
end
|
|
182
|
-
|
|
183
|
-
host_pid = File.read(marker)[/^NSpid:\s+(\d+)/, 1].to_i
|
|
212
|
+
host_pid = wait_for_descendant_pid(marker)
|
|
184
213
|
worker.raise(Interrupt)
|
|
185
214
|
expect(Timeout.timeout(10) { worker.value }).to eq(:cancelled)
|
|
186
215
|
expect(repl).to have_received(:ready_tty!)
|
data/spec/support/sandbox.rb
CHANGED
|
@@ -47,7 +47,9 @@ RSpec.shared_context 'pwn tmp sandbox' do
|
|
|
47
47
|
'PWN::AI::Agent::Policy::TRAJECTORY_FILE' => 'policy_traj.jsonl',
|
|
48
48
|
'PWN::AI::Agent::Extrospection::EXTRO_FILE' => 'extrospection.json',
|
|
49
49
|
'PWN::AI::Agent::Swarm::AGENTS_FILE' => 'agents.yml',
|
|
50
|
-
'PWN::AI::Agent::Swarm::SWARM_ROOT' => 'swarm'
|
|
50
|
+
'PWN::AI::Agent::Swarm::SWARM_ROOT' => 'swarm',
|
|
51
|
+
'PWN::AI::Agent::Mission::ROOT' => 'missions',
|
|
52
|
+
'PWN::AI::Agent::OpenGoal::GOAL_FILE' => 'open_goal.json'
|
|
51
53
|
}.each do |const, rel|
|
|
52
54
|
owner = const.split('::')[0..-2].join('::')
|
|
53
55
|
stub_const(const, File.join(@tmp, rel)) if Object.const_defined?(owner)
|
data/third_party/pwn_rdoc.jsonl
CHANGED
|
@@ -1898,6 +1898,7 @@
|
|
|
1898
1898
|
{"messages":[{"role":"user","content":"PWN::Backups.active? Usage"},{"role":"assistant","content":"`PWN::Backups.active?`: Supported Method Parameters\n\nPWN::Backups.active?\n"}]}
|
|
1899
1899
|
{"messages":[{"role":"user","content":"PWN::Backups.authors Usage"},{"role":"assistant","content":"`PWN::Backups.authors`: Author(s)\n\n0day Inc. <support@0dayinc.com>\n"}]}
|
|
1900
1900
|
{"messages":[{"role":"user","content":"PWN::Backups.capture Usage"},{"role":"assistant","content":"`PWN::Backups.capture`: Supported Method Parameters\n\nPWN::Backups.capture(path: ‘/path/to/source’, label: ‘learning’)\n"}]}
|
|
1901
|
+
{"messages":[{"role":"user","content":"PWN::Backups.collect_references Usage"},{"role":"assistant","content":"`PWN::Backups.collect_references`: "}]}
|
|
1901
1902
|
{"messages":[{"role":"user","content":"PWN::Backups.configure Usage"},{"role":"assistant","content":"`PWN::Backups.configure`: Supported Method Parameters\n\nPWN::Backups.configure(root: nil)\n"}]}
|
|
1902
1903
|
{"messages":[{"role":"user","content":"PWN::Backups.directory Usage"},{"role":"assistant","content":"`PWN::Backups.directory`: Supported Method Parameters\n\nPWN::Backups.directory(label: ‘maintenance’) Caller must hold transaction through the final source mutation and ledger.\n"}]}
|
|
1903
1904
|
{"messages":[{"role":"user","content":"PWN::Backups.expirable_name? Usage"},{"role":"assistant","content":"`PWN::Backups.expirable_name?`: "}]}
|
|
@@ -1905,11 +1906,13 @@
|
|
|
1905
1906
|
{"messages":[{"role":"user","content":"PWN::Backups.legacy_inventory Usage"},{"role":"assistant","content":"`PWN::Backups.legacy_inventory`: "}]}
|
|
1906
1907
|
{"messages":[{"role":"user","content":"PWN::Backups.legacy_unreferenced Usage"},{"role":"assistant","content":"`PWN::Backups.legacy_unreferenced`: "}]}
|
|
1907
1908
|
{"messages":[{"role":"user","content":"PWN::Backups.owned_directory? Usage"},{"role":"assistant","content":"`PWN::Backups.owned_directory?`: "}]}
|
|
1909
|
+
{"messages":[{"role":"user","content":"PWN::Backups.pin_raw_paths Usage"},{"role":"assistant","content":"`PWN::Backups.pin_raw_paths`: "}]}
|
|
1908
1910
|
{"messages":[{"role":"user","content":"PWN::Backups.reconcile Usage"},{"role":"assistant","content":"`PWN::Backups.reconcile`: Supported Method Parameters\n\nPWN::Backups.reconcile(generation: ‘name’, expected_sha256: ‘digest’, confirmed: true)\n"}]}
|
|
1909
1911
|
{"messages":[{"role":"user","content":"PWN::Backups.reference_pins Usage"},{"role":"assistant","content":"`PWN::Backups.reference_pins`: "}]}
|
|
1910
1912
|
{"messages":[{"role":"user","content":"PWN::Backups.relocate_legacy Usage"},{"role":"assistant","content":"`PWN::Backups.relocate_legacy`: Supported Method Parameters\n\nPWN::Backups.relocate_legacy(paths: [], dry_run: true, writers_stopped: false)\n"}]}
|
|
1911
1913
|
{"messages":[{"role":"user","content":"PWN::Backups.safe_directory Usage"},{"role":"assistant","content":"`PWN::Backups.safe_directory`: "}]}
|
|
1912
1914
|
{"messages":[{"role":"user","content":"PWN::Backups.transaction Usage"},{"role":"assistant","content":"`PWN::Backups.transaction`: Supported Method Parameters\n\nPWN::Backups.transaction(root: nil) { … }\n"}]}
|
|
1915
|
+
{"messages":[{"role":"user","content":"PWN::Backups.walk_reference Usage"},{"role":"assistant","content":"`PWN::Backups.walk_reference`: "}]}
|
|
1913
1916
|
{"messages":[{"role":"user","content":"PWN::Backups.write_state Usage"},{"role":"assistant","content":"`PWN::Backups.write_state`: "}]}
|
|
1914
1917
|
{"messages":[{"role":"user","content":"PWN::Banner.authors Usage"},{"role":"assistant","content":"`PWN::Banner.authors`: Author(s)\n\n0day Inc. <support@0dayinc.com>\n"}]}
|
|
1915
1918
|
{"messages":[{"role":"user","content":"PWN::Banner.get Usage"},{"role":"assistant","content":"`PWN::Banner.get`: Supported Method Parameters\n\nPWN::Banner.get(\n\nindex: 'optional - defaults to random banner index'\n\n)\n"}]}
|
|
@@ -2465,6 +2468,7 @@
|
|
|
2465
2468
|
{"messages":[{"role":"user","content":"PWN::Plugins::AISandbox.collect_worker Usage"},{"role":"assistant","content":"`PWN::Plugins::AISandbox.collect_worker`: "}]}
|
|
2466
2469
|
{"messages":[{"role":"user","content":"PWN::Plugins::AISandbox.control_directory Usage"},{"role":"assistant","content":"`PWN::Plugins::AISandbox.control_directory`: "}]}
|
|
2467
2470
|
{"messages":[{"role":"user","content":"PWN::Plugins::AISandbox.controller_state_roots Usage"},{"role":"assistant","content":"`PWN::Plugins::AISandbox.controller_state_roots`: "}]}
|
|
2471
|
+
{"messages":[{"role":"user","content":"PWN::Plugins::AISandbox.directory_open_flags Usage"},{"role":"assistant","content":"`PWN::Plugins::AISandbox.directory_open_flags`: "}]}
|
|
2468
2472
|
{"messages":[{"role":"user","content":"PWN::Plugins::AISandbox.env_mode Usage"},{"role":"assistant","content":"`PWN::Plugins::AISandbox.env_mode`: "}]}
|
|
2469
2473
|
{"messages":[{"role":"user","content":"PWN::Plugins::AISandbox.eval_ruby Usage"},{"role":"assistant","content":"`PWN::Plugins::AISandbox.eval_ruby`: "}]}
|
|
2470
2474
|
{"messages":[{"role":"user","content":"PWN::Plugins::AISandbox.exec Usage"},{"role":"assistant","content":"`PWN::Plugins::AISandbox.exec`: "}]}
|
|
@@ -4439,6 +4443,7 @@
|
|
|
4439
4443
|
{"messages":[{"role":"user","content":"PWN::Plugins::YubiKey::PIV::Session.info Usage"},{"role":"assistant","content":"`PWN::Plugins::YubiKey::PIV::Session.info`: "}]}
|
|
4440
4444
|
{"messages":[{"role":"user","content":"PWN::Plugins::YubiKey::PIV::Session.metadata Usage"},{"role":"assistant","content":"`PWN::Plugins::YubiKey::PIV::Session.metadata`: "}]}
|
|
4441
4445
|
{"messages":[{"role":"user","content":"PWN::Plugins::YubiKey::PIV::Session.move_key Usage"},{"role":"assistant","content":"`PWN::Plugins::YubiKey::PIV::Session.move_key`: "}]}
|
|
4446
|
+
{"messages":[{"role":"user","content":"PWN::Plugins::YubiKey::PIV::Session.pkcs1_unpad Usage"},{"role":"assistant","content":"`PWN::Plugins::YubiKey::PIV::Session.pkcs1_unpad`: "}]}
|
|
4442
4447
|
{"messages":[{"role":"user","content":"PWN::Plugins::YubiKey::PIV::Session.read_certificate Usage"},{"role":"assistant","content":"`PWN::Plugins::YubiKey::PIV::Session.read_certificate`: "}]}
|
|
4443
4448
|
{"messages":[{"role":"user","content":"PWN::Plugins::YubiKey::PIV::Session.read_object Usage"},{"role":"assistant","content":"`PWN::Plugins::YubiKey::PIV::Session.read_object`: "}]}
|
|
4444
4449
|
{"messages":[{"role":"user","content":"PWN::Plugins::YubiKey::PIV::Session.reset Usage"},{"role":"assistant","content":"`PWN::Plugins::YubiKey::PIV::Session.reset`: "}]}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pwn
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.795
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 0day Inc.
|
|
@@ -141,14 +141,14 @@ dependencies:
|
|
|
141
141
|
requirements:
|
|
142
142
|
- - ">="
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: 4.0.
|
|
144
|
+
version: 4.0.24
|
|
145
145
|
type: :development
|
|
146
146
|
prerelease: false
|
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements:
|
|
149
149
|
- - ">="
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: 4.0.
|
|
151
|
+
version: 4.0.24
|
|
152
152
|
- !ruby/object:Gem::Dependency
|
|
153
153
|
name: bundler-audit
|
|
154
154
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -169,14 +169,14 @@ dependencies:
|
|
|
169
169
|
requirements:
|
|
170
170
|
- - '='
|
|
171
171
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: 3.
|
|
172
|
+
version: 3.6.0
|
|
173
173
|
type: :runtime
|
|
174
174
|
prerelease: false
|
|
175
175
|
version_requirements: !ruby/object:Gem::Requirement
|
|
176
176
|
requirements:
|
|
177
177
|
- - '='
|
|
178
178
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: 3.
|
|
179
|
+
version: 3.6.0
|
|
180
180
|
- !ruby/object:Gem::Dependency
|
|
181
181
|
name: colorize
|
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -1037,14 +1037,14 @@ dependencies:
|
|
|
1037
1037
|
requirements:
|
|
1038
1038
|
- - '='
|
|
1039
1039
|
- !ruby/object:Gem::Version
|
|
1040
|
-
version: 2.
|
|
1040
|
+
version: 2.18.1
|
|
1041
1041
|
type: :runtime
|
|
1042
1042
|
prerelease: false
|
|
1043
1043
|
version_requirements: !ruby/object:Gem::Requirement
|
|
1044
1044
|
requirements:
|
|
1045
1045
|
- - '='
|
|
1046
1046
|
- !ruby/object:Gem::Version
|
|
1047
|
-
version: 2.
|
|
1047
|
+
version: 2.18.1
|
|
1048
1048
|
- !ruby/object:Gem::Dependency
|
|
1049
1049
|
name: selenium-devtools
|
|
1050
1050
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -6714,6 +6714,7 @@ files:
|
|
|
6714
6714
|
- spec/integration/reports_spec.rb
|
|
6715
6715
|
- spec/integration/result_condition_spec.rb
|
|
6716
6716
|
- spec/integration/sast_functional_spec.rb
|
|
6717
|
+
- spec/integration/spec_sandbox_isolation_spec.rb
|
|
6717
6718
|
- spec/integration/tool_registry_spec.rb
|
|
6718
6719
|
- spec/integration/web_cache_deception_yubikey_spec.rb
|
|
6719
6720
|
- spec/lib/pwn/ai/agent/assembly_spec.rb
|
|
@@ -7405,7 +7406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
7405
7406
|
- !ruby/object:Gem::Version
|
|
7406
7407
|
version: '0'
|
|
7407
7408
|
requirements: []
|
|
7408
|
-
rubygems_version: 4.0.
|
|
7409
|
+
rubygems_version: 4.0.24
|
|
7409
7410
|
specification_version: 4
|
|
7410
7411
|
summary: Automated Security Testing for CI/CD Pipelines & Beyond
|
|
7411
7412
|
test_files: []
|