Inspiration

GitLab SAST requires pipeline configuration and dumps findings into a security dashboard developers rarely check. Meanwhile, vulnerabilities slip through in code review because nobody wants to context-switch mid-review. Security should live where the review already happens.

What It Does

MR Risk Predictor requires zero pipeline setup. @mention it in any MR comment and in ~30 seconds it posts a structured security report directly in the MR conversation — exactly where the developer already is. It detects SQL injection, hardcoded secrets, XSS, missing auth, and 5 more vulnerability categories with exact file:line references and plain-English fixes.

It detects hardcoded secrets, SQL injection, XSS, missing authentication, plaintext passwords, and more - with exact file:line references and actionable fixes.

How I Built It

Built entirely on the GitLab Duo Agent Platform using:

  • agents/agent.yml - defines the AI agent, system prompt, and tools
  • flows/flow.yml - orchestrates the two-step workflow: fetch MR context → analyze → post comment
  • build_review_merge_request_context - fetches the MR diff automatically
  • create_merge_request_note - posts the structured security report back to the MR

No external APIs. No extra cost. Works natively for any GitLab user out of the box.

Challenges I ran into

The biggest challenge was schema validation — the validator revealed required fields one at a time, so every CI/CD run exposed a new missing field (routers -> toolset -> prompt_id -> unit_primitives). It took many iterations to get the YAML exactly right.

The agent also had a looping problem where it would call create_merge_request_note repeatedly instead of once. Solving this required tuning the prompt instructions and component type carefully.

Accomplishments that I'm proud of

  • Agent detects 8+ vulnerability categories with exact line numbers
  • Output is consistently structured every single time
  • Zero context switching - the report lives on the MR where developers already are
  • Published to GitLab AI Catalog and accessible via @mention in any MR comment
  • No external APIs - runs entirely on GitLab Duo natively

What I Learned

  • How to build and publish agents and flows on the GitLab Duo Agent Platform
  • How ambient context works (and when it doesn't)
  • How to debug AI agent behavior through prompt engineering
  • The importance of schema validation in AI platform configs

What's next for MR Risk Predictor

  • Auto-trigger on every MR open - no manual mention needed
  • Severity scoring with a risk score out of 10
  • Re-scan after fixes are pushed to verify vulnerabilities are resolved
  • Integration with GitLab security dashboard

Built With

  • agent
  • ai
  • api
  • build-review-merge-request-context
  • ci/cd
  • create-merge-request-note
  • duo
  • gitlab
  • platform
  • python
  • yaml
Share this project:

Updates