💡 Inspiration

This project started because I went down a rabbit hole trying to understand how enterprise file scanning is actually engineered under the hood. I was reading a breakdown by Apiiro about a massive malicious code campaign using GitHub repository confusion attacks, and it clicked for me: traditional static application security testing (SAST) tools are fundamentally flawed against modern supply-chain attacks. They rely on rigid regex patterns and keyword matching, which just creates alert fatigue. They don't understand the intent of the code.

I want to build a startup that develops highly niche, intelligent security products. GuardAgent is my first step toward that—bridging the gap between rapid CI/CD pipelines and rigorous security by building an AI gate that actually reasons about code like a Senior DevSecOps Engineer.

⚙️ What it does

GuardAgent.ai is an autonomous, event-driven security gate. Operating entirely within a developer's natural GitLab workflow, it intercepts every git push in real-time. Moving beyond standard chatbot wrappers, it autonomously fetches the commit diff, performs deep semantic threat hunting, and posts actionable, prioritized remediation reports directly back to the commit history as formatted Markdown.

Inspired by real-world attack vectors, it specifically targets complex supply-chain vulnerabilities, including:

  • Dependency confusion and typosquatting (the exact attacks I was researching).
  • Context-aware credential harvesting (e.g., catching dummy glpat- tokens).
  • Obfuscated payloads (Base64, hex-encoded).

📲 How I built it

To build this as a true enterprise-grade system—and a foundation for a future niche product—I strictly decoupled the application routing from the cognitive AI logic.

  1. The Secure Bridge (Google Cloud Run): I built a highly scalable FastAPI application deployed on Cloud Run to act as the event dispatcher. It catches GitLab webhooks and cryptographically verifies the HMAC-SHA256 signatures using Google Secret Manager to ensure total zero-trust payload authenticity.
  2. The Brain (Google Cloud Agent Builder): Instead of manually managing LLM context windows in Python, I offloaded the cognitive load to Agent Builder, powered by Gemini 2.5 Flash. I engineered a strict Chain-of-Thought system prompt to force the agent to Deconstruct, Contextualize, and Threat Hunt.
  3. The Hands (GitLab MCP Server): To give the agent true autonomy, I integrated the official GitLab Model Context Protocol (MCP) directly into Agent Builder. This allows Gemini to dynamically invoke tools to read specific commits and write comments without hardcoding the API sequences.

To evaluate threats, the agent conceptually calculates risk using a dynamic semantic matrix, which can be represented as:

$$\text{Risk Score} = \left( P_{exploit} \times I_{impact} \right) \times \mathcal{C}_{context}$$

Where $\mathcal{C}_{context}$ represents the deep semantic understanding uniquely provided by Gemini, allowing the agent to adjust scores based on variable naming, surrounding comments, and overall execution flow.

🚧 Challenges I ran into

My initial and most significant hurdle was simply getting the foundational architecture off the ground—writing the correct Python code for the routing process and figuring out exactly how to connect Google Cloud services to GitLab via webhooks. It took a lot of trial, error, and deep-dive research to finally understand how that event-driven handshake needed to work. From there, I was able to tackle the more advanced challenges: orchestrating the Model Context Protocol (MCP) within Agent Builder, managing the correct authentication scopes, and configuring the strict HMAC cryptographic validation to ensure the entire pipeline was zero-trust.

🏆 Accomplishments that I'm proud of

I am incredibly proud of the Agent's contextual reasoning capabilities. During live testing, I pushed a dummy GitLab Personal Access Token. The agent didn't just flag a generic string—it recognized the proprietary glpat- prefix, read the surrounding code comments indicating it was a "Fake API key," and still correctly flagged it as a high-risk behavioral vulnerability. It actually explained that hardcoding any secret pattern is a dangerous precedent in a production environment.

📚 What I learned

Building this showed the connection between the Model Context Protocol when paired with Agent Builder. By moving the LLM prompt and tool orchestration into Google's native AI infrastructure, the Python app became a pure, ultra-fast event dispatcher.

🚀 What's next for GuardAgent.ai

This hackathon project is the foundation for my niche cybersecurity startup. With the core Agent Builder pipeline laid, the next step is expanding the Agent's MCP toolbelt to integrate Slack and Jira. I want to build this out so GuardAgent not only blocks malicious commits in GitLab but autonomously pages the on-call security team and opens prioritized remediation tickets, creating a fully automated DevSecOps lifecycle.

Built With

  • docker
  • fastapi
  • gemini-2.5-flash
  • gitlab
  • google-cloud
  • google-cloud-agent-builder
  • google-cloud-run
  • google-secret-manager
  • mcp
  • model-context-protocol
  • python
  • webhooks
Share this project:

Updates