Commit 0bd5438
Refactor jail architecture with integrated services (#15)
* start
* Refactor jail to use integrated services architecture
- Updated namespace implementations to include environment setup in Command method
- Migrated Execute function logic from namespaces into Command method with proper env, credentials, and I/O setup
- Enhanced jail.Jail to integrate proxy server, certificate manager, rule engine, and auditor
- Simplified CLI to use unified jail.Jail instead of managing separate components
- Maintained all existing functionality while improving code organization
- All tests pass and binary builds successfully
Co-authored-by: f0ssel <[email protected]>
* Move environment setup to Open method in namespace implementations
- Move environment preparation from Command() to Open() method in both Linux and macOS namespaces
- Add preparedEnv field to store the prepared environment once during setup
- Simplify Command() methods to just inject the prepared environment
- Improves performance by avoiding repeated environment setup on each command
- Maintains all existing functionality while improving efficiency
Co-authored-by: f0ssel <[email protected]>
* Move sudo credential setup to Open method in namespace implementations
- Move sudo credential preparation from Command() to Open() method in both Linux and macOS namespaces
- Add procAttr field to store prepared syscall.SysProcAttr with credentials
- Simplify Command() methods to just use the prepared process attributes
- Eliminates repeated sudo environment checks and credential parsing on each command
- Further improves performance and code organization
- All credential handling now happens once during setup phase
Co-authored-by: f0ssel <[email protected]>
* Move construction logic from jail.New to CLI caller
- Simplify jail.Config to only contain dependencies (Commander, ProxyServer, etc)
- Move all component construction logic from jail.New into CLI
- jail.New now only accepts pre-constructed dependencies and assembles them
- CLI handles rule parsing, certificate manager creation, proxy server setup
- Better separation of concerns: jail package focuses on orchestration, CLI handles construction
- Eliminates error handling in jail.New since dependencies are pre-validated
- Makes jail package more testable with dependency injection
Co-authored-by: f0ssel <[email protected]>
* Remove unneeded dependencies from jail.Config
- Remove RuleEngine, Auditor, and CertManager from jail.Config
- These dependencies are only needed by ProxyServer, not by Jail directly
- Simplify jail.Config to only contain CommandExecutor, ProxyServer, and Logger
- Remove GetCACertPEM method since CertManager is no longer available in Jail
- Clean up unused imports (audit, rules, tls packages)
- CA certificate handling remains in CLI where CertManager is constructed
- Further simplifies the Jail orchestration layer
Co-authored-by: f0ssel <[email protected]>
* remove no cleanup
* setenv
* Convert preparedEnv to map and implement SetEnv methods
- Convert preparedEnv from []string to map[string]string for better environment management
- Implement SetEnv methods in both Linux and macOS namespace implementations
- Add CommandExecutor accessor method to Jail for SetEnv access
- Update CLI to use SetEnv method for CA certificate environment variables
- Remove Env field from namespace.Config since SetEnv is used instead
- Environment variables now properly managed through SetEnv interface
- Allows dynamic environment variable setting after initialization
- Better encapsulation and control over environment variables
Co-authored-by: f0ssel <[email protected]>
* fix
* fix
* fix
* fix
* Move TLS setup logic to CertificateManager method
- Add SetupTLSAndWriteCACert method to CertificateManager
- Combines getting TLS config, CA cert PEM, and writing CA cert to file
- Returns TLS config, CA cert path, and CA cert PEM in one call
- Update CLI to use the new method instead of separate calls
- Reduces complexity in CLI Run function
- Better encapsulation of TLS-related setup logic
- Remove unused filepath import from CLI
- Clean separation between TLS setup and CLI orchestration
Co-authored-by: f0ssel <[email protected]>
* Move GetConfigDir call into CertificateManager and remove unused return value
- Update SetupTLSAndWriteCACert to call tls.GetConfigDir() internally
- Return config directory as part of the method's return values
- Remove unused []byte (CA cert PEM) from return values since it's never used
- Update CLI to handle new return signature with configDir
- Remove separate GetConfigDir call from CLI
- Pass empty string to NewCertificateManager since configDir is determined internally
- Further simplifies CLI by removing another external dependency call
- Better encapsulation of config directory management within TLS package
Co-authored-by: f0ssel <[email protected]>
* fix
---------
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: f0ssel <[email protected]>1 parent 5678372 commit 0bd5438
File tree
11 files changed
+376
-343
lines changed- cli
- namespace
- network
- tls
11 files changed
+376
-343
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | 12 | | |
| 13 | + | |
15 | 14 | | |
16 | | - | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
| |||
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 71 | | |
82 | 72 | | |
83 | 73 | | |
| |||
123 | 113 | | |
124 | 114 | | |
125 | 115 | | |
| 116 | + | |
126 | 117 | | |
127 | 118 | | |
128 | 119 | | |
129 | 120 | | |
130 | 121 | | |
131 | 122 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 123 | | |
137 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
138 | 128 | | |
139 | | - | |
140 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
141 | 137 | | |
142 | | - | |
143 | | - | |
| 138 | + | |
| 139 | + | |
144 | 140 | | |
145 | 141 | | |
146 | 142 | | |
147 | | - | |
148 | 143 | | |
149 | | - | |
150 | | - | |
151 | 144 | | |
152 | | - | |
| 145 | + | |
153 | 146 | | |
154 | 147 | | |
155 | 148 | | |
156 | 149 | | |
157 | 150 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
170 | 154 | | |
171 | | - | |
172 | | - | |
| 155 | + | |
| 156 | + | |
173 | 157 | | |
174 | 158 | | |
175 | 159 | | |
176 | 160 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
184 | 167 | | |
185 | 168 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
193 | 178 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
200 | 185 | | |
201 | | - | |
| 186 | + | |
202 | 187 | | |
203 | 188 | | |
204 | 189 | | |
205 | 190 | | |
206 | 191 | | |
207 | 192 | | |
208 | 193 | | |
209 | | - | |
| 194 | + | |
210 | 195 | | |
211 | 196 | | |
212 | 197 | | |
| |||
216 | 201 | | |
217 | 202 | | |
218 | 203 | | |
219 | | - | |
| 204 | + | |
220 | 205 | | |
221 | | - | |
| 206 | + | |
222 | 207 | | |
223 | 208 | | |
224 | 209 | | |
225 | 210 | | |
226 | 211 | | |
227 | | - | |
228 | | - | |
| 212 | + | |
| 213 | + | |
229 | 214 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 215 | + | |
| 216 | + | |
245 | 217 | | |
246 | 218 | | |
247 | | - | |
248 | | - | |
249 | 219 | | |
250 | 220 | | |
251 | 221 | | |
252 | 222 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 223 | + | |
265 | 224 | | |
266 | 225 | | |
267 | | - | |
| 226 | + | |
268 | 227 | | |
269 | 228 | | |
270 | 229 | | |
| |||
277 | 236 | | |
278 | 237 | | |
279 | 238 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
| 239 | + | |
286 | 240 | | |
287 | 241 | | |
288 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
0 commit comments