Skip to content

About

ConfigDoctor is a lightweight CLI tool that scans configuration files to detect missing variables, weak credentials, security risks, and performance issues using rule-based analysis. With support for multiple formats and output types, it integrates into development workflows and CI/CD pipelines to prevent misconfigurations before deployment

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ConfigDoctor

Enterprise-grade configuration file scanner that detects common problems.

ConfigDoctor is a lightweight CLI tool that scans configuration files (.env, .json, .yaml, .ini) to detect missing variables, dangerous defaults, security risks, and performance misconfigurations.

ConfigDoctor Scan Results

Key Features:

  • ✅ Fast & Local: No cloud, no API calls, runs entirely on your machine
  • 🔒 Security-First: Detects hardcoded secrets, weak credentials, CORS misconfigurations
  • 📋 Rule-Based: Clear, deterministic detection rules with transparent logic
  • 🎯 Minimal Dependencies: Lightweight and cross-platform (Windows, Linux, macOS)
  • 📊 Multiple Formats: Console output with colors and JSON for CI/CD pipelines
  • 🛠️ Extensible: Easy to add new rules via modular architecture

Installation

NPM (Recommended)

npm install -g configdoctor

From Source

git clone https://github.com/yourusername/configdoctor.git
cd configdoctor
npm install
npm run build
npm link  # Makes 'configdoctor' available globally

Quick Start

Scan Current Directory

configdoctor scan .

Scan Specific Directory

configdoctor scan ./backend

Output as JSON

configdoctor scan --format json

Strict Mode (Warnings = Errors)

configdoctor scan --strict

Get Help

configdoctor --help
configdoctor --version

CLI Usage

USAGE:
  configdoctor scan [PATH] [OPTIONS]

ARGUMENTS:
  PATH                  Path to scan (file or directory, default: current directory)

OPTIONS:
  --format <FORMAT>     Output format: console (default) or json
  --strict              Treat warnings as errors (exit with code 1)
  --help, -h            Show help message
  --version, -v         Show version information

Exit Codes

  • 0 - No issues found or only info-level issues
  • 1 - Critical issues found or warnings found in strict mode

Supported File Types

ConfigDoctor scans the following configuration file formats:

Format Pattern Example
dotenv .env* .env, .env.local, .env.example
JSON .json config.json, database.json
YAML .yaml, .yml config.yaml, docker-compose.yml
INI .ini app.ini, settings.ini

Detection Rules

ConfigDoctor uses deterministic, rule-based detection. Below is the complete list of checks:

🚨 Critical Issues

Missing Secrets

  • Empty passwords or secret values
  • Null or undefined database credentials
  • Missing API keys

Hardcoded Secrets

  • Potential API keys in config values
  • Database connection strings with credentials
  • AWS keys or tokens

Insecure CORS

  • CORS=* (wildcard origins)
  • ALLOW_ALL_ORIGINS=true

Insecure Protocols

  • Database URLs using http:// instead of https://
  • Unencrypted database connections

Weak Credentials

  • Default passwords like admin, password, 123456
  • Common test credentials

⚠️ Warnings

Debug Mode Enabled

  • DEBUG=true in production-like configs
  • dev_mode, debug_enabled set to true

Unbounded Connection Pools

  • Connection pool size set to unlimited or 0
  • No maximum connection limit specified

Missing Environment Variables

  • Variables in .env.example but not in .env

ℹ️ Info (Recommendations)

Performance Optimizations

  • Caching disabled when it should be enabled
  • Excessive logging (debug, trace, verbose levels)
  • Compression disabled
  • Keep-alive disabled
  • Very high timeout values

Rule Descriptions

1. Missing Variables Rule

Triggers when:

  • A variable exists in .env.example but is missing in .env

Example:

.env.example:
DATABASE_URL=postgres://...
API_KEY=sk-...
.env (missing API_KEY)
DATABASE_URL=postgres://...

Message: Missing environment variable: API_KEY
Recommendation: Add API_KEY to your .env file.


2. Bad Defaults Rule

Triggers when:

  • Debug mode is enabled (DEBUG=true)
  • Weak passwords detected (admin, password, 123456)
  • Empty secrets ("", null, undefined)

Examples:

# ❌ Weak password
DB_PASSWORD=admin

# ❌ Debug enabled
DEBUG=true

# ❌ Empty secret
API_KEY=

Recommendations: Use strong credentials, disable debug mode, provide non-empty values.


3. Security Risks Rule

