A fast and configurable tool for scanning file trees, detecting forbidden expressions, and refining exclusion rules
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Florian Schade d1afc4e1bd
Merge pull request #3 from opencloud-eu/ignored-files-issue-md-report
enhancement: list ignored files in the issue-md report
2025-02-11 18:04:04 +01:00
.github chore: setup github labels 2025-02-06 14:00:44 +01:00
assets Initial commit 2025-01-30 17:40:06 +01:00
cmd/dbrand fix: ignored match results and config dir overwrite 2025-02-05 13:07:07 +01:00
examples enhancement: support exclusion of new, used and unused processors for the config gen cmd 2025-02-05 11:38:53 +01:00
fixtures enhancement: support exclusion of new, used and unused processors for the config gen cmd 2025-02-05 11:38:53 +01:00
pkg enhancement: list ignored files in the issue-md report 2025-02-06 14:14:24 +01:00
vendor enhancement: speed up processing by using routines, add ignoreExpression processor 2025-02-03 10:58:04 +01:00
.gitignore Initial commit 2025-01-30 17:40:06 +01:00
go.mod enhancement: speed up processing by using routines, add ignoreExpression processor 2025-02-03 10:58:04 +01:00
go.sum enhancement: speed up processing by using routines, add ignoreExpression processor 2025-02-03 10:58:04 +01:00
LICENSE Initial commit 2025-01-30 17:40:06 +01:00
README.md enhancement: support exclusion of new, used and unused processors for the config gen cmd 2025-02-05 11:38:53 +01:00

dbrand

dbrand is a powerful tool for scanning file trees to find occurrences of definable patterns. It is designed to efficiently process large file structures while allowing for flexible exclusion rules.

Features

  • IgnorePath – Exclude specific files or directories from scanning.
  • IgnoreLineRange – Skip certain line ranges within files.
  • IgnoreTextRange – Ignore specific text ranges within a row.
  • IgnoreExpression – Ignore specific expressions within a row.
  • Configurable Infection Detection – Define custom patterns to identify occurrences that need to be reported.

Why Use dbrand?

When working with large codebases or documentation repositories, dbrand helps identify and report unwanted patterns, such as branding references in forks of open-source software. It provides:

  • Efficient scanning using nested globbing for both file traversal and exclusion rules.
  • Pattern-based detection of occurrences that need modification.
  • Configurable exclusion rules to fine-tune what should and shouldn't be detected.

How It Works

dbrand produces two types of reports:

  1. Summary Report

    • Provides detailed metrics on detected patterns.
    • Includes skipped occurrences based on configured exclusions.
  2. Configuration Generation

    • Builds a new configuration based on an existing configuration and detected occurrences.
    • Useful for refining exclusion rules and improving detection accuracy.

Installation

git clone https://github.com/opencloud-eu/dbrand.git
cd dbrand
go build -o bin/dbrand cmd/dbrand/*.go

Usage

Basic command to run dbrand:

bin/dbrand config generate --config-path=examples/dbrand.clean.yaml

Example config.yaml:

---
expression: (?i)forbidden|dangerous
dir: ../fixtures
pattern: '**/*.{txt,yaml}' ## ignore go.sum
reports:
  issue-md:
    title: Violation report
    base: https://github.com/opencloud-eu/dbrand
    branch: main
  template:
    example: # use any key you want
      title: Example dbrand report
      header: Custom Template
processors:
  '**/*.txt':
    - type: IgnoreExpression
      expression: dangerous word # ignore dangerous if the word after it is `word`
      meta:
        reason: "meta can contain any key-value pair"
  '**/*_1.txt':
    - type: IgnorePath
  root_2.txt:
    - type: IgnoreLineRange
      from: 1
      to: 4
  root_3.txt:
    - type: IgnoreTextRange
      line: 1
      from: 0
      to: 9
    - type: IgnoreTextRange
      line: 3
      from: 0
      to: 9
    - type: IgnoreTextRange
      line: 4
      from: 0
      to: 9
  root_4.txt:
    - type: IgnoreExpression
      line: 1
      expression: forbidden
    - type: IgnoreExpression
      line: 3
      expression: forbidden
    - type: IgnoreExpression
      line: 4
      expression: forbidden
  root_[5,6].txt:
    - type: IgnoreExpression
      expression: forbidden
  sub/**:
    - type: IgnoreExpression
      expression: (?i)FORBIDDEN
      pattern: sub/*.yaml

Future Improvements

  • Additional reporting formats for better analysis.
  • Enhanced exclusion rule refinement for greater flexibility.
  • Potential for automated modifications in future versions.

License

This project is licensed under AGPL3 License.

Contributions

Contributions are welcome! Feel free to submit issues or pull requests to improve dbrand.

Contact

For more information, reach out via the GitHub Issues.