Hệ thống SOC (Security Operations Center) độc lập, có khả năng giám sát an ninh mạng thời gian thực cho các website/backend thông qua phân tích log từ AWS CloudWatch.
┌─────────────────────────┐
│ Existing Web Backend │
│ (Node.js + Express) │
└────────────┬────────────┘
│ Security Logs (JSON)
▼
┌─────────────────────────┐
│ AWS CloudWatch Logs │
└────────────┬────────────┘
│ Log Stream
▼
┌─────────────────────────┐
│ Log Subscription Filter │
└────────────┬────────────┘
│ Trigger
▼
┌─────────────────────────┐
│ AWS Lambda Function │
│ - Log Analyzer │
│ - Rule Detection │
│ - Severity Classification │
│ - Deduplication │
└────────────┬────────────┘
│
├──► PostgreSQL (RDS)
│ - Users, Roles, Alerts
│ - Rules, Logs
│
└──► DynamoDB (Optional)
- Realtime Alerts
│
▼
┌─────────────────────────┐
│ AWS API Gateway │
│ - REST API │
│ - WebSocket API │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ SOC Dashboard │
│ (React + TypeScript) │
│ - Realtime Alerts │
│ - Analytics │
│ - User Management │
└─────────────────────────┘
SOC-Systems/
├── backend/ # Backend Lambda Functions
│ ├── lambdas/
│ │ ├── log-analyzer/ # Main log analyzer
│ │ ├── api-handler/ # REST API handler
│ │ ├── websocket-handler/ # WebSocket connections
│ │ └── alert-processor/ # Alert processing
│ ├── shared/
│ │ ├── models/ # Database models
│ │ ├── rules/ # Detection rules
│ │ ├── utils/ # Utilities
│ │ └── types/ # TypeScript types
│ ├── infrastructure/
│ │ ├── cloudformation/ # CF templates
│ │ └── terraform/ # Terraform configs
│ └── package.json
├── frontend/ # React Dashboard
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── stores/ # Zustand stores
│ │ ├── api/ # API clients
│ │ ├── hooks/ # Custom hooks
│ │ ├── utils/ # Utilities
│ │ ├── types/ # TypeScript types
│ │ └── App.tsx
│ ├── public/
│ └── package.json
├── database/
│ ├── schema.sql # Database schema (3NF)
│ ├── migrations/ # Migration scripts
│ └── seeds/ # Seed data
├── docs/
│ ├── API.md # API documentation
│ ├── DEPLOYMENT.md # Deployment guide
│ └── ARCHITECTURE.md # Architecture details
└── README.md
- AWS Lambda - Node.js 18
- AWS API Gateway - REST + WebSocket
- AWS CloudWatch - Log collection
- AWS IAM - Authentication & Authorization
- PostgreSQL (RDS) - Primary database
- DynamoDB - Realtime alerts (optional)
- TypeScript - Type safety
- JWT - Authentication tokens
- React 18 - UI framework
- TypeScript - Type safety
- Tailwind CSS - Styling
- React Router v6 - Routing
- Zustand - State management
- React Query - API data fetching
- Recharts - Charts & analytics
- WebSocket - Realtime updates
- Tổng số cảnh báo theo ngày
- Phân bố theo mức độ nghiêm trọng
- Xu hướng 24h (biểu đồ)
- Top IP tấn công
- Thời gian phản hồi TB
- Danh sách alerts realtime
- Filter theo severity, status, source
- Trạng thái: NEW, ACKNOWLEDGED, IN_PROGRESS, RESOLVED
- Assign alerts cho analysts
- Export CSV/JSON
- Quản lý nguồn log (CloudWatch, Syslog, Azure Monitor)
- Tạo/sửa/xóa rule phát hiện
- Bật/tắt rules
- Test rule với sample data
- Rule templates
- Email gateway
- Slack integration
- SMS gateway
- Webhook
- Phân phối theo severity
- Role-based access control (RBAC)
- 3 roles: Admin, Analyst, Viewer
- Phân quyền chi tiết
- MFA support
- Audit trail
- Tra cứu log gốc
- Export reports
- Alert statistics
- Compliance reports
- Audit logs
- Điều kiện: LOGIN_FAILED ≥ 5 lần / 1 phút
- Severity: HIGH / CRITICAL
- Action: Alert + Block IP (optional)
- Điều kiện: ADMIN_LOGIN event
- Severity: HIGH
- Action: Alert + Notification
- Điều kiện: Log chứa
SELECT,UNION,DROP,--,OR 1=1 - Severity: CRITICAL
- Action: Immediate alert + Block
- Điều kiện: ≥ 20 requests 404 từ 1 IP / 1 phút
- Severity: MEDIUM
- Action: Alert + Monitor
- Điều kiện: Outbound traffic > 1GB
- Severity: HIGH
- Action: Alert + Investigate
- Điều kiện: User role change hoặc
sudocommand - Severity: CRITICAL
- Action: Immediate alert
users- User accountsroles- User rolespermissions- System permissionsrole_permissions- Role-permission mappingalert_sources- Log sourcesseverity_levels- Severity definitionsalert_status- Alert statusesanalysis_rules- Detection rulesalerts- Security alertslog_events- Raw logsalert_history- Audit trailnotification_channels- Notification confignotification_rules- Notification routingnotification_history- Notification logsaudit_logs- System audit
v_alert_stats_by_severity- Alert statisticsv_top_attacking_ips- Top attacking IPsv_alert_timeline_hourly- Hourly alert trends
Chạy nhanh với dữ liệu mẫu:
# Windows
start-demo.bat
# Hoặc thủ công:
# Terminal 1
cd backend && npm install && npm run demo
# Terminal 2
cd frontend && npm install && npm run devTruy cập: http://localhost:3000
Login: admin / Admin@123
Xem QUICKSTART.md và DEMO-GUIDE.md để biết thêm chi tiết.
- Node.js 18+
- AWS Account
- PostgreSQL 14+
- AWS CLI configured
# Create database
createdb soc_system
# Run schema
psql -d soc_system -f database/schema.sql
# Run migrations (if any)
npm run migratecd backend
npm install
npm run build
# Deploy Lambda functions
npm run deploy:devcd frontend
npm install
# Development
npm run dev
# Production build
npm run buildSee docs/DEPLOYMENT.md for detailed AWS setup including:
- CloudWatch Logs subscription
- Lambda function deployment
- API Gateway configuration
- IAM roles & policies
# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=soc_system
DB_USER=postgres
DB_PASSWORD=your_password
# JWT
JWT_SECRET=your_secret_key
JWT_EXPIRES_IN=24h
# AWS
AWS_REGION=ap-southeast-1
CLOUDWATCH_LOG_GROUP=/aws/lambda/soc-analyzer
# WebSocket
WEBSOCKET_API_ENDPOINT=wss://your-api-id.execute-api.region.amazonaws.com/prodVITE_API_BASE_URL=https://your-api-gateway.com/prod
VITE_WEBSOCKET_URL=wss://your-websocket-api.com/prodPOST /api/auth/login
POST /api/auth/logout
POST /api/auth/refresh
GET /api/auth/me
GET /api/alerts
GET /api/alerts/:id
PATCH /api/alerts/:id/acknowledge
PATCH /api/alerts/:id/assign
PATCH /api/alerts/:id/resolve
GET /api/alerts/stats
GET /api/rules
POST /api/rules
PUT /api/rules/:id
DELETE /api/rules/:id
PATCH /api/rules/:id/toggle
GET /api/users
POST /api/users
PUT /api/users/:id
DELETE /api/users/:id
GET /api/logs
GET /api/logs/export
wss://your-api/prod
- Connection: JWT in query string
- Events: alert.new, alert.updated, system.status
# Backend
cd backend
npm test
npm run test:coverage
# Frontend
cd frontend
npm test
npm run test:e2eWebsite backend cần gửi log theo format:
{
"timestamp": "2025-01-01T10:15:30Z",
"service": "WebBackend",
"event": "LOGIN_FAILED",
"username": "admin",
"ip": "203.0.113.10",
"path": "/api/login",
"status": 401,
"message": "Invalid password",
"user_agent": "Mozilla/5.0...",
"request_id": "uuid-here"
}| Level | Value | Color | Description |
|---|---|---|---|
| INFO | 1 | Blue | Thông tin |
| LOW | 2 | Green | Bất thường nhẹ |
| MEDIUM | 3 | Yellow | Nguy cơ |
| HIGH | 4 | Orange | Tấn công rõ ràng |
| CRITICAL | 5 | Red | Sự cố nghiêm trọng |
- Database schema
- Backend Lambda functions
- REST API
- WebSocket API
- Basic frontend
- Advanced rule engine
- Machine learning detection
- Threat intelligence integration
- Automated response (SOAR)
- Multi-tenant support
- Compliance reporting
- Integration marketplace
- Mobile app
MIT License - See LICENSE file for details
- Admin User - admin@cybersec.vn
For issues and questions:
- Email: admin@cybersec.vn
- Documentation:
/docs - GitHub Issues: [Create Issue]
Version: 2.1.0-alpha
Last Updated: December 2025