mirror of
https://github.com/opencloud-eu/dbrand.git
synced 2026-11-16 23:05:03 +00:00
A fast and configurable tool for scanning file trees, detecting forbidden expressions, and refining exclusion rules
- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .github | ||
| assets | ||
| cmd/dbrand | ||
| examples | ||
| fixtures | ||
| pkg | ||
| vendor | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| README.md | ||
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:
-
Summary Report
- Provides detailed metrics on detected patterns.
- Includes skipped occurrences based on configured exclusions.
-
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.