grim-reaper 1.0.29

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.
@@ -0,0 +1,172 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ module GrimReaper
6
+ # Python module wrapper for py_grim operations
7
+ class PythonModule
8
+ attr_reader :config, :grim_root
9
+
10
+ def initialize(config, grim_root)
11
+ @config = config
12
+ @grim_root = grim_root
13
+ end
14
+
15
+ def execute(command, *args)
16
+ case command
17
+ when "health"
18
+ execute_health
19
+ when "status"
20
+ execute_status
21
+ when "backup"
22
+ execute_backup(*args)
23
+ when "monitor"
24
+ execute_monitor(*args)
25
+ when "security"
26
+ execute_security(*args)
27
+ when "ai"
28
+ execute_ai(*args)
29
+ else
30
+ execute_generic(command, *args)
31
+ end
32
+ end
33
+
34
+ def status
35
+ {
36
+ status: "ready",
37
+ module: "python",
38
+ available_commands: %w[health status backup monitor security ai],
39
+ grim_root: @grim_root
40
+ }
41
+ end
42
+
43
+ private
44
+
45
+ def execute_health
46
+ script_path = File.join(@grim_root, "scythe", "scythe.py")
47
+
48
+ if File.exist?(script_path)
49
+ stdout, stderr, status = Open3.capture3("python3", script_path, "health", chdir: @grim_root)
50
+ {
51
+ command: "health",
52
+ stdout: stdout,
53
+ stderr: stderr,
54
+ success: status.success?,
55
+ module: "python"
56
+ }
57
+ else
58
+ { error: "Scythe script not found", module: "python" }
59
+ end
60
+ end
61
+
62
+ def execute_status
63
+ script_path = File.join(@grim_root, "scythe", "scythe.py")
64
+
65
+ if File.exist?(script_path)
66
+ stdout, stderr, status = Open3.capture3("python3", script_path, "status", chdir: @grim_root)
67
+ {
68
+ command: "status",
69
+ stdout: stdout,
70
+ stderr: stderr,
71
+ success: status.success?,
72
+ module: "python"
73
+ }
74
+ else
75
+ { error: "Scythe script not found", module: "python" }
76
+ end
77
+ end
78
+
79
+ def execute_backup(*args)
80
+ path = args.first || "/"
81
+ script_path = File.join(@grim_root, "scythe", "scythe.py")
82
+
83
+ if File.exist?(script_path)
84
+ stdout, stderr, status = Open3.capture3("python3", script_path, "backup", path, chdir: @grim_root)
85
+ {
86
+ command: "backup",
87
+ path: path,
88
+ stdout: stdout,
89
+ stderr: stderr,
90
+ success: status.success?,
91
+ module: "python"
92
+ }
93
+ else
94
+ { error: "Scythe script not found", module: "python" }
95
+ end
96
+ end
97
+
98
+ def execute_monitor(*args)
99
+ path = args.first || "/"
100
+ script_path = File.join(@grim_root, "py_grim", "grim_web", "app.py")
101
+
102
+ if File.exist?(script_path)
103
+ # Start monitoring in background
104
+ pid = spawn("python3", script_path, chdir: @grim_root)
105
+ Process.detach(pid)
106
+ {
107
+ command: "monitor",
108
+ path: path,
109
+ pid: pid,
110
+ success: true,
111
+ module: "python"
112
+ }
113
+ else
114
+ { error: "Python web app not found", module: "python" }
115
+ end
116
+ end
117
+
118
+ def execute_security(*args)
119
+ script_path = File.join(@grim_root, "scythe", "scythe.py")
120
+
121
+ if File.exist?(script_path)
122
+ stdout, stderr, status = Open3.capture3("python3", script_path, "security", *args, chdir: @grim_root)
123
+ {
124
+ command: "security",
125
+ args: args,
126
+ stdout: stdout,
127
+ stderr: stderr,
128
+ success: status.success?,
129
+ module: "python"
130
+ }
131
+ else
132
+ { error: "Scythe script not found", module: "python" }
133
+ end
134
+ end
135
+
136
+ def execute_ai(*args)
137
+ script_path = File.join(@grim_root, "py_grim", "ai_decision_engine.py")
138
+
139
+ if File.exist?(script_path)
140
+ stdout, stderr, status = Open3.capture3("python3", script_path, *args, chdir: @grim_root)
141
+ {
142
+ command: "ai",
143
+ args: args,
144
+ stdout: stdout,
145
+ stderr: stderr,
146
+ success: status.success?,
147
+ module: "python"
148
+ }
149
+ else
150
+ { error: "AI script not found", module: "python" }
151
+ end
152
+ end
153
+
154
+ def execute_generic(command, *args)
155
+ script_path = File.join(@grim_root, "py_grim", "#{command}.py")
156
+
157
+ if File.exist?(script_path)
158
+ stdout, stderr, status = Open3.capture3("python3", script_path, *args, chdir: @grim_root)
159
+ {
160
+ command: command,
161
+ args: args,
162
+ stdout: stdout,
163
+ stderr: stderr,
164
+ success: status.success?,
165
+ module: "python"
166
+ }
167
+ else
168
+ { error: "Python script not found: #{command}.py", module: "python" }
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ module GrimReaper
6
+ # Security module wrapper for scythe operations
7
+ class SecurityModule
8
+ attr_reader :config, :grim_root
9
+
10
+ def initialize(config, grim_root)
11
+ @config = config
12
+ @grim_root = grim_root
13
+ end
14
+
15
+ def execute(command, *args)
16
+ case command
17
+ when "audit"
18
+ execute_audit
19
+ when "scan"
20
+ execute_scan(*args)
21
+ when "encrypt"
22
+ execute_encrypt(*args)
23
+ when "decrypt"
24
+ execute_decrypt(*args)
25
+ when "quarantine"
26
+ execute_quarantine(*args)
27
+ when "threat"
28
+ execute_threat(*args)
29
+ else
30
+ execute_generic(command, *args)
31
+ end
32
+ end
33
+
34
+ def status
35
+ {
36
+ status: "ready",
37
+ module: "security",
38
+ available_commands: %w[audit scan encrypt decrypt quarantine threat],
39
+ grim_root: @grim_root
40
+ }
41
+ end
42
+
43
+ private
44
+
45
+ def execute_audit
46
+ script_path = File.join(@grim_root, "sh_grim", "security.sh")
47
+
48
+ if File.exist?(script_path)
49
+ stdout, stderr, status = Open3.capture3(script_path, "audit", chdir: @grim_root)
50
+ {
51
+ command: "audit",
52
+ stdout: stdout,
53
+ stderr: stderr,
54
+ success: status.success?,
55
+ module: "security"
56
+ }
57
+ else
58
+ { error: "Security script not found", module: "security" }
59
+ end
60
+ end
61
+
62
+ def execute_scan(*args)
63
+ path = args.first || "/"
64
+ script_path = File.join(@grim_root, "sh_grim", "security.sh")
65
+
66
+ if File.exist?(script_path)
67
+ stdout, stderr, status = Open3.capture3(script_path, "scan-vulnerabilities", path, chdir: @grim_root)
68
+ {
69
+ command: "scan",
70
+ path: path,
71
+ stdout: stdout,
72
+ stderr: stderr,
73
+ success: status.success?,
74
+ module: "security"
75
+ }
76
+ else
77
+ { error: "Security script not found", module: "security" }
78
+ end
79
+ end
80
+
81
+ def execute_encrypt(*args)
82
+ file = args.first
83
+ return { error: "File path required", module: "security" } unless file
84
+
85
+ script_path = File.join(@grim_root, "sh_grim", "security.sh")
86
+
87
+ if File.exist?(script_path)
88
+ stdout, stderr, status = Open3.capture3(script_path, "encrypt", file, chdir: @grim_root)
89
+ {
90
+ command: "encrypt",
91
+ file: file,
92
+ stdout: stdout,
93
+ stderr: stderr,
94
+ success: status.success?,
95
+ module: "security"
96
+ }
97
+ else
98
+ { error: "Security script not found", module: "security" }
99
+ end
100
+ end
101
+
102
+ def execute_decrypt(*args)
103
+ file = args.first
104
+ return { error: "File path required", module: "security" } unless file
105
+
106
+ script_path = File.join(@grim_root, "sh_grim", "security.sh")
107
+
108
+ if File.exist?(script_path)
109
+ stdout, stderr, status = Open3.capture3(script_path, "decrypt", file, chdir: @grim_root)
110
+ {
111
+ command: "decrypt",
112
+ file: file,
113
+ stdout: stdout,
114
+ stderr: stderr,
115
+ success: status.success?,
116
+ module: "security"
117
+ }
118
+ else
119
+ { error: "Security script not found", module: "security" }
120
+ end
121
+ end
122
+
123
+ def execute_quarantine(*args)
124
+ file = args.first
125
+ return { error: "File path required", module: "security" } unless file
126
+
127
+ script_path = File.join(@grim_root, "sh_grim", "quarantine.sh")
128
+
129
+ if File.exist?(script_path)
130
+ stdout, stderr, status = Open3.capture3(script_path, "isolate", file, chdir: @grim_root)
131
+ {
132
+ command: "quarantine",
133
+ file: file,
134
+ stdout: stdout,
135
+ stderr: stderr,
136
+ success: status.success?,
137
+ module: "security"
138
+ }
139
+ else
140
+ { error: "Quarantine script not found", module: "security" }
141
+ end
142
+ end
143
+
144
+ def execute_threat(*args)
145
+ script_path = File.join(@grim_root, "scythe", "scythe.py")
146
+
147
+ if File.exist?(script_path)
148
+ stdout, stderr, status = Open3.capture3("python3", script_path, "threat", *args, chdir: @grim_root)
149
+ {
150
+ command: "threat",
151
+ args: args,
152
+ stdout: stdout,
153
+ stderr: stderr,
154
+ success: status.success?,
155
+ module: "security"
156
+ }
157
+ else
158
+ { error: "Scythe script not found", module: "security" }
159
+ end
160
+ end
161
+
162
+ def execute_generic(command, *args)
163
+ script_path = File.join(@grim_root, "sh_grim", "#{command}.sh")
164
+
165
+ if File.exist?(script_path)
166
+ stdout, stderr, status = Open3.capture3(script_path, *args, chdir: @grim_root)
167
+ {
168
+ command: command,
169
+ args: args,
170
+ stdout: stdout,
171
+ stderr: stderr,
172
+ success: status.success?,
173
+ module: "security"
174
+ }
175
+ else
176
+ { error: "Security script not found: #{command}.sh", module: "security" }
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ module GrimReaper
6
+ # Shell module wrapper for sh_grim operations
7
+ class ShellModule
8
+ attr_reader :config, :grim_root
9
+
10
+ def initialize(config, grim_root)
11
+ @config = config
12
+ @grim_root = grim_root
13
+ end
14
+
15
+ def execute(command, *args)
16
+ case command
17
+ when "backup"
18
+ execute_backup(*args)
19
+ when "restore"
20
+ execute_restore(*args)
21
+ when "monitor"
22
+ execute_monitor(*args)
23
+ when "scan"
24
+ execute_scan(*args)
25
+ when "security"
26
+ execute_security(*args)
27
+ else
28
+ execute_generic(command, *args)
29
+ end
30
+ end
31
+
32
+ def status
33
+ {
34
+ status: "ready",
35
+ module: "shell",
36
+ available_commands: %w[backup restore monitor scan security],
37
+ grim_root: @grim_root
38
+ }
39
+ end
40
+
41
+ private
42
+
43
+ def execute_backup(*args)
44
+ path = args.first || "/"
45
+ script_path = File.join(@grim_root, "sh_grim", "backup.sh")
46
+
47
+ if File.exist?(script_path)
48
+ stdout, stderr, status = Open3.capture3(script_path, "create", path, chdir: @grim_root)
49
+ {
50
+ command: "backup",
51
+ path: path,
52
+ stdout: stdout,
53
+ stderr: stderr,
54
+ success: status.success?,
55
+ module: "shell"
56
+ }
57
+ else
58
+ { error: "Backup script not found", module: "shell" }
59
+ end
60
+ end
61
+
62
+ def execute_restore(*args)
63
+ backup = args.first
64
+ return { error: "Backup path required", module: "shell" } unless backup
65
+
66
+ script_path = File.join(@grim_root, "sh_grim", "restore.sh")
67
+
68
+ if File.exist?(script_path)
69
+ stdout, stderr, status = Open3.capture3(script_path, "recover", backup, chdir: @grim_root)
70
+ {
71
+ command: "restore",
72
+ backup: backup,
73
+ stdout: stdout,
74
+ stderr: stderr,
75
+ success: status.success?,
76
+ module: "shell"
77
+ }
78
+ else
79
+ { error: "Restore script not found", module: "shell" }
80
+ end
81
+ end
82
+
83
+ def execute_monitor(*args)
84
+ path = args.first || "/"
85
+ script_path = File.join(@grim_root, "sh_grim", "monitor.sh")
86
+
87
+ if File.exist?(script_path)
88
+ stdout, stderr, status = Open3.capture3(script_path, "start", path, chdir: @grim_root)
89
+ {
90
+ command: "monitor",
91
+ path: path,
92
+ stdout: stdout,
93
+ stderr: stderr,
94
+ success: status.success?,
95
+ module: "shell"
96
+ }
97
+ else
98
+ { error: "Monitor script not found", module: "shell" }
99
+ end
100
+ end
101
+
102
+ def execute_scan(*args)
103
+ path = args.first || "/"
104
+ script_path = File.join(@grim_root, "sh_grim", "scan.sh")
105
+
106
+ if File.exist?(script_path)
107
+ stdout, stderr, status = Open3.capture3(script_path, "full", path, chdir: @grim_root)
108
+ {
109
+ command: "scan",
110
+ path: path,
111
+ stdout: stdout,
112
+ stderr: stderr,
113
+ success: status.success?,
114
+ module: "shell"
115
+ }
116
+ else
117
+ { error: "Scan script not found", module: "shell" }
118
+ end
119
+ end
120
+
121
+ def execute_security(*args)
122
+ script_path = File.join(@grim_root, "sh_grim", "security.sh")
123
+
124
+ if File.exist?(script_path)
125
+ stdout, stderr, status = Open3.capture3(script_path, "audit", chdir: @grim_root)
126
+ {
127
+ command: "security",
128
+ stdout: stdout,
129
+ stderr: stderr,
130
+ success: status.success?,
131
+ module: "shell"
132
+ }
133
+ else
134
+ { error: "Security script not found", module: "shell" }
135
+ end
136
+ end
137
+
138
+ def execute_generic(command, *args)
139
+ script_path = File.join(@grim_root, "sh_grim", "#{command}.sh")
140
+
141
+ if File.exist?(script_path)
142
+ stdout, stderr, status = Open3.capture3(script_path, *args, chdir: @grim_root)
143
+ {
144
+ command: command,
145
+ args: args,
146
+ stdout: stdout,
147
+ stderr: stderr,
148
+ success: status.success?,
149
+ module: "shell"
150
+ }
151
+ else
152
+ { error: "Script not found: #{command}.sh", module: "shell" }
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GrimReaper
4
+ VERSION = "1.0.29"
5
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "grim_reaper/version"
4
+ require_relative "grim_reaper/core"
5
+ require_relative "grim_reaper/shell_module"
6
+ require_relative "grim_reaper/python_module"
7
+ require_relative "grim_reaper/go_module"
8
+ require_relative "grim_reaper/security_module"
9
+ require_relative "grim_reaper/installer"
10
+
11
+ # Grim Reaper - The Ultimate Backup, Monitoring, and Security System
12
+ # Ruby Wrapper for all Grim Reaper modules
13
+ module GrimReaper
14
+ class Error < StandardError; end
15
+
16
+ # Main entry point for the gem
17
+ def self.new(config = {})
18
+ Core.new(config)
19
+ end
20
+
21
+ # Quick access methods
22
+ def self.status
23
+ Core.new.status
24
+ end
25
+
26
+ def self.execute(command, *args)
27
+ Core.new.execute(command, *args)
28
+ end
29
+
30
+ def self.backup(path)
31
+ Core.new.execute('backup', path)
32
+ end
33
+
34
+ def self.monitor(path)
35
+ Core.new.execute('monitor', path)
36
+ end
37
+
38
+ def self.security
39
+ Core.new.execute('security')
40
+ end
41
+ end