Skip to content

redhat-data-and-ai/naysayer

Repository files navigation

πŸ›‘οΈ Naysayer - GitLab Automation Platform

A multi-purpose GitLab webhook service that automates merge request validation, repository maintenance, and workflow optimization.

🎯 Smart Automation: Validates MRs, maintains repositories, and keeps projects clean

πŸš€ What Naysayer Does

Naysayer provides three core capabilities through webhook endpoints:

1. πŸ“‹ MR Validation & Auto-Approval (/dataverse-product-config-review)

  • βœ… Auto-approves safe changes (cost reductions, compliant configurations)
  • ⚠️ Flags for review risky changes (cost increases, security violations)
  • πŸ” Validates file content against organizational policies
  • πŸ“ Documents decisions with clear reasoning

2. πŸ”„ Fivetran Terraform Auto-Rebase (/fivetran-terraform-rebase)

  • πŸ”€ Automatically rebases Fivetran terraform repository MRs
  • ⚑ Reduces merge conflicts through proactive rebasing
  • πŸ€– Streamlines workflows for infrastructure-as-code

3. 🧹 Stale MR Cleanup (/stale-mr-cleanup)

  • πŸ—‘οΈ Closes stale MRs (30+ days old)
  • πŸ“Š Maintains clean project state across repositories
  • πŸ”„ Stateless, pull-based design (repos opt-in via CI)

πŸ›‘οΈ Validation Rules

Naysayer includes built-in rules for:

  • 🏒 Cost Control - Warehouse configuration validation
  • πŸ”’ Security - Service account compliance
  • πŸ‘₯ Access Management - Consumer access auto-approval (NEW!)
  • βš–οΈ TOC Approval - TOC oversight for production deployments
  • πŸ“„ Documentation - Metadata and docs validation

πŸ“š Complete Rule Details: See Rules Documentation for what gets validated, troubleshooting, and examples.

πŸ—οΈ How It Works

Naysayer uses Section-Based Validation Architecture for granular, configurable rule processing:

graph TD
    A[πŸ“₯ GitLab MR] --> B[πŸ“„ File Analysis]
    B --> C{Section-Based Config?}
    C -->|Yes| D[🧩 YAML Section Parsing]
    C -->|No| E[πŸ“ Traditional Validation]
    
    D --> F[Extract File Sections]
    F --> G[Section 1: warehouses]
    F --> H[Section 2: service_account]
    F --> I[Section N: custom]
    
    G --> J[🏒 Apply warehouse_rule]
    H --> K[πŸ”’ Apply service_account_rule]
    I --> L[🎯 Apply section rules]
    
    E --> M[Apply all rules to file]
    
    J --> N{All Sections Valid?}
    K --> N
    L --> N
    M --> O{All Rules Pass?}
    
    N -->|βœ… All sections pass| P[πŸŽ‰ Auto-Approve MR]
    N -->|❌ Section failures| Q[πŸ” Manual Review Required]
    O -->|βœ… All rules pass| P
    O -->|❌ Rule failures| Q
    
    classDef startEnd fill:#e1f5fe,stroke:#01579b,stroke-width:2px,color:#000
    classDef process fill:#f3e5f5,stroke:#4a148c,stroke-width:2px,color:#000
    classDef decision fill:#fff3e0,stroke:#e65100,stroke-width:2px,color:#000
    classDef section fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px,color:#000
    classDef rule fill:#fff8e1,stroke:#f57f17,stroke-width:2px,color:#000
    classDef success fill:#e8f5e8,stroke:#388e3c,stroke-width:3px,color:#000
    classDef review fill:#ffebee,stroke:#d32f2f,stroke-width:2px,color:#000
    
    class A,P startEnd
    class B,D,E,F,M process
    class C,N,O decision
    class G,H,I section
    class J,K,L rule
    class P success
    class Q review
Loading

