revanth-3995/rl-devsecops-openenv-test
0
RL-Based DevSecOps OpenEnv Environment
๐ Overview
This project implements a DevSecOps simulation environment compatible with OpenEnv for reinforcement learning-based security decision-making.
It simulates a CI/CD pipeline where an agent performs security-related actions such as detecting secrets, triaging vulnerabilities, and making deployment decisions based on risk levels.
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ RL Agent / Policy โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ action
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DevSecOps Gym Env โ
โ (task + severity state) โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ reward + next state
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAPI Server (app.py) โ
โ /reset /step /state โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ HTTP
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Hugging Face Space (Docker)โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๐ Project Structure
devsecops_env.py: Core Gymnasium environment defining state, actions, and rewards for the DevSecOps simulation.app.py: FastAPI application exposing the environment via HTTP endpoints (/reset,/step,/state).inference.py: Dummy inference script to demonstrate how an agent interacts with the environment.openenv.yaml: OpenEnv metadata specification.Dockerfile: Containerizes the FastAPI server for easy deployment (e.g., Hugging Face Spaces).
๐ง Tasks Implemented
1. Secret Scanning
- Detect exposed credentials in code
- Actions:
DETECT,REPORT,APPROVE
2. CVE Triage
- Analyze vulnerability severity and prioritize fixes
- Actions:
BLOCK,PATCH,ESCALATE,APPROVE
3. Pipeline Security Audit
- Multi-stage decision-making across pipeline stages
- Actions:
BLOCK,PATCH,ESCALATE,APPROVE,ROLLBACK
โ๏ธ Action Space
["DETECT", "REPORT", "BLOCK", "PATCH", "ESCALATE", "APPROVE", "ROLLBACK"]๐ Observation Space
{
"task": "int (0โ2)",
"severity": "float (1โ10)"
}๐ ๏ธ Installation & Usage
1. Local Setup
Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
pip install -r requirements.txt2. Running FastAPI Server
The application exposes a REST API to interact with the environment:
uvicorn app:app --host 0.0.0.0 --port 7860Endpoints:
POST /reset: Resets the environment state.POST /step: Takes an action (e.g.,{"action": 0}) and returns the next state, reward, and done flag.GET /state: Retrieves the current state.
3. Running Dummy Inference
Test the environment locally using the dummy agent:
python inference.py4. Docker Deployment
You can also run this environment via Docker:
docker build -t devsecops-env .
docker run -p 7860:7860 devsecops-env