{"id":51602726,"url":"https://github.com/jacktheprogrammer/sentinel-ml-security-crag-agent","last_synced_at":"2026-07-11T23:01:30.341Z","repository":{"id":342171058,"uuid":"1173112333","full_name":"JackTheProgrammer/Sentinel-ML-security-CRAG-agent","owner":"JackTheProgrammer","description":"A CRAG agent crafted using Gemini, langgraph and python to audit the ML scripts before deploying in production level","archived":false,"fork":false,"pushed_at":"2026-03-18T18:04:32.000Z","size":3508,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-19T07:41:59.127Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JackTheProgrammer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-05T02:46:36.000Z","updated_at":"2026-03-18T18:04:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/JackTheProgrammer/Sentinel-ML-security-CRAG-agent","commit_stats":null,"previous_names":["jacktheprogrammer/sentinel-ml-security-crag-agent"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JackTheProgrammer/Sentinel-ML-security-CRAG-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackTheProgrammer%2FSentinel-ML-security-CRAG-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackTheProgrammer%2FSentinel-ML-security-CRAG-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackTheProgrammer%2FSentinel-ML-security-CRAG-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackTheProgrammer%2FSentinel-ML-security-CRAG-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JackTheProgrammer","download_url":"https://codeload.github.com/JackTheProgrammer/Sentinel-ML-security-CRAG-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackTheProgrammer%2FSentinel-ML-security-CRAG-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35377013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-11T02:00:05.354Z","response_time":104,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-11T23:01:29.075Z","updated_at":"2026-07-11T23:01:30.325Z","avatar_url":"https://github.com/JackTheProgrammer.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛡️ Sentinel-ML: Security-First Agentic CRAG\n\nAutonomous AI Agent System for Auditing ML Workflows via LangGraph \u0026 Corrective RAG.\n\n## 🔍 Overview\n\n**Sentinel-ML** is an intelligent security layer for the ML lifecycle. It doesn't just scan code; it understands the context of training, deployment, and inference scripts to intercept vulnerabilities before they reach production.\n\n## 🚀 Why Sentinel-ML?\n\nStandard LLMs often provide insecure code snippets or hallucinate outdated security patches. Sentinel-ML solves this by treating security as a Stateful Engineering Problem, not just a prompting task.\n\n### 🧠 Architecture \u0026 Logic\n\nSentinel-ML is not a simple wrapper. It uses a **Directed Acyclic Graph (DAG)** via LangGraph to manage the audit state:\n\n1. **Contextual Retrieval**: Proactively fetches framework-specific security signatures.\n2. **Corrective Grading**: Self-evaluates retrieved data quality (`GOOD`, `AMBIGUOUS`, `INCORRECT`).\n3. **Recursive Re-writing**: Dynamically optimizes queries to trigger targeted web searches when local knowledge is insufficient.\n4. **Final Security Audit**: The final reasoning gatekeeper against RCE, Model Poisoning, and Path Injection.\n\n## 📊 Agent flow\n\n### Node sequence\n\n![Agent Workflow Diagram](output/ml_security_audit_CRAG_workflow.png \"Agent Workflow Diagram\")\n\n### Internal execution flow\n\n![Agentic nodes flowchart](output/agentic_nodes_logic_sequence.png \"Agentic nodes flowchart\")\n\n## ⚡Demonstration\n\n**Problem**: Insecure model loading using `pickle` (Remote Code Execution risk).\n\n**Sentinel-ML Solution**: Seamless migration to high-performance, safe alternatives like `safetensors`.\n\n```python\nres = app.invoke({\n    \"question\": \"Find vulnerabilities in this model loading script and provide a secure, high-performance alternative.\",\n    \"vulnerable_code\": \"\"\"import pickle\n    import pandas as pd\n    def load_user_model(user_id):\n        # DANGEROUS: Loading model from untrusted user path\n        path = f\"models/{user_id}_model.pkl\"\n        with open(path, 'rb') as f:\n            model = pickle.load(f) # \u003c--- Potential RCE Vulnerability\n        return model\n    \"\"\",\n    \"query\": \"Find vulnerabilities in this model loading script and provide a secure, high-performance alternative.\",\n    \"web_docs\": [],\n    \"fixed_code_cost_reduced\": \"\",\n    \"entire_fixed_code\": \"\",\n    \"final_report\": None,\n    \"display_report\": \"\",\n    \"docs\": [],\n    \"good_docs\": [],\n    \"kept_strips\": [],\n    \"strips\": [],\n    \"refined_context\": \"\",\n    \"recommend_fix_only\": False,\n    \"verdict\": \" \",\n    \"reason\": \" \",\n    \"web_queries\": [],\n    \"fix_recommendations\": set()\n})\n\nprint(\"Fixed code with reduced computational cost:\\n\", res['fixed_code_cost_reduced'])\n```\n\n### Output\n\n```text\nFixed code with reduced computational cost:\nfrom pathlib import Path\nfrom safetensors.torch import load_file\n\ndef load_user_model(user_id):\n    # Optimized safe loading: uses zero-copy memory mapping via safetensors\n    # Minimalist path sanitization to reduce overhead\n    safe_id = Path(user_id).name\n    path = Path(\"models\") / f\"{safe_id}_model.safetensors\"\n\n    # load_file is significantly faster than pickle and inherently safe\n    return load_file(str(path))\n```\n\n## 🛠️ Key Capabilities\n\n- **Vulnerability Detection**: Identifies Data Leakage, Model Poisoning, and Adversarial Vectors.\n- **Best Practices Recommendations**: Uses CRAG to verify all recommendations against live web data.\n- **Automated Analysis**: Provides deep-dive security reports with zero manual intervention.\n- **Integration with CI/CD**: State-persistent logic designed for automated pipeline security gates.\n\n## 📦 Installation and setup\n\nTo use the Sentinel-ML Security CRAG AI-agent, follow these steps:\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/JackTheProgrammer/Sentinel-ML-security-CRAG-agent.git\n   ```\n\n2. Install the required dependencies:\n\n   ```bash\n    pip install -r configs/requirements.txt\n   ```\n\n3. Use the code from the jupyter notebook `notebooks/sentinel_ml_security_crag_demo.ipynb` to see the agent in action.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacktheprogrammer%2Fsentinel-ml-security-crag-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacktheprogrammer%2Fsentinel-ml-security-crag-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacktheprogrammer%2Fsentinel-ml-security-crag-agent/lists"}