coderabbit-security-basics

0
0
Source

Apply CodeRabbit security best practices for secrets and access control. Use when securing API keys, implementing least privilege access, or auditing CodeRabbit security configuration. Trigger with phrases like "coderabbit security", "coderabbit secrets", "secure coderabbit", "coderabbit API key security".

Install

mkdir -p .claude/skills/coderabbit-security-basics && curl -L -o skill.zip "https://mcp.directory/api/skills/download/8424" && unzip -o skill.zip -d .claude/skills/coderabbit-security-basics && rm skill.zip

Installs to .claude/skills/coderabbit-security-basics

About this skill

CodeRabbit Security Basics

Overview

Configure CodeRabbit to catch security vulnerabilities, hardcoded secrets, and insecure patterns in pull requests. CodeRabbit's AI review can detect security issues that static analysis tools miss because it understands code context and intent. This skill covers security-focused configuration, secret detection instructions, and compliance-oriented review policies.

Prerequisites

  • CodeRabbit installed on repository
  • .coderabbit.yaml in repository root
  • Understanding of security requirements for your codebase

Security Coverage

CategoryCodeRabbit DetectionComplementary Tool
Hardcoded secretsPath instructions + AI detectionGitHub Secret Scanning, GitLeaks
SQL injectionPath instructions for DB codeSonarCloud, Semgrep
XSS vulnerabilitiesPath instructions for frontendESLint security plugins
Auth bypassPath instructions for auth codeManual review
Insecure dependenciesLimited (reviews import patterns)Dependabot, Renovate
OWASP Top 10Path instructions covering each riskDedicated SAST tools

Instructions

Step 1: Configure Security-Focused Review

# .coderabbit.yaml - Security-hardened configuration
language: "en-US"

reviews:
  profile: "assertive"
  request_changes_workflow: true    # Block merge on security findings

  auto_review:
    enabled: true
    drafts: false
    base_branches: [main, develop]

  # Exclude secrets files from AI processing
  path_filters:
    - "!**/.env*"
    - "!**/credentials*"
    - "!**/secrets*"
    - "!**/*.pem"
    - "!**/*.key"
    - "!**/*.p12"
    - "!**/*.pfx"
    - "!**/serviceAccountKey*"
    - "!**/terraform.tfstate*"
    - "!**/*.tfvars"
    - "!**/*.lock"
    - "!dist/**"
    - "!vendor/**"

  path_instructions:
    # Global security rules
    - path: "**"
      instructions: |
        SECURITY REVIEW: Flag any of these as HIGH severity:
        - Hardcoded API keys, tokens, passwords, or connection strings
        - AWS access keys (AKIA...), GCP service account keys
        - Private keys or certificates in source code
        - JWT secrets or signing keys
        - Database credentials in code (not env vars)
        - Webhook URLs with tokens in query parameters
        - Disabled SSL/TLS verification
        - eval() or equivalent dynamic code execution

    # API security
    - path: "src/api/**"
      instructions: |
        API security checks:
        - Input validation: all request parameters validated before use
        - Authentication: auth middleware on all non-public endpoints
        - Authorization: proper role/permission checks
        - Rate limiting: endpoints have rate limits configured
        - Error responses: no stack traces or internal details exposed
        - CORS: properly configured, not wildcard (*)
        - SQL injection: parameterized queries only, no string concat

    # Authentication code
    - path: "src/auth/**"
      instructions: |
        CRITICAL SECURITY PATH. Review for:
        - Password hashing: bcrypt or argon2 ONLY (flag MD5, SHA-1, SHA-256)
        - Token expiry: access tokens < 1 hour, refresh tokens < 30 days
        - Session fixation: new session ID after authentication
        - CSRF protection: anti-CSRF tokens on state-changing operations
        - Brute force protection: account lockout or rate limiting on login
        - No timing attacks in comparison (use constant-time comparison)

    # Database code
    - path: "src/db/**"
      instructions: |
        Database security checks:
        - Parameterized queries ONLY (flag any string concatenation in SQL)
        - No sensitive data in error messages (e.g., full query text)
        - Connection strings from env vars (not hardcoded)
        - Principle of least privilege for DB user accounts
        - Transactions for multi-step operations

    # CI/CD pipelines
    - path: ".github/workflows/**"
      instructions: |
        CI/CD security checks:
        - Pin ALL action versions to SHA commit hash (not tags)
        - No secrets in step names, echo statements, or log output
        - Include timeout-minutes on all jobs
        - Use OIDC for cloud provider auth (not long-lived keys)
        - No curl | sh patterns (supply chain risk)
        - Restrict workflow permissions to minimum required

    # Infrastructure as code
    - path: "**/*.tf"
      instructions: |
        Terraform security:
        - No hardcoded credentials or access keys
        - S3 buckets: encryption enabled, public access blocked
        - Security groups: no 0.0.0.0/0 ingress except port 443
        - RDS/databases: encryption at rest enabled, no public access
        - IAM roles: least privilege, no wildcard (*) actions

    # Docker
    - path: "**/Dockerfile"
      instructions: |
        Container security:
        - No secrets in ENV or ARG instructions
        - Use specific image tags (not :latest)
        - Run as non-root user (USER instruction)
        - Multi-stage builds to reduce attack surface
        - No sensitive files copied into image

chat:
  auto_reply: true

Step 2: Secret Detection with GitHub Integration

