Skip to content

Global File Exclusion for Sensitive Content #201

@butschster

Description

@butschster

Add a global configuration option to exclude sensitive files from being included in any context document, with seamless integration of existing .gitignore patterns to leverage established exclusion rules.

Proposed Solution

Configuration Structure

Add a new top-level exclude section with an option to respect .gitignore files:

$schema: https://raw.githubusercontent.com/context-hub/generator/refs/heads/main/json-schema.json

# Global exclusion patterns
exclude:
  # File patterns to exclude globally
  patterns:
    - "**/.env*"
    - "**/config/secrets.yaml"
    - "**/*.pem"
    - "**/*.key"
    - "**/id_rsa"
    - "**/credentials.json"
  
  # Paths to exclude globally
  paths:
    - ".secrets/"
    - "config/credentials/"
    
  # GitIgnore integration
  gitignore:
    enabled: true                    # Whether to respect .gitignore files
    paths:                           # Optional: specific .gitignore files to use
      - ".gitignore"                 # Project root .gitignore
      - "submodules/**/.gitignore"   # Submodule .gitignore files
    ignoreGlobalGitignore: false     # Whether to ignore global .gitignore files

# Regular configuration continues
documents:
  - description: "Project Documentation"
    outputPath: "docs/project.md"
    # ...

Implementation Plan

  1. GitIgnore Integration:

    • Parse and respect .gitignore files throughout the project
    • Support hierarchical .gitignore rules (parent directories, subdirectories)
    • Parse global .gitignore files when applicable
  2. Exclusion Priority:

    • Global explicit exclusions (highest priority)
    • Document-level explicit exclusions
    • .gitignore patterns (respecting hierarchy)
    • Source-specific exclusions
  3. Configuration Options:

    • Toggle .gitignore support
    • Specify additional .gitignore files to respect
    • Option to ignore global .gitignore files
  4. Performance Optimization:

    • Cache parsed .gitignore rules for better performance
    • Optimize path matching algorithms for large codebases
  5. CLI Support:

    • Add a global flag to enable/disable .gitignore integration
    • Allow specifying additional exclusions via command line

Benefits

  1. Leverage Existing Patterns: Reuse carefully crafted .gitignore patterns that already exclude sensitive files
  2. Consistency with Git Workflows: Files excluded from Git are likely candidates for exclusion from context
  3. No Duplication Required: Avoids having to maintain two separate sets of exclusion patterns
  4. Project-Specific Adaptability: Respects the granular .gitignore rules that may exist in complex projects

Example Use Cases

  1. A development team can instantly leverage their extensive .gitignore configuration without additional setup
  2. Organizations can combine global security policies (in CTX config) with project-specific exclusions (.gitignore)
  3. New projects get immediate protection from credential exposure by using standard .gitignore templates

Metadata

Metadata

Assignees

Labels

config:loaderConfigLoader component for parsing and validating config filesenhancementNew feature or requestsourcesNew source type for data retrieval

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions