Speedofmastery commited on
Commit
af0024b
Β·
1 Parent(s): 6652512

Auto-commit: README.md updated

Browse files
Files changed (1) hide show
  1. README.md +220 -65
README.md CHANGED
@@ -1,158 +1,313 @@
1
- ------
 
 
 
 
 
 
 
 
 
 
2
 
3
- title: Landrun Sandbox + Browser Automationtitle: Docker Sandbox
4
 
5
- emoji: πŸ”’πŸŒemoji: 🐳
6
 
7
- colorFrom: purplecolorFrom: blue
8
 
9
- colorTo: bluecolorTo: purple
10
 
11
  sdk: dockersdk: docker
12
 
 
 
13
  pinned: truepinned: false
14
 
 
 
15
  license: mitlicense: mit
16
 
 
 
17
  ------
18
 
 
19
 
20
 
21
- # πŸ”’ Landrun Sandbox + Browser Automation# 🐳 Docker Sandbox Executor
22
 
 
23
 
 
24
 
25
- **Kernel-Level Code Execution Sandbox + Automated UI Testing****Secure code execution in isolated Docker containers**
26
 
 
27
 
 
28
 
29
- Execute code with maximum security using **Landrun** (Linux Landlock kernel security) and automatically test UIs with **Playwright** browser automation.## Features
30
 
31
 
32
 
33
- ## ✨ Featuresβœ… **Isolated execution** - Each code run in separate container
34
 
35
- βœ… **Resource limits** - 256MB RAM, 50% CPU per execution
36
 
37
- ### πŸ”’ Landrun Securityβœ… **Network disabled** - Maximum security
38
 
39
- - **Kernel-level isolation** using Linux Landlock LSMβœ… **Auto-cleanup** - Containers destroyed after execution
40
 
41
- - **Zero-trust execution** with restricted filesystem accessβœ… **Multiple languages** - Python, JavaScript, React, HTML
42
 
43
- - **Read-only system files** - only `/tmp/sandbox` is writable
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  - **Network restrictions** - only HTTP/HTTPS allowed## Architecture
46
 
47
- - **10-second timeout** protection
 
 
 
 
 
 
48
 
49
  ```
50
 
51
  ### 🌐 Browser Automationβ”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
52
 
53
- - **Playwright Chromium** for automated UI testingβ”‚ Hugging Face Space (Docker SDK) β”‚
 
 
 
 
54
 
55
- - **Screenshot capture** before/after actionsβ”‚ β”‚
56
 
57
- - **Element interaction** - click, type, waitβ”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
58
 
59
- - **Text extraction** from elementsβ”‚ β”‚ FastAPI Server (app_docker.py) β”‚ β”‚
 
 
 
 
 
 
 
60
 
61
  - **One-shot API** - execute code β†’ test UI β†’ get resultsβ”‚ β”‚ β”‚ β”‚
62
 
63
- β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
 
 
64
 
65
- ### πŸš€ Supported Languagesβ”‚ β”‚ β”‚ Docker Engine (in Space) β”‚ β”‚ β”‚
66
 
67
- - **Python 3.11** - with stdlib + compilersβ”‚ β”‚ β”‚ β”‚ β”‚ β”‚
68
 
69
- - **JavaScript (Node.js)** - server-side executionβ”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚
70
 
71
- - **React (JSX)** - client-side components with live previewβ”‚ β”‚ β”‚ β”‚ Python:3.11 β”‚ β”‚ Node:18 β”‚ β”‚ β”‚ β”‚
72
 
73
- - **HTML + CSS** - static pages with full stylingβ”‚ β”‚ β”‚ β”‚ Container β”‚ β”‚ Container β”‚ β”‚ β”‚ β”‚
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
76
 
77
- ## πŸ“‘ API Endpointsβ”‚ β”‚ β”‚ β”‚ β€’ 256MB RAM β”‚ β”‚ β€’ 256MB RAM β”‚ β”‚ β”‚ β”‚
 
 
 
 
 
 
 
 
78
 
79
- β”‚ β”‚ β”‚ β”‚ β€’ 50% CPU β”‚ β”‚ β€’ 50% CPU β”‚ β”‚ β”‚ β”‚
80
 
81
- ### POST /execute - Execute Code with Landrunβ”‚ β”‚ β”‚ β”‚ β€’ No Network β”‚ β”‚ β€’ No Network β”‚ β”‚ β”‚ β”‚
82
 
83
- ### GET /preview/{uuid} - Get Live Preview β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚
 
 
84
 
85
  ### POST /browser/test - Test UI with Browserβ”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
86
 
 
 
87
  ### POST /browser/execute_and_test - One-Shot Execute + Testβ”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
88
 
89
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 
 
 
 
90
 
91
  Full API documentation available at the Space URL.```
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
 
94
 
95
- ## πŸš€ Quick Start## Security Features
96
 
 
 
 
97
 
 
98
 
99
- Visit: **https://speedofmastery-hmm.hf.space**### πŸ›‘οΈ Container Isolation
100
 
101
- - Each execution runs in a **separate Docker container**
102
 
103
- ## πŸ“„ License- Containers are **destroyed after execution**
104
 
105
- - **No persistent storage** between executions
106
 
107
- MIT License
 
 
108
 
109
- ### 🚫 Resource Limits
110
- - **Memory**: 256MB per container
111
- - **CPU**: 50% of one core
112
- - **Timeout**: 30 seconds default
113
  - **Network**: Disabled (network_mode="none")
114
 
115
- ### πŸ”’ Security Constraints
116
- - **No root access** in containers
 
 
 
 
117
  - **No file system persistence**
118
- - **No network access**
 
 
119
  - **Automatic cleanup** after execution
120
 
121
- ## Hugging Face Space Configuration
 
 
 
 
 
 
122
 
123
- ### Required Space Settings
 
 
124
 
125
- #### 1. SDK
126
  ```yaml
127
- sdk: docker
 
 
128
  ```
129
 
130
- #### 2. Dockerfile.sandbox
131
- Use the provided `Dockerfile.sandbox` which includes:
132
- - Python 3.11 base
133
- - Node.js for React/JavaScript
134
- - Docker-in-Docker (DinD) support
135
- - Non-root user execution
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- #### 3. Requirements
138
  ```txt
139
- fastapi
140
- uvicorn[standard]
141
- docker
142
- pydantic
143
- ```
144
 
145
- ## Deployment Steps
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
- ### Step 1: Create Hugging Face Space
148
  ```bash
149
- # Create new space with Docker SDK
 
 
150
  # Name: your-docker-sandbox
151
- # SDK: Docker
 
 
152
  ```
153
 
154
- ### Step 2: Upload Files
155
- ```bash
 
 
 
 
156
  python deploy_docker_space.py
157
  ```
158
 
 
1
+ ---------
2
+
3
+ title: Landrun Sandbox + Browser Automation
4
+
5
+ emoji: πŸ”’title: Landrun Sandbox + Browser Automationtitle: Docker Sandbox
6
+
7
+ colorFrom: purple
8
+
9
+ colorTo: blueemoji: πŸ”’πŸŒemoji: 🐳
10
+
11
+ sdk: docker
12
 
13
+ app_file: app.pycolorFrom: purplecolorFrom: blue
14
 
15
+ pinned: false
16
 
17
+ license: mitcolorTo: bluecolorTo: purple
18
 
19
+ ---
20
 
21
  sdk: dockersdk: docker
22
 
23
+ # πŸ”’ Landrun Sandbox + Browser Automation
24
+
25
  pinned: truepinned: false
26
 
27
+ **Kernel-Level Code Execution Sandbox with Automated UI Testing**
28
+
29
  license: mitlicense: mit
30
 
31
+ Execute code with maximum security using **Landrun** (Linux Landlock kernel security) and automatically test UIs with **Playwright** browser automation.
32
+
33
  ------
34
 
35
+ ## ✨ Features
36
 
37
 
 
38
 
39
+ ### πŸ”’ Landrun Security
40
 
41
+ - **Kernel-level isolation** using Linux Landlock LSM# πŸ”’ Landrun Sandbox + Browser Automation# 🐳 Docker Sandbox Executor
42
 
43
+ - **Zero-trust execution** with restricted filesystem access
44
 
45
+ - **Read-only system files** - only `/tmp/sandbox` is writable
46
 
47
+ - **Network restrictions** - only HTTP/HTTPS allowed
48
 
49
+ - **10-second timeout** protection**Kernel-Level Code Execution Sandbox + Automated UI Testing****Secure code execution in isolated Docker containers**
50
 
51
 
52
 
53
+ ### 🌐 Browser Automation
54
 
55
+ - **Playwright Chromium** for automated UI testing
56
 
57
+ - **Screenshot capture** before/after actionsExecute code with maximum security using **Landrun** (Linux Landlock kernel security) and automatically test UIs with **Playwright** browser automation.## Features
58
 
59
+ - **Element interaction** - click, type, wait, get text
60
 
61
+ - **One-shot API** - execute code β†’ test UI β†’ get results
62
 
