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