scabox_sdk 1.0.2 → 1.0.3
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/scabox_sdk/runner.rb +24 -48
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06c90e64a4fb078488636cc2daabff10d0303b6aa9ef6c6d70fd6f2864bf8d61
|
4
|
+
data.tar.gz: f11bc69f122571c912e96ddd79d02589e9bccde37e9c4eb5bc6a91ea329872f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 118cad2f1e2482cacb03c833d9b67fd4c6a3d2111677bae9735aaddc55537f08176f3a24c470d28f07bbed41bb8689953a8ffd6dc1342f7c8f8cd49c64996a59
|
7
|
+
data.tar.gz: 4633a897857b19823af3bba6e4e8dcebb457302107feb9ec9d073af607f8476546756c53948d954dbd204fd8d84e3994e22135cb113904267696ac9828f00d54
|
data/lib/scabox_sdk/runner.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'open3'
|
2
1
|
require 'timeout'
|
2
|
+
require 'open3'
|
3
3
|
|
4
4
|
module ScaBox
|
5
5
|
module Runner
|
@@ -20,55 +20,31 @@ module ScaBox
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
=
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
=end
|
35
|
-
|
36
|
-
def run_cmd_with_timeout(cmd)
|
37
|
-
out_reader = ''
|
38
|
-
err_reader = ''
|
39
|
-
Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thr|
|
40
|
-
# https://stackoverflow.com/questions/8952043/how-to-fix-hanging-popen3-in-ruby
|
41
|
-
stdin.close_write
|
42
|
-
output, pid = [], wait_thr.pid
|
43
|
-
begin
|
44
|
-
Timeout.timeout(@timeout) do
|
45
|
-
begin
|
46
|
-
err_reader = Thread.new { stderr.read }
|
47
|
-
rescue IOError
|
48
|
-
end
|
49
|
-
|
50
|
-
out_reader = stdout.read
|
51
|
-
|
52
|
-
#output = [stdout.read, stderr.read]
|
53
|
-
Process.wait(pid)
|
54
|
-
end
|
55
|
-
rescue Errno::ECHILD
|
56
|
-
rescue Timeout::Error
|
57
|
-
print_error('Timed out - Skipping...')
|
58
|
-
Process.kill('HUP', pid)
|
59
|
-
exit 1
|
23
|
+
def run_cmd_with_timeout(cmd, timeout=1800, output_file=@tempfile)
|
24
|
+
begin
|
25
|
+
# Start the process in a separate thread
|
26
|
+
thread = Thread.new { system(*cmd, out: output_file) }
|
27
|
+
|
28
|
+
# Timeout block to limit execution time
|
29
|
+
Timeout.timeout(timeout) do
|
30
|
+
# Wait for the process to finish
|
31
|
+
thread.join
|
60
32
|
end
|
61
|
-
|
33
|
+
|
34
|
+
# Check if the process has finished successfully
|
35
|
+
if thread.value
|
36
|
+
return true
|
37
|
+
else
|
38
|
+
# Command execution failed
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
rescue Timeout::Error
|
42
|
+
# Handle timeout
|
43
|
+
print_error('Timed out - Skipping...')
|
44
|
+
# Terminate the process
|
45
|
+
thread.kill
|
46
|
+
return false
|
62
47
|
end
|
63
48
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
49
|
end
|
69
50
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scabox_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rd
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|
@@ -30,14 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.7.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.7.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 13.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 13.1.0
|
41
55
|
description: SDK to construct SCA scanners
|
42
56
|
email: rd@convisoappsec.com
|
43
57
|
executables: []
|
@@ -62,7 +76,7 @@ homepage: ''
|
|
62
76
|
licenses:
|
63
77
|
- MIT
|
64
78
|
metadata: {}
|
65
|
-
post_install_message:
|
79
|
+
post_install_message:
|
66
80
|
rdoc_options: []
|
67
81
|
require_paths:
|
68
82
|
- lib
|
@@ -77,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
91
|
- !ruby/object:Gem::Version
|
78
92
|
version: '0'
|
79
93
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
-
signing_key:
|
94
|
+
rubygems_version: 3.5.6
|
95
|
+
signing_key:
|
82
96
|
specification_version: 4
|
83
97
|
summary: SCABox SDK
|
84
98
|
test_files: []
|