Spaces:
Sleeping
Sleeping
Commit Β·
98d1f5d
1
Parent(s): af0024b
Auto-commit: README.md updated
Browse files11234556789910111213131415161717181920212122232425252627282929303132333334353637373839404141424343444545464747484949505152535455565758596057616263646165666768656970677169727173747375767778798081827783848586878881899091928593949596899798991009310110210310497105106107108101109110111112105113114107115116117118109119120121122123124125113126127128117129130131132121133134135136125137138139140129141142143144133145146147148137149150151152141153154155156157158145159160147161162149163151164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304153305306307308309310311312313314315316317318319155320157321322159323324161325326163327328329---------------------
title: Landrun Sandbox + Browser Automation
emoji: πtitle: Landrun Sandbox + Browser Automationtitle: Docker Sandboxemoji: πtitle: Landrun Sandbox + Browser Automation
colorFrom: purple
colorTo: blueemoji: ππemoji: π³colorTo: blueemoji: πtitle: Landrun Sandbox + Browser Automationtitle: Docker Sandbox
sdk: docker
app_file: app.pycolorFrom: purplecolorFrom: blueapp_file: app.pycolorFrom: purple
pinned: false
license: mitcolorTo: bluecolorTo: purplelicense: mitcolorTo: blueemoji: ππemoji: π³
---
sdk: dockersdk: dockersdk: docker
# π Landrun Sandbox + Browser Automation
pinned: truepinned: falseapp_file: app.pycolorFrom: purplecolorFrom: blue
**Kernel-Level Code Execution Sandbox with Automated UI Testing**
license: mitlicense: mitpinned: false
Execute code with maximum security using **Landrun** (Linux Landlock kernel security) and automatically test UIs with **Playwright** browser automation.
------license: mitcolorTo: bluecolorTo: purple
## β¨ Features
---
### π Landrun Security
- **Kernel-level isolation** using Linux Landlock LSM# π Landrun Sandbox + Browser Automation# π³ Docker Sandbox Executorsdk: dockersdk: docker
- **Zero-trust execution** with restricted filesystem access- **Kernel-level isolation** using Linux Landlock LSM
- **Read-only system files** - only `/tmp/sandbox` is writable- **Zero-trust execution** with restricted filesystem access# π Landrun Sandbox + Browser Automation
- **Network restrictions** - only HTTP/HTTPS allowed- **Read-only system files** - only `/tmp/sandbox` is writable
- **10-second timeout** protection**Kernel-Level Code Execution Sandbox + Automated UI Testing****Secure code execution in isolated Docker containers**- **Network restrictions** - only HTTP/HTTPS allowedpinned: truepinned: false
- **10-second timeout** protection
**Kernel-Level Code Execution Sandbox with Automated UI Testing**
### π Browser Automation
license: mitlicense: mit
- **Playwright Chromium** for automated UI testing
- **Screenshot capture** before/after actionsExecute code with maximum security using **Landrun** (Linux Landlock kernel security) and automatically test UIs with **Playwright** browser automation.## Features- **Screenshot capture** before/after actionsExecute code with maximum security using **Landrun** (Linux Landlock kernel security) and automatically test UIs with **Playwright** browser automation.
- **Element interaction** - click, type, wait, get text
- **One-shot API** - execute code β test UI β get results- **One-shot API** - execute code β test UI β get results------
### π Supported Languages## β¨ Featuresβ
**Isolated execution** - Each code run in separate container ### π Supported Languages## β¨ Features
- **Python 3.11** - with stdlib + compilers (gcc, g++)
- **JavaScript (Node.js)** - server-side executionβ
**Resource limits** - 256MB RAM, 50% CPU per execution
- **React (JSX)** - client-side components with live preview- **Python 3.11** - with stdlib + compilers (gcc, g++)
- **HTML + CSS** - static pages with full styling### π Landrun Securityβ
**Network disabled** - Maximum security - **JavaScript (Node.js)** - server-side execution
- **React (JSX)** - client-side components with live preview### π Landrun Security
- **HTML + CSS** - static pages with full styling
- **Kernel-level isolation** using Linux Landlock LSM# π Landrun Sandbox + Browser Automation# π³ Docker Sandbox Executor
## π‘ API Endpoints- **Kernel-level isolation** using Linux Landlock LSMβ
**Auto-cleanup** - Containers destroyed after execution ## π‘ API Endpoints
- **Zero-trust execution** with restricted filesystem access
### 1. Execute Code
### 1. Execute Code- **Zero-trust execution** with restricted filesystem accessβ
**Multiple languages** - Python, JavaScript, React, HTML- **Read-only system files** - only `/tmp/sandbox` is writable
```bash
POST /execute- **Read-only system files** - only `/tmp/sandbox` is writablePOST /execute- **Network restrictions** - only HTTP/HTTPS allowed
Content-Type: application/json
- **Network restrictions** - only HTTP/HTTPS allowed## Architecture- **10-second timeout** protection**Kernel-Level Code Execution Sandbox + Automated UI Testing****Secure code execution in isolated Docker containers**
{
"language": "react",- **10-second timeout** protection "language": "react",
"code": "export default function App() { return <h1>Hello!</h1>; }"
}```}### π Browser Automation
```
### π Browser Automationβββββββββββββββββββββββββββββββββββββββββββββββββββββββ- **Playwright Chromium** for automated UI testing
### 2. Get Live Preview
```bash- **Playwright Chromium** for automated UI testingβ Hugging Face Space (Docker SDK) β- **Screenshot capture** before/after actionsExecute code with maximum security using **Landrun** (Linux Landlock kernel security) and automatically test UIs with **Playwright** browser automation.## Features
GET /preview/{uuid}```bash
GET /preview/{uuid}- **Element interaction** - click, type, wait, get text
```- **Screenshot capture** before/after actionsβ β```
- **One-shot API** - execute code β test UI β get results
### 3. Test UI with Browser
### 3. Test UI with Browser- **Element interaction** - click, type, waitβ ββββββββββββββββββββββββββββββββββββββββββββββββ β
```bash
POST /browser/test- **Text extraction** from elementsβ β FastAPI Server (app_docker.py) β βPOST /browser/test### π Supported Languages## β¨ Featuresβ
**Isolated execution** - Each code run in separate container
Content-Type: application/json
- **One-shot API** - execute code β test UI β get resultsβ β β β- **Python 3.11** - with stdlib + compilers (gcc, g++)
{
"preview_url": "/preview/uuid",β β ββββββββββββββββββββββββββββββββββββββββββ β β "preview_url": "/preview/uuid",- **JavaScript (Node.js)** - server-side executionβ
**Resource limits** - 256MB RAM, 50% CPU per execution
"actions": [
{"type": "click", "selector": "button"},### π Supported Languagesβ β β Docker Engine (in Space) β β β {"type": "click", "selector": "button"},- **React (JSX)** - client-side components with live preview
{"type": "screenshot"}
]- **Python 3.11** - with stdlib + compilersβ β β β β β ]- **HTML + CSS** - static pages with full styling### π Landrun Securityβ
**Network disabled** - Maximum security
}
```- **JavaScript (Node.js)** - server-side executionβ β β ββββββββββββββββ ββββββββββββββββ β β β```
### 4. Execute + Test (One-Shot)- **React (JSX)** - client-side components with live previewβ β β β Python:3.11 β β Node:18 β β β β### 4. Execute + Test (One-Shot)## π‘ API Endpoints- **Kernel-level isolation** using Linux Landlock LSMβ
**Auto-cleanup** - Containers destroyed after execution
```bash
POST /browser/execute_and_test- **HTML + CSS** - static pages with full stylingβ β β β Container β β Container β β β βPOST /browser/execute_and_test
Content-Type: application/jsonContent-Type: application/json### 1. Execute Code- **Zero-trust execution** with restricted filesystem accessβ
**Multiple languages** - Python, JavaScript, React, HTML
β β β β β β β β β β
{
{```bash
"language": "react",
"code": "export default function App() { return <button>Click</button>; }",POST /execute- **Read-only system files** - only `/tmp/sandbox` is writable
"actions": [
{"type": "click", "selector": "button"},Content-Type: application/json
{"type": "screenshot"}
]- **Network restrictions** - only HTTP/HTTPS allowed## Architecture
}
```{
## π― Quick Start "language": "react",- **10-second timeout** protection
### Python Example "code": "export default function App() { return <h1>Hello!</h1>; }"
```python}```
import requests
```
response = requests.post(
"https://speedofmastery-hmm.hf.space/browser/execute_and_test",### π Browser Automationβββββββββββββββββββββββββββββββββββββββββββββββββββββββ
json={
"language": "react",### 2. Get Live Preview
"code": """
export default function App() {```bash- **Playwright Chromium** for automated UI testingβ Hugging Face Space (Docker SDK) β
const [count, setCount] = React.useState(0);
return (GET /preview/{uuid}
<div>
<h1>Count: {count}</h1>```- **Screenshot capture** before/after actionsβ β
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}### 3. Test UI with Browser- **Element interaction** - click, type, waitβ ββββββββββββββββββββββββββββββββββββββββββββββββ β
""",
"actions": [```bash
{"type": "click", "selector": "button"},
{"type": "screenshot"}POST /browser/test- **Text extraction** from elementsβ β FastAPI Server (app_docker.py) β β
]
}Content-Type: application/json
)
- **One-shot API** - execute code β test UI β get resultsβ β β β
result = response.json()
print(result['status']) # 'success'{
```
"preview_url": "/preview/uuid",β β ββββββββββββββββββββββββββββββββββββββββββ β β
## π Security
"actions": [
- **Landrun Sandbox:** Kernel-level isolation using Linux Landlock
- **Read-only:** `/usr`, `/lib`, `/etc` are read-only {"type": "click", "selector": "button"},### π Supported Languagesβ β β Docker Engine (in Space) β β β
- **Writable:** Only `/tmp/sandbox` is writable
- **Network:** TCP ports 80, 443 only {"type": "screenshot"}
- **Timeout:** 10 seconds max execution
- **Browser:** Headless Chromium with 5s action timeout ]- **Python 3.11** - with stdlib + compilersβ β β β β β
## π οΈ Technology Stack}
- **Landrun**: Go-based Linux Landlock sandbox```- **JavaScript (Node.js)** - server-side executionβ β β ββββββββββββββββ ββββββββββββββββ β β β
- **FastAPI**: Modern async Python web framework
- **Playwright**: Browser automation framework
- **Chromium**: Headless browser engine
- **Docker**: Multi-stage container build### 4. Execute + Test (One-Shot)- **React (JSX)** - client-side components with live previewβ β β β Python:3.11 β β Node:18 β β β β
- **Python 3.11**: Runtime environment with compilers
- **Node.js**: JavaScript execution```bash
## π Browser ActionsPOST /browser/execute_and_test- **HTML + CSS** - static pages with full stylingβ β β β Container β β Container β β β β
| Action | Description |Content-Type: application/json
|--------|-------------|
| `click` | Click element by selector |β β β β β β β β β β
| `type` | Type text into input field |
| `get_text` | Extract text from element |{
| `wait` | Wait for element to appear |
"language": "react",## π‘ API Endpointsβ β β β β’ 256MB RAM β β β’ 256MB RAM β β β β| `screenshot` | Capture screenshot (base64) | "language": "react",## π‘ API Endpointsβ β β β β’ 256MB RAM β β β’ 256MB RAM β β β β
## π License "code": "export default function App() { return <button>Click</button>; }",
MIT License - Free to use and modify "actions": [β β β β β’ 50% CPU β β β’ 50% CPU β β β β
## π Links {"type": "click", "selector": "button"},
"code": "export default function App() { return <button>Click</button>; }",
"actions": [β β β β β’ 50% CPU β β β’ 50% CPU β β β β- **Live Demo:** [speedofmastery-hmm.hf.space](https://speedofmastery-hmm.hf.space) {"type": "screenshot"}### POST /execute - Execute Code with Landrunβ β β β β’ No Network β β β’ No Network β β β β
{"type": "click", "selector": "button"},- **Landrun GitHub:** [github.com/zouuup/landrun](https://github.com/zouuup/landrun)
{"type": "screenshot"}### POST /execute - Execute Code with Landrunβ β β β β’ No Network β β β’ No Network β β β β- **Playwright Docs:** [playwright.dev](https://playwright.dev) ]
]
}### GET /preview/{uuid} - Get Live Preview β β β ββββββββββββββββ ββββββββββββββββ β β β
README.md+213-50