πŸ†• Section-Based Features:

  • 🎯 Granular Control: Rules target specific YAML sections (e.g., warehouses, service_account.dbt)
  • 🧩 Configurable Mapping: Rules and sections defined in rules.yaml configuration
  • πŸ“Š Coverage Tracking: Ensures all sections are validated by appropriate rules
  • πŸ”§ Modular Validation: Different rules can validate different sections of the same file
  • πŸ“ Enhanced Reporting: Section-by-section validation results with line-level detail

πŸš€ Quick Start

1. Deploy Naysayer

# Deploy to Kubernetes/OpenShift
kubectl apply -f config/

# Or run locally for development
export GITLAB_TOKEN=glpat-xxxxxxxxxxxxxxxxxxxx
make build && make run

2. Configure GitLab Webhook

  1. Go to GitLab project β†’ Settings β†’ Webhooks
  2. Add URL: https://your-naysayer-domain.com/webhook
  3. Select "Merge request events"
  4. Save configuration

3. Test It

Create an MR with configuration changes and Naysayer will automatically validate and provide feedback.

Result: Safe changes get auto-approved, risky changes get flagged for review

βš™οΈ Configuration

Basic configuration via environment variables:

# Required
GITLAB_TOKEN=glpat-xxxxxxxxxxxxxxxxxxxx

# Optional
GITLAB_BASE_URL=https://gitlab.com
PORT=3000

# Rule toggles
WAREHOUSE_RULE_ENABLED=true

πŸ“– Complete Configuration: See Development Setup Guide for all rule-specific settings.

🎯 Auto-Approval Logic

βœ… When MRs Get Auto-Approved

Change Type Risk Level Auto-Approval Business Rationale
Documentation 🟒 Low βœ… Always Zero operational risk
Warehouse Reduction 🟒 Low βœ… Yes Cost savings (~$50k/month)
Service Account (Astro) 🟑 Medium βœ… Conditional Automated accounts with naming compliance
Warehouse Increase 🟑 Medium ❌ Never Requires budget approval
Service Account (Other) πŸ”΄ High ❌ Never Security review required
New Product (Prod) πŸ”΄ High ❌ Never Requires TOC governance approval

🚫 Manual Review Triggers

  • Cost Increases - Warehouse size increases require budget approval
  • New Production Deployments - New product.yaml files in preprod/prod require TOC approval
  • Security Violations - Hardcoded secrets, invalid domains
  • Configuration Errors - YAML syntax errors, missing fields
  • Uncovered Changes - Lines not validated by any rule

πŸ” Compliance Details: For complete audit trails, risk matrices, and compliance procedures, see detailed rule documentation.

πŸ“š Documentation

πŸ—οΈ Architecture

πŸ‘₯ For Users

πŸ‘¨β€πŸ’» For Developers

πŸš€ For Operators

πŸ› οΈ Development

Quick setup for developers:

# Clone and setup
git clone https://github.com/your-org/naysayer.git
cd naysayer && make install

# Run tests
make test

# Start development server
export GITLAB_TOKEN=your-token
make run

For complete development setup, testing guides, and project structure details, see the Development Guide.

πŸ”’ Security & Compliance

  • Minimal Permissions: GitLab token only needs read_repository scope
  • Audit Trail: All decisions logged with detailed reasoning
  • Input Validation: All webhook payloads validated
  • Policy Enforcement: Consistent application of organizational standards

🎯 Benefits

  • ⚑ Faster Reviews: Safe changes approved automatically
  • πŸ›‘οΈ Risk Reduction: Automated detection of policy violations
  • πŸ“ Consistency: Uniform application of organizational standards
  • πŸ” Transparency: Clear explanations for all decisions

πŸš€ Deployment

Naysayer deployment configs are maintained in this repository (/config/).

Quick Deploy

# Deploy from this repository
kubectl apply -f config/

For complete setup: See Deployment Guide

Health Check: GET /health

🀝 Contributing

  1. Read Rule Creation Guide
  2. Follow development guidelines and patterns
  3. Update documentation in docs/rules/

πŸš€ Ready to get started?

About

A framework for building bots that can handle Gitlab webhook events and act on it.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 8

Languages