Skip to content

d4kw1n/S4E

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

S4E - Security Platform for Enterprise

Nền tảng quản lý bảo mật cho doanh nghiệp với các tính năng:

  • Quản lý lỗ hổng bảo mật (Vulnerability Management)
  • Công cụ DAST (Dynamic Application Security Testing)
  • Công cụ SAST (Static Application Security Testing)
  • Quản lý vòng đời lỗ hổng (Vulnerability Lifecycle)
  • Quản lý Compliance (SOC 2, PCI/DSS, ISO 27001)

Cấu trúc dự án

/app
├── /core           # Config, Security, Database connection
├── /api            # API Endpoints (FastAPI routers)
│   ├── /auth       # Login, Register
│   ├── /tenants    # CRUD Tenant, Project
│   ├── /vulns      # Vulnerability Management
│   └── /compliance # Compliance Mapping
├── /worker         # Celery workers
│   ├── /agents     # AI Agent Logic (LangGraph)
│   ├── /mcp_server # Các tool wrappers (NmapWrapper, FfufWrapper)
│   └── /parsers    # Đọc output XML/JSON của tool chuyển về DB
├── /models         # SQLModel models
└── /services       # Business Logic

Cài đặt

Option 1: Docker Compose (Recommended)

Cách đơn giản nhất để chạy toàn bộ stack (Backend + Frontend + Database + Redis):

# Build và chạy tất cả services
docker-compose up -d

# Xem logs
docker-compose logs -f

# Dừng tất cả services
docker-compose down

Sau khi chạy, truy cập:

Lưu ý: Khi backend khởi động lần đầu, hệ thống sẽ tự động tạo Super Admin account. Xem logs để lấy password:

docker-compose logs backend | grep "Super Admin Password"

Option 2: Manual Setup

Backend

  1. Tạo virtual environment:
python -m venv venv
source venv/bin/activate  # Linux/Mac
# hoặc
venv\Scripts\activate  # Windows
  1. Cài đặt dependencies:
pip install -r requirements.txt
  1. Tạo file .env từ .env.example và cấu hình:
cp env.example .env
# Chỉnh sửa .env với thông tin database, Redis, etc.
  1. Chạy migrations (nếu cần):
alembic revision --autogenerate -m "Initial migration"
alembic upgrade head
  1. Chạy server:
python run.py
# hoặc
uvicorn app.main:app --reload

Lưu ý: Khi server khởi động lần đầu, hệ thống sẽ tự động:

  • Khởi tạo database và tạo các tables
  • Tạo tài khoản Super Admin với thông tin:
    • Email: admin@s4e.com
    • Username: admin
    • Password: Sẽ được tạo ngẫu nhiên và hiển thị trong log

Quan trọng: Hãy lưu lại password Super Admin được hiển thị trong log khi deploy!

  1. Chạy Celery worker (terminal khác):
celery -A app.worker.celery_app worker --loglevel=info
# hoặc
python run_worker.py

Frontend

  1. Cài đặt dependencies:
cd frontend
npm install
  1. Chạy development server:
npm run dev

Frontend sẽ chạy tại http://localhost:3000

  1. Build production:
npm run build

API Documentation

Sau khi chạy server, truy cập:

Frontend

Frontend được xây dựng với React + Vite + Ant Design. Xem chi tiết trong frontend/README.md

Development

cd frontend
npm install
npm run dev

Production Build

cd frontend
npm run build

Frontend sẽ được serve qua Nginx trong Docker container.

Cấu trúc API

Authentication

  • POST /api/auth/register - Đăng ký user mới
  • POST /api/auth/login - Đăng nhập
  • GET /api/auth/me - Lấy thông tin user hiện tại

Users (Super Admin / Tenant Admin)

  • GET /api/users/ - Danh sách users
  • GET /api/users/{id} - Chi tiết user
  • POST /api/users/ - Tạo user mới
  • PUT /api/users/{id} - Cập nhật user
  • DELETE /api/users/{id} - Xóa user (Chỉ Super Admin)
  • PUT /api/users/{id}/password - Đổi password cho user

Tenants

  • POST /api/tenants/ - Tạo tenant (Super Admin)
  • GET /api/tenants/ - Danh sách tenants
  • GET /api/tenants/{id} - Chi tiết tenant
  • PUT /api/tenants/{id} - Cập nhật tenant
  • DELETE /api/tenants/{id} - Xóa tenant (Super Admin)

Projects

  • POST /api/projects/ - Tạo project
  • GET /api/projects/ - Danh sách projects
  • GET /api/projects/{id} - Chi tiết project
  • POST /api/projects/{id}/targets - Tạo target trong project
  • GET /api/projects/{id}/targets - Danh sách targets

Vulnerabilities

  • POST /api/vulns/ - Tạo vulnerability
  • GET /api/vulns/ - Danh sách vulnerabilities
  • GET /api/vulns/{id} - Chi tiết vulnerability
  • PUT /api/vulns/{id} - Cập nhật vulnerability
  • POST /api/vulns/{id}/verify - Verify vulnerability (Pentester)
  • POST /api/vulns/{id}/mark-fixed - Mark as fixed (Developer)
  • GET /api/vulns/{id}/lifecycle - Lịch sử thay đổi trạng thái

Scan

  • POST /api/scan/targets/{id}/scan - Bắt đầu scan
  • GET /api/scan/tasks/{task_id}/status - Trạng thái scan task

Compliance

  • POST /api/compliance/ - Tạo compliance
  • GET /api/compliance/ - Danh sách compliances
  • POST /api/compliance/{id}/map-vulnerability - Map vulnerability với compliance

Testing

Chạy tests:

# Chạy tất cả tests
pytest

# Chạy với verbose output
pytest -v

# Chạy một file test cụ thể
pytest tests/test_auth.py

# Chạy với coverage
pytest --cov=app --cov-report=html

Xem chi tiết về tests trong tests/README.md

Roles

  • Super Admin: Quản trị toàn hệ thống, tạo Tenant, quản lý gói subscription
  • Tenant Admin: Quản lý project của công ty, thêm member, xem báo cáo
  • Tenant Developer/Ops: Xem lỗ hổng, cập nhật trạng thái fix
  • Pentester/Security Analyst: Vận hành công cụ scan, verify lỗ hổng, viết PoC
  • Auditor: Chỉ có quyền xem báo cáo Compliance (Read-only)

About

An integrated platform for security management and policy automation for businesses.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors