Skip to main content

Fail-fast configuration validation & environment drift detection for SAP landscapes

Project description

๐Ÿ›ก๏ธ sap-config-guard

Fail-fast configuration validation & environment drift detection for SAP landscapes

Python 3.8+ License: MIT


๐ŸŽฏ Problem

In almost every SAP project:

  • โŒ DEV / QA / PROD configs silently differ
  • โŒ Missing parameters cause runtime failures
  • โŒ Secure parameters fail only in PROD
  • โŒ No automated pre-deployment validation

๐Ÿ‘‰ SAP has no lightweight, open tool to catch this before deployment.


โœ… Solution

sap-config-guard is a CLI + library that:

  • โœ”๏ธ Validates SAP configuration files
  • โœ”๏ธ Detects missing / unused / invalid parameters
  • โœ”๏ธ Compares environments (DEV vs QA vs PROD)
  • โœ”๏ธ Fails builds before deployment
  • โœ”๏ธ Works outside SAP (CI/CD friendly)

๐Ÿš€ Quick Start

Installation

Option 1: PyPI (when published)

pip install sap-config-guard

Option 2: From source

git clone https://github.com/upendra-manike/sap-config-guard.git
cd sap-config-guard
pip install -e .

Option 3: Docker

docker pull sap-config-guard:latest
# Or build from source
docker build -t sap-config-guard:latest .

Basic Usage

1๏ธโƒฃ Validate Configuration

sap-config-guard validate ./config/dev

Output:

โŒ Missing required key: SAP_API_URL
โŒ Invalid pattern: SAP_CLIENT = 12 (expected pattern: ^[0-9]{3}$)
โš ๏ธ  Secure key missing or empty: SAP_PASSWORD

2๏ธโƒฃ Compare Environments

sap-config-guard diff dev=./config/dev qa=./config/qa prod=./config/prod

Output:

โš ๏ธ  Drift detected:

  โš ๏ธ  Key 'SAP_TIMEOUT' differs: dev=30, qa=30, prod=10
  โš ๏ธ  Key 'SAP_API_URL' differs: dev=http://localhost:8080, qa=https://qa.sap.com, prod=https://prod.sap.com
  โŒ Key 'SAP_CLIENT' missing in: qa

3๏ธโƒฃ Production Validation (Strict Mode)

sap-config-guard validate ./config/prod --environment prod --fail-on-warning

๐Ÿ“– Library API

Python

from sap_config_guard import validate, compare_environments

# Validate configuration
results, is_valid = validate(
    config_path="./config/prod",
    schema_path="./schema.yaml",  # optional
    environment="prod",
    fail_on_warning=True
)

for result in results:
    print(result)

# Compare environments
diff_results = compare_environments({
    "dev": "./config/dev",
    "qa": "./config/qa",
    "prod": "./config/prod"
})

for diff in diff_results:
    print(f"{diff.key}: {diff.message}")

๐Ÿ“ Supported File Formats

  • โœ… .env files
  • โœ… .properties files (Java-style)
  • โœ… .yaml / .yml files
  • โœ… .json files
  • โœ… Directory with multiple config files

๐Ÿ”ง Configuration Schema

Create a schema.yaml file to define validation rules:

required:
  - SAP_CLIENT
  - SAP_SYSTEM_ID
  - SAP_API_URL

secure:
  - SAP_PASSWORD
  - SAP_PRIVATE_KEY

patterns:
  SAP_CLIENT: "^[0-9]{3}$"
  SAP_API_URL: "^https://.*"

forbidden_in_prod:
  - mock
  - localhost
  - 127.0.0.1

min_lengths:
  SAP_PASSWORD: 8

๐Ÿงฉ Supported SAP Contexts

Area Supported
SAP BTP โœ…
SAP CPI / PI โœ…
MuleSoft โ†” SAP โœ…
CAP Apps โœ…
SAP Properties / YAML / JSON โœ…
ABAP exports (CSV/XML) โš ๏ธ (phase 2)

๐Ÿ” Built-in SAP Rules

  • โœ… No localhost in PROD
  • โœ… No hardcoded secrets
  • โœ… SAP client must be 3 digits
  • โœ… HTTPS enforced
  • โœ… Timeout sanity checks
  • โœ… Destination name validation

