Skip to content

Commit 3a186fc

Browse files
feat: initial open-source release
- Complete SafeExec secure code execution platform - Multi-language support (Python, JavaScript, Java, C++, Go) - Docker-based sandboxing with security controls - Redis queue processing for scalable execution - Comprehensive API with authentication - Production-ready deployment configuration - Full test suite and documentation - Contributor-friendly setup with yarn scripts
0 parents  commit 3a186fc

File tree

91 files changed

+14999
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+14999
-0
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
.env
4+
.git
5+
.dockerignore
6+
Dockerfile
7+
README.md

.env.example

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# SafeExec - Secure Code Execution Platform
2+
# Copy this file to .env and configure for your environment
3+
4+
# ================================
5+
# ENVIRONMENT CONFIGURATION
6+
# ================================
7+
# Environment: development, test, production
8+
ENV=development
9+
10+
# Node.js Environment
11+
NODE_ENV=development
12+
13+
# ================================
14+
# APPLICATION CONFIGURATION
15+
# ================================
16+
PORT=5000
17+
API_PORT=5000
18+
DEBUG_PORT=9229
19+
20+
# ================================
21+
# DATABASE CONFIGURATION
22+
# ================================
23+
# MongoDB
24+
MONGO_USERNAME=admin
25+
MONGO_PASSWORD=devpassword
26+
MONGO_DB=safeexec_dev
27+
MONGO_PORT=27017
28+
MONGO_URI=mongodb://localhost:27017/safeexec_dev
29+
30+
# ================================
31+
# REDIS CONFIGURATION
32+
# ================================
33+
REDIS_PORT=6379
34+
REDIS_PASSWORD=
35+
REDIS_URI=redis://localhost:6379
36+
37+
# ================================
38+
# SECURITY CONFIGURATION
39+
# ================================
40+
# JWT Configuration (CHANGE IN PRODUCTION!)
41+
JWT_SECRET=dev-jwt-secret-change-in-production
42+
JWT_EXPIRES_IN=24h
43+
44+
# CORS Configuration
45+
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001
46+
47+
# Rate Limiting
48+
MAX_SUBMISSIONS_PER_MINUTE=10
49+
MAX_SUBMISSIONS_PER_HOUR=100
50+
MAX_SUBMISSIONS_PER_DAY=500
51+
52+
# ================================
53+
# DOCKER EXECUTOR CONFIGURATION
54+
# ================================
55+
EXECUTOR_TIMEOUT_MS=30000
56+
EXECUTOR_MEMORY_LIMIT_MB=128
57+
EXECUTOR_CPU_LIMIT=0.5
58+
59+
# ================================
60+
# LOGGING CONFIGURATION
61+
# ================================
62+
LOG_LEVEL=info
63+
64+
# ================================
65+
# API DOCUMENTATION
66+
# ================================
67+
SWAGGER_UI_ENABLED=true
68+
69+
# ================================
70+
# DOCKER CONFIGURATION
71+
# ================================
72+
DOCKER_HOST=/var/run/docker.sock
73+
BUILD_TARGET=development
74+
SUBNET=172.20.0.0/16
75+
76+
# Nginx Configuration
77+
NGINX_HTTP_PORT=80
78+
NGINX_HTTPS_PORT=443
79+
80+
# Health Check Configuration
81+
HEALTH_CHECK_INTERVAL=30s
82+
HEALTH_CHECK_TIMEOUT=10s
83+
84+
# Development Volume Mounts (for hot reload)
85+
DEV_VOLUME_MOUNT=.
86+
DEV_NODE_MODULES_MOUNT=/tmp/node_modules
87+
88+
# ================================
89+
# ENVIRONMENT-SPECIFIC EXAMPLES
90+
# ================================
91+
92+
# Development Environment
93+
# ENV=development
94+
# LOG_LEVEL=debug
95+
# SWAGGER_UI_ENABLED=true
96+
# BUILD_TARGET=development
97+
# HEALTH_CHECK_INTERVAL=10s
98+
# API_PORT=5000
99+
# MONGO_PORT=27017
100+
# REDIS_PORT=6379
101+
102+
# Test Environment
103+
# ENV=test
104+
# LOG_LEVEL=error
105+
# SWAGGER_UI_ENABLED=false
106+
# BUILD_TARGET=test
107+
# HEALTH_CHECK_INTERVAL=5s
108+
# API_PORT=5001
109+
# MONGO_PORT=27018
110+
# REDIS_PORT=6380
111+
# JWT_EXPIRES_IN=1h
112+
113+
# Production Environment
114+
# ENV=production
115+
# LOG_LEVEL=warn
116+
# SWAGGER_UI_ENABLED=false
117+
# BUILD_TARGET=production
118+
# HEALTH_CHECK_INTERVAL=30s
119+
# API_PORT=5000
120+
# MONGO_PORT=27017
121+
# REDIS_PORT=6379
122+
# REDIS_PASSWORD=secure_redis_password_change_me
123+
# MONGO_PASSWORD=secure_mongo_password_change_me
124+
# JWT_SECRET=super-secure-jwt-secret-change-me
125+
# ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
126+
# DEV_VOLUME_MOUNT=/dev/null
127+
# DEV_NODE_MODULES_MOUNT=/dev/null

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es2022": true,
5+
"jest": true
6+
},
7+
"extends": ["eslint:recommended"],
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": "latest",
11+
"sourceType": "module"
12+
},
13+
"plugins": ["@typescript-eslint"],
14+
"rules": {
15+
"@typescript-eslint/no-unused-vars": "error",
16+
"@typescript-eslint/no-explicit-any": "warn",
17+
"@typescript-eslint/explicit-function-return-type": "off",
18+
"@typescript-eslint/explicit-module-boundary-types": "off",
19+
"@typescript-eslint/no-inferrable-types": "off",
20+
"prefer-const": "error",
21+
"no-var": "error",
22+
"no-unused-vars": "off"
23+
},
24+
"ignorePatterns": ["dist/", "node_modules/", "docker/"]
25+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Environment (please complete the following information):**
27+
28+
- OS: [e.g. Ubuntu 20.04]
29+
- Node.js version: [e.g. 18.17.0]
30+
- Docker version: [e.g. 24.0.0]
31+
- Project version: [e.g. 1.0.0]
32+
33+
**Additional context**
34+
Add any other context about the problem here.
35+
36+
**Logs**
37+
Please include relevant logs:
38+
39+
```
40+
Paste logs here
41+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.
20+
21+
**Implementation considerations**
22+
If you have ideas about how this could be implemented, please share them here.

.github/pull_request_template.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Description
2+
3+
Brief description of what this PR does.
4+
5+
## Type of Change
6+
7+
- [ ] Bug fix (non-breaking change which fixes an issue)
8+
- [ ] New feature (non-breaking change which adds functionality)
9+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10+
- [ ] Documentation update
11+
- [ ] Refactoring (no functional changes)
12+
- [ ] Performance improvement
13+
- [ ] Security enhancement
14+
15+
## Testing
16+
17+
- [ ] I have added tests that prove my fix is effective or that my feature works
18+
- [ ] New and existing unit tests pass locally with my changes
19+
- [ ] I have tested the Docker containers
20+
- [ ] I have tested the API endpoints
21+
22+
## Security Checklist (for security-related changes)
23+
24+
- [ ] No sensitive data is exposed in logs
25+
- [ ] Input validation is properly implemented
26+
- [ ] Docker containers run with minimal privileges
27+
- [ ] Authentication/authorization is maintained
28+
29+
## Documentation
30+
31+
- [ ] I have updated the README.md if needed
32+
- [ ] I have updated the API documentation
33+
- [ ] I have added/updated code comments where necessary
34+
35+
## Screenshots (if applicable)
36+
37+
Add screenshots to help explain your changes.
38+
39+
## Additional Notes
40+
41+
Any additional information that reviewers should know.

.github/workflows/ci.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x]
16+
17+
services:
18+
mongodb:
19+
image: mongo:7
20+
ports:
21+
- 27017:27017
22+
redis:
23+
image: redis:7-alpine
24+
ports:
25+
- 6379:6379
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node.js ${{ matrix.node-version }}
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ matrix.node-version }}
35+
cache: 'yarn'
36+
37+
- name: Install dependencies
38+
run: yarn install --frozen-lockfile
39+
40+
- name: Run type checking
41+
run: yarn typecheck
42+
43+
- name: Run linting
44+
run: yarn lint
45+
46+
- name: Run tests
47+
run: yarn test:coverage
48+
env:
49+
NODE_ENV: test
50+
MONGO_URI: mongodb://localhost:27017/rce_test
51+
REDIS_HOST: localhost
52+
REDIS_PORT: 6379
53+
JWT_SECRET: test_secret_key_for_ci
54+
55+
- name: Upload coverage reports
56+
uses: codecov/codecov-action@v3
57+
with:
58+
token: ${{ secrets.CODECOV_TOKEN }}
59+
file: ./coverage/lcov.info
60+
61+
docker:
62+
runs-on: ubuntu-latest
63+
needs: test
64+
65+
steps:
66+
- name: Checkout repository
67+
uses: actions/checkout@v4
68+
69+
- name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v3
71+
72+
- name: Build Docker images
73+
run: |
74+
yarn build:executors
75+
docker compose -f docker-compose.yml build
76+
77+
- name: Test Docker containers
78+
run: |
79+
ENV=test docker compose up -d
80+
sleep 30
81+
docker compose ps
82+
ENV=test docker compose down
83+
84+
security:
85+
runs-on: ubuntu-latest
86+
needs: test
87+
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v4
91+
92+
- name: Setup Node.js
93+
uses: actions/setup-node@v4
94+
with:
95+
node-version: '20.x'
96+
cache: 'yarn'
97+
98+
- name: Install dependencies
99+
run: yarn install --frozen-lockfile
100+
101+
- name: Run security audit
102+
run: yarn audit --audit-level moderate
103+
104+
- name: Run Snyk security scan
105+
uses: snyk/actions/node@master
106+
env:
107+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
108+
with:
109+
args: --severity-threshold=medium

0 commit comments

Comments
 (0)