63
+
64
+
65
+ ### πŸš€ Supported Languages## ✨ Featuresβœ… **Isolated execution** - Each code run in separate container
66
+
67
+ - **Python 3.11** - with stdlib + compilers (gcc, g++)
68
+
69
+ - **JavaScript (Node.js)** - server-side executionβœ… **Resource limits** - 256MB RAM, 50% CPU per execution
70
+
71
+ - **React (JSX)** - client-side components with live preview
72
+
73
+ - **HTML + CSS** - static pages with full styling### πŸ”’ Landrun Securityβœ… **Network disabled** - Maximum security
74
+
75
+
76
+
77
+ ## πŸ“‘ API Endpoints- **Kernel-level isolation** using Linux Landlock LSMβœ… **Auto-cleanup** - Containers destroyed after execution
78
+
79
+
80
+
81
+ ### 1. Execute Code- **Zero-trust execution** with restricted filesystem accessβœ… **Multiple languages** - Python, JavaScript, React, HTML
82
+
83
+ ```bash
84
+
85
+ POST /execute- **Read-only system files** - only `/tmp/sandbox` is writable
86
+
87
+ Content-Type: application/json
88
 
89
  - **Network restrictions** - only HTTP/HTTPS allowed## Architecture
90
 
91
+ {
92
+
93
+ "language": "react",- **10-second timeout** protection
94
+
95
+ "code": "export default function App() { return <h1>Hello!</h1>; }"
96
+
97
+ }```
98
 
99
  ```
100
 
101
  ### 🌐 Browser Automationβ”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
102
 
103
+ ### 2. Get Live Preview
104
+
105
+ ```bash- **Playwright Chromium** for automated UI testingβ”‚ Hugging Face Space (Docker SDK) β”‚
106
+
107
+ GET /preview/{uuid}
108
 
109
+ ```- **Screenshot capture** before/after actionsβ”‚ β”‚
110
 
 
111
 
112
+
113
+ ### 3. Test UI with Browser- **Element interaction** - click, type, waitβ”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
114
+
115
+ ```bash
116
+
117
+ POST /browser/test- **Text extraction** from elementsβ”‚ β”‚ FastAPI Server (app_docker.py) β”‚ β”‚
118
+
119
+ Content-Type: application/json
120
 
121
  - **One-shot API** - execute code β†’ test UI β†’ get resultsβ”‚ β”‚ β”‚ β”‚
122
 
123
+ {
124
+
125
+ "preview_url": "/preview/uuid",β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
126
 
127
+ "actions": [
128
 
129
+ {"type": "click", "selector": "button"},### πŸš€ Supported Languagesβ”‚ β”‚ β”‚ Docker Engine (in Space) β”‚ β”‚ β”‚
130
 
131
+ {"type": "screenshot"}
132
 
133
+ ]- **Python 3.11** - with stdlib + compilersβ”‚ β”‚ β”‚ β”‚ β”‚ β”‚
134
 
135
+ }
136
+
137
+ ```- **JavaScript (Node.js)** - server-side executionβ”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚
138
+
139
+
140
+
141
+ ### 4. Execute + Test (One-Shot)- **React (JSX)** - client-side components with live previewβ”‚ β”‚ β”‚ β”‚ Python:3.11 β”‚ β”‚ Node:18 β”‚ β”‚ β”‚ β”‚
142
+
143
+ ```bash
144
+
145
+ POST /browser/execute_and_test- **HTML + CSS** - static pages with full stylingβ”‚ β”‚ β”‚ β”‚ Container β”‚ β”‚ Container β”‚ β”‚ β”‚ β”‚
146
+
147
+ Content-Type: application/json
148
 
149
  β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
150
 
151
+ {
152
+
153
+ "language": "react",## πŸ“‘ API Endpointsβ”‚ β”‚ β”‚ β”‚ β€’ 256MB RAM β”‚ β”‚ β€’ 256MB RAM β”‚ β”‚ β”‚ β”‚
154
+
155
+ "code": "export default function App() { return <button>Click</button>; }",
156
+
157
+ "actions": [β”‚ β”‚ β”‚ β”‚ β€’ 50% CPU β”‚ β”‚ β€’ 50% CPU β”‚ β”‚ β”‚ β”‚
158
+
159
+ {"type": "click", "selector": "button"},
160
 
161
+ {"type": "screenshot"}### POST /execute - Execute Code with Landrunβ”‚ β”‚ β”‚ β”‚ β€’ No Network β”‚ β”‚ β€’ No Network β”‚ β”‚ β”‚ β”‚
162
 
163
+ ]
164
 
165
+ }### GET /preview/{uuid} - Get Live Preview β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚
166
+
167
+ ```
168
 
169
  ### POST /browser/test - Test UI with Browserβ”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
170
 
171
+ ## 🎯 Quick Start
172
+
173
  ### POST /browser/execute_and_test - One-Shot Execute + Testβ”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
174
 
175
+ ### Python Example
176
+
177
+ ```pythonβ””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
178
+
179
+ import requests
180
 