# .github/workflows/security-review.yml
name: Security Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  secret-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Scan for secrets in PR diff
        run: |
          # Check PR diff for common secret patterns
          DIFF=$(git diff origin/${{ github.base_ref }}...HEAD)
          PATTERNS=(
            "AKIA[0-9A-Z]{16}"           # AWS access key
            "(?i)(api[_-]?key|apikey)\s*[:=]\s*['\"][^'\"]{16,}"   # API keys
            "(?i)(password|passwd|pwd)\s*[:=]\s*['\"][^'\"]{8,}"   # Passwords
            "ghp_[a-zA-Z0-9]{36}"         # GitHub PAT
            "sk-[a-zA-Z0-9]{48}"          # OpenAI key
            "-----BEGIN.*PRIVATE KEY"     # Private keys
          )

          FOUND=0
          for PATTERN in "${PATTERNS[@]}"; do
            if echo "$DIFF" | grep -qP "$PATTERN"; then
              echo "::error::Potential secret found matching pattern: $PATTERN"
              FOUND=1
            fi
          done

          if [ "$FOUND" -eq 1 ]; then
            echo "::error::Secret-like patterns detected in PR. Review before merging."
            exit 1
          fi

Step 3: Security Review Learnings

# Train CodeRabbit to catch your team's specific security patterns:

# In a PR comment, reply to a CodeRabbit review:
"Good catch! We always want to flag missing CSRF tokens in POST handlers."

"We use Helmet.js for security headers. If you see an Express route
without `app.use(helmet())`, flag it as a security issue."

"In this project, all database queries must go through the QueryBuilder class.
Direct SQL strings are a security violation."

# These learnings persist across PRs and repos in the organization.

Step 4: Security Audit Script

set -euo pipefail
echo "=== CodeRabbit Security Configuration Audit ==="

# Check .coderabbit.yaml for security settings
if [ -f .coderabbit.yaml ]; then
  python3 -c "
import yaml

config = yaml.safe_load(open('.coderabbit.yaml'))
reviews = config.get('reviews', {})
path_filters = reviews.get('path_filters', [])
path_instructions = reviews.get('path_instructions', [])

# Check if sensitive files are excluded
sensitive_patterns = ['.env', '.pem', '.key', 'credentials', 'secrets', 'tfstate', 'tfvars']
excluded = [p for p in path_filters if any(s in p for s in sensitive_patterns)]
print(f'Sensitive file exclusions: {len(excluded)}/{len(sensitive_patterns)} patterns')

# Check if security instructions exist
security_keywords = ['security', 'injection', 'credential', 'secret', 'auth', 'password']
has_security = any(
    any(kw in str(pi.get('instructions', '')).lower() for kw in security_keywords)
    for pi in path_instructions
)
print(f'Security path_instructions: {\"YES\" if has_security else \"MISSING\"} ')

# Check if request_changes_workflow blocks on issues
blocks = reviews.get('request_changes_workflow', False)
print(f'Blocks merge on issues: {\"YES\" if blocks else \"NO (consider enabling)\"}')

# Check auto_review settings
auto = reviews.get('auto_review', {})
print(f'Drafts reviewed: {\"YES (risky)\" if auto.get(\"drafts\", True) else \"NO (good)\"}')
" 2>&1
else
  echo "WARNING: .coderabbit.yaml not found"
fi

Output

  • Security-focused .coderabbit.yaml with path instructions for critical code areas
  • Secret detection patterns in CI pipeline
  • CodeRabbit learnings trained for team-specific security rules
  • Security configuration audit script
  • Merge blocking enabled for security findings

Error Handling

IssueCauseSolution
Secrets not flaggedNo security path_instructionsAdd global ** instruction for secret patterns
False positive on test dataTest fixtures contain mock secretsAdd !**/fixtures/** to path_filters
Security finding ignoredrequest_changes_workflow: falseSet to true to block merge
Too many security commentsOverly broad instructionsFocus instructions on specific paths
Secret in reviewed diffFile not in exclusion listAdd pattern to path_filters

Resources

Next Steps

For production deployment, see coderabbit-prod-checklist.

svg-icon-generator

jeremylongshore

Svg Icon Generator - Auto-activating skill for Visual Content. Triggers on: svg icon generator, svg icon generator Part of the Visual Content skill category.

8227

d2-diagram-creator

jeremylongshore

D2 Diagram Creator - Auto-activating skill for Visual Content. Triggers on: d2 diagram creator, d2 diagram creator Part of the Visual Content skill category.

4926

automating-mobile-app-testing

jeremylongshore

This skill enables automated testing of mobile applications on iOS and Android platforms using frameworks like Appium, Detox, XCUITest, and Espresso. It generates end-to-end tests, sets up page object models, and handles platform-specific elements. Use this skill when the user requests mobile app testing, test automation for iOS or Android, or needs assistance with setting up device farms and simulators. The skill is triggered by terms like "mobile testing", "appium", "detox", "xcuitest", "espresso", "android test", "ios test".

14217

performing-penetration-testing

jeremylongshore

This skill enables automated penetration testing of web applications. It uses the penetration-tester plugin to identify vulnerabilities, including OWASP Top 10 threats, and suggests exploitation techniques. Use this skill when the user requests a "penetration test", "pentest", "vulnerability assessment", or asks to "exploit" a web application. It provides comprehensive reporting on identified security flaws.

4615

designing-database-schemas

jeremylongshore

Design and visualize efficient database schemas, normalize data, map relationships, and generate ERD diagrams and SQL statements.

11514

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

11410

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,1421,171

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

969933

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

683829

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

691549

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

797540

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

697374

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.