Triggers when:

  • Potential hardcoded secrets detected
  • Insecure URLs (http:// for sensitive endpoints)
  • CORS misconfigured
  • Overly permissive settings

Examples:

{
  "database_url": "http://localhost:5432/mydb",
  "cors": "*",
  "api_key": "sk-1234567890abcdefghij"
}

Recommendations:

  • Use https:// for sensitive URLs
  • Specify explicit allowed origins for CORS
  • Store secrets in environment variables, not config files

4. Performance Issues Rule

Triggers when:

  • Caching is disabled
  • Excessive logging enabled
  • Compression disabled
  • Unbounded connection pools
  • Very high timeout values

Examples:

cache:
  enabled: false
  
logging:
  level: debug
  
compression:
  enabled: false
  
connection_pool:
  max_size: unlimited

Recommendations: Enable caching, reduce log verbosity, enable compression, set connection limits.


Output Examples

Console Output

ConfigDoctor Scan Results

❌ CRITICAL ISSUES (2)

  config.json
  Rule: security-risks
  Message: Insecure protocol in database_url: http://localhost:5432/mydb
  Recommendation: Use HTTPS/WSS instead of HTTP/WS for database_url

  .env
  Rule: bad-defaults
  Message: Weak default password detected: DB_PASSWORD=admin
  Recommendation: Use a strong, unique password. Never use default or weak credentials.

⚠  WARNING ISSUES (1)

  .env
  Rule: missing-variables
  Message: Missing environment variable: SECRET_KEY
  Recommendation: Add SECRET_KEY to your .env file. See .env.example for reference.

Summary
--------
Total files scanned: 2
Critical issues: 2
Warnings: 1
Info: 0
Total: 3

✗ Critical issues found. Please fix them before deploying.

JSON Output

configdoctor scan --format json
{
  "timestamp": "2024-01-18T10:30:45.123Z",
  "scannedFiles": ["config.json", ".env"],
  "issues": [
    {
      "severity": "critical",
      "file": "config.json",
      "rule": "security-risks",
      "message": "Insecure protocol in database_url: http://localhost:5432/mydb",
      "recommendation": "Use HTTPS/WSS instead of HTTP/WS for database_url"
    }
  ],
  "summary": {
    "critical": 1,
    "warning": 1,
    "info": 0,
    "total": 2
  }
}

CI/CD Integration

GitHub Actions

name: Config Check
on: [push, pull_request]

jobs:
  config:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install -g configdoctor
      - run: configdoctor scan . --strict

GitLab CI

config_check:
  image: node:18
  script:
    - npm install -g configdoctor
    - configdoctor scan . --strict

Jenkins

pipeline {
  stages {
    stage('Config Check') {
      steps {
        sh '''
          npm install -g configdoctor
          configdoctor scan . --strict
        '''
      }
    }
  }
}

Development

Prerequisites

  • Node.js 18+
  • npm or yarn

Setup

git clone https://github.com/yourusername/configdoctor.git
cd configdoctor
npm install

Build

npm run build

Output goes to dist/ directory.

Development Mode

npm run dev -- scan .

Uses ts-node for live TypeScript compilation.

Lint & Format

npm run lint      # Run ESLint
npm run format    # Run Prettier

Testing

npm test

Architecture

ConfigDoctor is organized into modular components:

src/
├── cli.ts              # CLI entry point and argument parsing
├── scanner.ts          # Main scanning orchestrator
├── types.ts            # TypeScript type definitions
├── parsers/            # Config file parsers
│   ├── index.ts
│   ├── env.parser.ts
│   ├── json.parser.ts
│   ├── yaml.parser.ts
│   └── ini.parser.ts
├── rules/              # Detection rules
│   ├── engine.ts
│   ├── missing-variables.rule.ts
│   ├── bad-defaults.rule.ts
│   ├── security-risks.rule.ts
│   ├── performance-issues.rule.ts
│   └── index.ts
└── reporters/          # Output formatters
    ├── console.reporter.ts
    ├── json.reporter.ts
    └── index.ts

Key Concepts

  • Parser: Reads and normalizes different config file formats into a common data structure
  • Rule: Checks a parsed config against a specific detection pattern
  • RuleEngine: Orchestrates all rules against a config
  • Reporter: Formats results for display (console or JSON)
  • Scanner: Finds config files, parses them, runs rules, and aggregates results

Adding Custom Rules

To add a new detection rule:

  1. Create a new file in src/rules/ (e.g., custom-check.rule.ts)
  2. Implement the Rule interface:
import { Rule, ParsedConfig, DiagnosticIssue } from "../types";

export class CustomCheckRule implements Rule {
  name = "custom-check";
  description = "Detects custom configuration problems";

  check(config: ParsedConfig): DiagnosticIssue[] {
    const issues: DiagnosticIssue[] = [];

    // Your detection logic here
    if (config.data.someKey === "badValue") {
      issues.push({
        severity: "warning",
        file: config.file,
        rule: this.name,
        message: "Some configuration is wrong",
        recommendation: "Fix it by doing X",
      });
    }

    return issues;
  }
}
  1. Register the rule in src/rules/engine.ts:
import { CustomCheckRule } from "./custom-check.rule";

constructor() {
  this.rules = [
    // ... existing rules
    new CustomCheckRule(),
  ];
}

Security Disclaimer

ConfigDoctor detects common configuration patterns but is not a complete security solution. It:

✅ Will detect:

  • Missing environment variables
  • Weak default passwords
  • Obvious hardcoded secrets (patterns)
  • Common misconfigurations

❌ Will NOT detect:

  • Sophisticated obfuscated secrets
  • Business logic vulnerabilities
  • Network-level security issues
  • Dynamic/runtime security problems

Always:

  • Use this tool as part of a broader security strategy
  • Have sensitive files reviewed by humans
  • Use dedicated secret management tools (HashiCorp Vault, AWS Secrets Manager, etc.)
  • Conduct regular security audits
  • Follow principle of least privilege

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Write clear, commented code
  4. Add tests for new rules
  5. Ensure all tests pass (npm test)
  6. Submit a pull request

Areas for Contribution

  • New detection rules
  • Additional file format support (HCL, TOML, etc.)
  • Better error messages
  • Performance improvements
  • Documentation improvements

License

MIT License - see LICENSE file for details.


Support & Issues


Changelog

v1.0.0 (2024-01-18)

  • Initial release
  • Support for .env, .json, .yaml, .ini files
  • 4 core detection rule categories
  • Console and JSON output formats
  • CLI with strict mode
  • Cross-platform support

ConfigDoctor: Treat your configs like a senior engineer reviews them. 🏥

About

ConfigDoctor is a lightweight CLI tool that scans configuration files to detect missing variables, weak credentials, security risks, and performance issues using rule-based analysis. With support for multiple formats and output types, it integrates into development workflows and CI/CD pipelines to prevent misconfigurations before deployment

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages