oxide-sloc/oxide-sloc
GitHub: oxide-sloc/oxide-sloc
基于 Rust 的跨平台源代码行统计工具,符合 IEEE 1045-1992 标准,提供 CLI、Web UI、Git 历史浏览、多格式报告及 CI/CD 集成。
Stars: 0 | Forks: 0
# oxide-sloc
[](https://github.com/oxide-sloc/oxide-sloc/actions/workflows/ci.yml)
[](https://github.com/oxide-sloc/oxide-sloc/actions/workflows/release.yml)
[](https://github.com/oxide-sloc/oxide-sloc/actions/workflows/docker.yml)
[](https://github.com/oxide-sloc/oxide-sloc/releases/latest)
[](https://crates.io/crates/oxide-sloc)
[](./LICENSE)
**oxide-sloc** 是一个基于 Rust 的源代码行分析工具 —— 符合 IEEE 1045-1992 标准,远不止是一个行数计数器。
## 快速开始
```
bash scripts/install.sh # detects bundled binary or builds from vendor sources
bash scripts/run.sh # web UI at http://127.0.0.1:4317
```
| 平台 | 安装 | 启动 | LAN 服务器 |
|---|---|---|---|
| **Windows 10/11** (Git Bash) | `bash scripts/install.sh` | `bash scripts/run.sh` | `bash scripts/serve-server.sh` |
| **Linux — RHEL 8/9, Ubuntu, Debian** | `bash scripts/install.sh` | `bash scripts/run.sh` | `bash scripts/serve-server.sh` |
**网络要求:**
- **Windows** —— 不需要网络;`oxide-sloc.exe` 已包含在仓库根目录中。
- **安装了 Rust 的 Linux** —— 不需要网络;`vendor.tar.xz` 包含了所有 crate 源码,可实现完全离线构建。
- **未安装 Rust 的 Linux** —— 将 `dist/oxide-sloc-linux-x86_64.tar.gz` 放置在仓库旁边(不需要网络),或者在有 `curl` 的情况下运行 `bash scripts/install.sh --online` 从 GitHub 下载。
有关所有部署方式,请参阅 [`docs/airgap.md`](./docs/airgap.md)。
## 在局域网中托管
使 oxide-sloc 可以从同一网络上的任何设备访问。
**最快方式:**
```
bash scripts/serve-server.sh
```
自动生成 API 密钥,打印服务器可访问的每个 LAN 地址,并提供一个现成的 `curl` 测试命令。如果其他设备连接超时,说明你的防火墙拦截了端口 4317 —— 脚本会准确告诉你该运行什么命令,或者传递 `--open-firewall` 让它自动开放端口(在 Linux 上需要 `sudo`)。
**或者直接运行二进制文件:**
```
export SLOC_API_KEY=$(openssl rand -hex 32)
oxide-sloc serve --server # binds to 0.0.0.0:4317
```
然后在同一网络上的任何设备上打开 `http://<你的IP>:4317`(Linux 上使用 `hostname -I`,Windows 上使用 `ipconfig`)。
设置 API 密钥后,CLI/curl 调用方必须包含该密钥:
```
curl -H "Authorization: Bearer $SLOC_API_KEY" http://:4317/healthz
```
**防火墙(Linux):**
```
sudo ufw allow 4317/tcp # UFW
sudo firewall-cmd --add-port=4317/tcp --permanent # firewalld
```
在 Windows 上,出现提示时请允许 oxide-sloc 通过 Windows Defender 防火墙。
## 功能特性
- **CLI + Web UI** —— `analyze / report / diff / serve / send / init / git-scan / git-compare` 命令;引导式的 4 步 Web 流程,支持明暗主题和一键快速扫描
- **符合 IEEE 1045-1992 的物理 SLOC** —— 可配置的混合行策略、续行、编译器指令和块注释中的空行分类;符号计数(函数、类、变量、导入)
- **灵活的输出** —— 包含逐文件细分和语言图表的 HTML 报告;PDF、CSV 和 4 个工作表的 Excel 导出;重新渲染任何已保存的 JSON 结果
- **Git 集成** —— 用于分支/标签/提交的浏览器 UI,GitHub/GitLab/Bitbucket webhook 和轮询自动化,通过 git worktree 进行时间点比较,子模块细分
- **CI/CD 和集成** —— Jenkinsfile、GitHub Actions、GitLab CI;JSON 指标 API、SVG 徽章端点、可嵌入的 `
标签:crates.io, Docker, GitHub Actions, Git历史, HTML报告, IEEE 1045-1992, PDF报告, Python安全, Rust, SLOC计数器, TCP SYN 扫描, Web UI, 云安全监控, 代码分析工具, 代码度量, 代码统计, 可视化界面, 安全防御评估, 源码行分析, 研发效能, 离线安装, 网络流量审计, 自动笔记, 请求拦截, 通知系统, 静态分析