๐Ÿ–ฅ๏ธ CLI Reference

validate Command

sap-config-guard validate <config_path> [options]

Options:

  • --schema, -s: Path to schema YAML file
  • --environment, -e: Environment name (dev, qa, prod) - default: dev
  • --fail-on-warning: Treat warnings as errors

Examples:

# Basic validation
sap-config-guard validate ./config/dev

# Production validation with custom schema
sap-config-guard validate ./config/prod --environment prod --schema ./custom-schema.yaml

# Strict mode (fail on warnings)
sap-config-guard validate ./config/prod --environment prod --fail-on-warning

diff Command

sap-config-guard diff <env1>=<path1> [env2]=<path2> ... [options]

Options:

  • --show-same: Show keys that are the same across environments
  • --fail-on-drift: Exit with error code if drift is detected

Examples:

# Compare environments
sap-config-guard diff dev=./config/dev qa=./config/qa prod=./config/prod

# Positional arguments (auto-named as dev, qa, prod)
sap-config-guard diff ./config/dev ./config/qa ./config/prod

# Fail CI/CD on drift
sap-config-guard diff dev=./config/dev prod=./config/prod --fail-on-drift

๐Ÿ”„ CI/CD Integration

GitHub Actions

name: Validate SAP Config

on: [push, pull_request]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - run: pip install sap-config-guard
      - run: sap-config-guard validate ./config/prod --environment prod --fail-on-warning
      - run: sap-config-guard diff dev=./config/dev qa=./config/qa prod=./config/prod --fail-on-drift

Jenkins

stage('Validate Config') {
    steps {
        sh 'pip install sap-config-guard'
        sh 'sap-config-guard validate ./config/prod --environment prod --fail-on-warning'
    }
}

Docker in CI/CD

- name: Validate with Docker
  run: |
    docker run --rm \
      -v ${{ github.workspace }}/config:/app/configs:ro \
      sap-config-guard:latest \
      validate /app/configs/prod --environment prod --fail-on-warning

๐Ÿ“ˆ Roadmap

v0.1.0 (Current) โœ…

  • โœ… CLI
  • โœ… Config validation
  • โœ… Env diff
  • โœ… CI-friendly exit codes

v0.2.0 (Planned)

  • ๐Ÿ”„ CAP app support
  • ๐Ÿ”„ MuleSoft properties
  • ๐Ÿ”„ JSON/YAML schemas

v0.3.0 (Planned)

  • ๐Ÿ”„ ABAP export validation
  • ๐Ÿ”„ SAP transport pre-checks

v1.0.0 (Future)

  • ๐Ÿ”„ Java wrapper
  • ๐Ÿ”„ Plugin system
  • ๐Ÿ”„ SAP GenAI config advisor

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Built for the SAP community
  • Inspired by real-world production issues
  • Designed to be SAP-agnostic and CI/CD friendly

๐Ÿณ Docker Support

Full Docker support is available! See DOCKER.md for detailed usage.

# Quick start with Docker
docker run --rm \
  -v $(pwd)/config:/app/configs:ro \
  sap-config-guard:latest \
  validate /app/configs/prod

๐Ÿ“š Additional Documentation

๐Ÿ“ž Support


Made with โค๏ธ for the SAP community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sap_config_guard-0.1.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sap_config_guard-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file sap_config_guard-0.1.0.tar.gz.

File metadata

  • Download URL: sap_config_guard-0.1.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sap_config_guard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7c142314630dd464a6b52f93ad7ad1fdb4c78ce668e9d50aae2eaac27d895e5b
MD5 54862a9cdbdbd952874807e16b9a8637
BLAKE2b-256 5986ed134a793bda1f287eb6e467b69ed9f551259ac86ae3bbe0943820182ea1

See more details on using hashes here.

File details

Details for the file sap_config_guard-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sap_config_guard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 710c8d93a344b652abba4a4fb25e9d5c1feb34393cb3a51bcd8107e68b942996
MD5 11fa962ebca044b1089ca087b95079ab
BLAKE2b-256 b7efd0628c5a15cf466a996d6ff959b906cf8e1b5e4a156521e06b5c36828a84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page