181
  Full API documentation available at the Space URL.```
182
 
183
+ response = requests.post(
184
+
185
+ "https://speedofmastery-hmm.hf.space/browser/execute_and_test",
186
+
187
+ json={
188
+
189
+ "language": "react",## πŸš€ Quick Start## Security Features
190
+
191
+ "code": """
192
+
193
+ export default function App() {
194
+
195
+ const [count, setCount] = React.useState(0);
196
+
197
+ return (Visit: **https://speedofmastery-hmm.hf.space**### πŸ›‘οΈ Container Isolation
198
+
199
+ <div>
200
+
201
+ <h1>Count: {count}</h1>- Each execution runs in a **separate Docker container**
202
 
203
+ <button onClick={() => setCount(count + 1)}>Increment</button>
204
 
205
+ </div>## πŸ“„ License- Containers are **destroyed after execution**
206
 
207
+ );
208
+
209
+ }- **No persistent storage** between executions
210
 
211
+ """,
212
 
213
+ "actions": [MIT License
214
 
215
+ {"type": "click", "selector": "button"},
216
 
217
+ {"type": "screenshot"}### 🚫 Resource Limits
218
 
219
+ ]- **Memory**: 256MB per container
220
 
221
+ }- **CPU**: 50% of one core
222
+
223
+ )- **Timeout**: 30 seconds default
224
 
 
 
 
 
225
  - **Network**: Disabled (network_mode="none")
226
 
227
+ result = response.json()
228
+
229
+ print(result['status']) # 'success'### πŸ”’ Security Constraints
230
+
231
+ ```- **No root access** in containers
232
+
233
  - **No file system persistence**
234
+
235
+ ## πŸ”’ Security- **No network access**
236
+
237
  - **Automatic cleanup** after execution
238
 
239
+ - **Landrun Sandbox:** Kernel-level isolation using Linux Landlock
240
+
241
+ - **Read-only:** `/usr`, `/lib`, `/etc` are read-only## Hugging Face Space Configuration
242
+
243
+ - **Writable:** Only `/tmp/sandbox` is writable
244
+
245
+ - **Network:** TCP ports 80, 443 only### Required Space Settings
246
 
247
+ - **Timeout:** 10 seconds max execution
248
+
249
+ - **Browser:** Headless Chromium with 5s action timeout#### 1. SDK
250
 
 
251
  ```yaml
252
+
253
+ ## πŸ› οΈ Technology Stacksdk: docker
254
+
255
  ```
256
 
257
+ - **Landrun**: Go-based Linux Landlock sandbox
258
+
259
+ - **FastAPI**: Modern async Python web framework#### 2. Dockerfile.sandbox
260
+
261
+ - **Playwright**: Browser automation frameworkUse the provided `Dockerfile.sandbox` which includes:
262
+
263
+ - **Chromium**: Headless browser engine- Python 3.11 base
264
+
265
+ - **Docker**: Multi-stage container build- Node.js for React/JavaScript
266
+
267
+ - **Python 3.11**: Runtime environment with compilers- Docker-in-Docker (DinD) support
268
+
269
+ - **Node.js**: JavaScript execution- Non-root user execution
270
+
271
+
272
+
273
+ ## πŸ“Š Browser Actions#### 3. Requirements
274
 
 
275
  ```txt
 
 
 
 
 
276
 
277
+ | Action | Description |fastapi
278
+
279
+ |--------|-------------|uvicorn[standard]
280
+
281
+ | `click` | Click element by selector |docker
282
+
283
+ | `type` | Type text into input field |pydantic
284
+
285
+ | `get_text` | Extract text from element |```
286
+
287
+ | `wait` | Wait for element to appear |
288
+
289
+ | `screenshot` | Capture screenshot (base64) |## Deployment Steps
290
+
291
+
292
+
293
+ ## πŸ“„ License### Step 1: Create Hugging Face Space
294
 
 
295
  ```bash
296
+
297
+ MIT License - Free to use and modify# Create new space with Docker SDK
298
+
299
  # Name: your-docker-sandbox
300
+
301
+ ## πŸ”— Links# SDK: Docker
302
+
303
  ```
304
 
305
+ - **Live Demo:** [speedofmastery-hmm.hf.space](https://speedofmastery-hmm.hf.space)
306
+
307
+ - **Landrun GitHub:** [github.com/zouuup/landrun](https://github.com/zouuup/landrun)### Step 2: Upload Files
308
+
309
+ - **Playwright Docs:** [playwright.dev](https://playwright.dev)```bash
310
+
311
  python deploy_docker_space.py
312
  ```
313