GPL Radar is a powerful CLI tool designed to detect potential GPL license contamination in your codebase. It uses advanced algorithms (Rolling Hash + Winnowing) to identify code similarities even when variable names have been modified.
- 🎯 High Precision Detection: Rolling Hash + Winnowing algorithm identifies code similarity even with renamed variables
- ⚡ Fast Scanning: Single file scan time < 10ms
- 📊 Rich Reporting: Colorful terminal output with risk scores and matched code snippets
- 🔍 Pre-built Database: Built-in fingerprint database of Linux Kernel core code
- 🛠️ Multi-language Support: Python, C, JavaScript file scanning
# Clone the repository
git clone https://github.com/PerryLink/gpl-radar.git
cd gpl-radar
# Install in development mode
pip install -e ".[dev]"# Scan a single file
scan-gpl ./your_file.py
# Example output:
# 🛡️ GPL Radar Scan Results
# Risk Score: 85/100 ⚠️
# Matched: 3 code segments from Linux Kernelgpl-radar/
├── src/gpl_radar/ # Main source code
│ ├── cli.py # CLI entry point
│ ├── analyzer.py # Core algorithm implementation
│ ├── database.py # Fingerprint database management
│ ├── models.py # Data models
│ └── reporter.py # Terminal output formatting
├── tests/ # Test suite
│ ├── test_exact_match.py
│ └── test_renamed_vars.py
├── scripts/ # Utility scripts
│ └── generate_db.py # Database generation
├── data/ # Fingerprint database
│ └── linux_kernel_hashes.bin
├── pyproject.toml # Project configuration
├── README.md # This file
├── LICENSE # Apache 2.0 License
└── CONTRIBUTING.md # Contribution guidelines
- CLI Framework: Typer - Modern CLI framework
- Terminal UI: Rich - Beautiful terminal formatting
- Code Analysis: Pygments - Syntax highlighting and tokenization
- Testing: Pytest - Testing framework
- Code Style: Black - Code formatter
GPL Radar 是一个强大的 CLI 工具,用于检测代码中潜在的 GPL 协议污染。它使用高级算法(Rolling Hash + Winnowing)来识别代码相似性,即使在变量名被修改的情况下也能有效工作。
- 🎯 高精度检测: Rolling Hash + Winnowing 算法,即使变量被重命名也能识别代码相似性
- ⚡ 极速扫描: 单文件扫描时间 < 10ms
- 📊 丰富的报告: 彩色终端输出,包含风险分数和匹配的代码片段
- 🔍 预置数据库: 内置 Linux Kernel 核心代码指纹库
- 🛠️ 多语言支持: Python、C、JavaScript 文件扫描
# 克隆仓库
git clone https://github.com/PerryLink/gpl-radar.git
cd gpl-radar
# 以开发模式安装
pip install -e ".[dev]"# 扫描单个文件
scan-gpl ./your_file.py
# 示例输出:
# 🛡️ GPL Radar 扫描结果
# 风险分数: 85/100 ⚠️
# 匹配: 3 段来自 Linux Kernel 的代码gpl-radar/
├── src/gpl_radar/ # 主源代码
│ ├── cli.py # CLI 入口
│ ├── analyzer.py # 核心算法实现
│ ├── database.py # 指纹数据库管理
│ ├── models.py # 数据模型
│ └── reporter.py # 终端输出格式化
├── tests/ # 测试套件
│ ├── test_exact_match.py
│ └── test_renamed_vars.py
├── scripts/ # 实用脚本
│ └── generate_db.py # 数据库生成
├── data/ # 指纹数据库
│ └── linux_kernel_hashes.bin
├── pyproject.toml # 项目配置
├── README.md # 本文件
├── LICENSE # Apache 2.0 许可证
└── CONTRIBUTING.md # 贡献指南
- CLI 框架: Typer - 现代 CLI 框架
- 终端 UI: Rich - 美观的终端格式化
- 代码分析: Pygments - 语法高亮和词法分析
- 测试: Pytest - 测试框架
- 代码风格: Black - 代码格式化
本项目采用 Apache License 2.0 许可证。
欢迎提交 Issue 和 Pull Request!请查看 CONTRIBUTING.md 了解详细信息。
Made with ❤️ by PerryLink