manojisnow/laria

GitHub: manojisnow/laria

专为 Java 项目设计的 Docker 化纵深防御安全扫描器,整合 10 余款行业工具实现从源码到容器的全链路安全审计。

Stars: 0 | Forks: 0

Laria Logo
# 🛡️ Laria Security Scanner **针对 Java 项目的全面安全扫描,采用纵深防御方法** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Docker](https://img.shields.io/badge/docker-ready-blue.svg)](https://www.docker.com/) [![Security](https://img.shields.io/badge/security-scanning-green.svg)](https://github.com/manojisnow/laria) ## 概述 Laria 是一个基于 Docker 的安全扫描器,为 Java 项目和容器化应用程序提供全面的安全分析。它集成了 10 多种行业标准的安全工具,用于检测跨多个层面的漏洞: - **Secrets Detection** - 查找硬编码的凭据和 API keys - **SAST** - 静态应用程序安全测试 - **Dependency Scanning** - 识别易受攻击的依赖项 - **IaC Security** - 扫描基础设施即代码文件 - **Container Scanning** - 分析 Docker 镜像中的漏洞 - **Helm Chart Security** - 扫描 Kubernetes Helm charts - **Dockerfile Linting** - 容器镜像的最佳实践 - **Dependency Consistency** - 检测版本冲突和菱形依赖 ## 特性 ✅ **10+ Security Tools** - Gitleaks, Semgrep, SpotBugs, Trivy, Checkov, Hadolint, Grype, Kubescape, Kubeaudit, Helm, Syft ✅ **Multi-Layer Scanning** - Secrets, SAST, Dependencies, IaC, Containers, Helm Charts, Linting ✅ **Container Image Scanning** - Trivy & Grype 用于已构建的 Docker 镜像 ✅ **Helm Chart Security** - Kubescape, Kubeaudit, Helm lint, 和 Trivy 用于 Kubernetes 部署 ✅ **Dependency Consistency** - 通过 SBOM 分析检测菱形依赖和版本冲突 ✅ **SBOM Generation** - 通过 Syft 生成软件物料清单,以实现供应链可见性 ✅ **Beautiful Reports** - HTML, Markdown, 和 JSON 格式,附带修复指南 ✅ **Fast Scans** - 通过并行执行,约 2.5 分钟即可完成全面分析 ✅ **CI/CD Ready** - 包含 GitHub Actions workflow ✅ **Docker-based** - 无需安装本地工具 ✅ **Remote Repository Support** - 直接从 GitHub/GitLab URLs 进行扫描 ✅ **Smart Builds** - 自动构建 Maven/Gradle 项目 & Dockerfiles 以进行更深入的分析 ✅ **Formatted Output** - 整洁的表格,而非原始 JSON ✅ **Configurable Severity** - 可自定义阈值和失败严重级别 ✅ **Executive Summary** - 为利益相关者提供的高层级概览 ## 安装 ### 选项 1: Docker (推荐) 无需安装!只需拉取并运行容器: ``` docker pull dumanoj/laria:latest docker run --rm -v $(pwd):/repo dumanoj/laria:latest /repo ``` ### 选项 2: 独立安装 直接在您的系统 上安装 Laria 和所有工具: ``` curl -sfL https://raw.githubusercontent.com/manojisnow/laria/main/install.sh | bash ``` 这会将所有内容安装到 `~/.laria`(与您的系统隔离): - 工具位于 `~/.laria/bin` - Python venv 位于 `~/.laria/venv` **用法:** 将 bin 目录添加到您的 PATH: ``` export PATH="$HOME/.laria/bin:$PATH" ``` 然后运行: ``` laria /path/to/repo ``` ### 卸载 要彻底移除 Laria: ``` curl -sfL https://raw.githubusercontent.com/manojisnow/laria/main/uninstall.sh | bash ``` 这只会删除 `~/.laria` 目录。不会触碰其他文件。 ## 快速入门 ### 1. 拉取或构建 Docker 镜像 **选项 A: 从 Docker Hub 拉取 (推荐)** ``` docker pull dumanoj/laria:latest ``` **选项 B: 从源码构建** ``` git clone https://github.com/manojisnow/laria.git cd laria docker build -t laria:latest . ``` ### 2. 扫描一个仓库 ``` # 使用扫描脚本(最简单) ./scan-repo.sh /path/to/your/repository # 或者直接使用 Docker # 如果你从 Docker Hub 拉取,使用:dumanoj/laria:latest # 如果你在本地构建,使用:laria:latest docker run --rm \ --tmpfs /tmp:rw,exec,size=4g \ -v /path/to/repo:/path/to/repo \ -v $(pwd)/reports:/laria/reports \ dumanoj/laria:latest /path/to/repo ``` ### 3. 查看报告 ``` # 打开 HTML 报告 open reports/laria_report_*.html # 或者查看 Markdown 报告 cat reports/laria_report_*.md ``` ## 集成工具 | Tool | Purpose | What it Finds | |------|---------|---------------| | **Gitleaks** | Secrets Detection | API keys, passwords, tokens | | **Semgrep** | SAST | SQL injection, XSS, code vulnerabilities | | **SpotBugs** | SAST (Java) | Null pointers, resource leaks, security bugs | | **Trivy** | Dependencies + IaC + Containers | CVEs, vulnerable packages, misconfigurations | | **Grype** | Container Scanning | Container image vulnerabilities | | **Checkov** | IaC Security | Dockerfile, K8s, Terraform issues | | **Hadolint** | Dockerfile Linting | Best practices, security issues | | **Kubescape** | Kubernetes Security | K8s misconfigurations, compliance checks | | **Kubeaudit** | Kubernetes Auditing | Security policy violations | | **Helm** | Helm Chart Linting | Chart validation and best practices | | **Syft** | SBOM Generation | Software Bill of Materials, dependency analysis | ## 报告格式 Laria 生成三种报告格式: ### HTML 报告 - 美观的格式化表格 - 颜色编码的严重级别 - 可点击的 CVE 链接 - 执行摘要 ### Markdown 报告 - GitHub 兼容 - 针对所有发现的清晰表格 - 易于阅读和分享 ### JSON 报告 - 机器可读 - 用于 CI/CD 集成的完整数据 - 程序化分析 ## 示例输出 ``` 🛡️ Laria Security Scanner Starting... ⏰ Scan started at: 2025-12-06 22:36:51 📦 Step 1: Repository Management Using local repository: /path/to/example-project 🔍 Step 2: Artifact Detection Found artifacts: • dockerfiles: 3 item(s) • build_files: 4 item(s) • jar_files: 2 item(s) 🔨 Step 3: Building Artifacts 🐳 Building Docker images... ☕ Building Java projects... 🔐 Step 4: Source Code Security Scanning 🔑 Running secrets detection... 🐛 Running static application security testing... 📚 Running dependency vulnerability scanning... ☁️ Running infrastructure-as-code scanning... 📊 Step 6: Generating Reports ✓ JSON report: reports/laria_report_20251206_223919.json ✓ HTML report: reports/laria_report_20251206_223919.html ✓ Markdown report: reports/laria_report_20251206_223919.md ✅ Scan completed in 148.12 seconds ``` ## CI/CD 集成 ### GitHub Actions ``` name: Security Scan on: [push, pull_request] jobs: security: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run Laria run: | docker pull dumanoj/laria:latest docker run --rm \ -v ${{ github.workspace }}:${{ github.workspace }} \ -v ${{ github.workspace }}/reports:/laria/reports \ dumanoj/laria:latest ${{ github.workspace }} - name: Upload Reports uses: actions/upload-artifact@v4 with: name: security-reports path: reports/ ``` 参见 [.github/workflows/laria-scan.yml](.github/workflows/laria-scan.yml) 获取完整示例。 ## 配置 使用 `config.yaml` 自定义扫描行为: ``` scanners: secrets: enabled: true tools: [gitleaks] sast: enabled: true tools: [semgrep, spotbugs] dependencies: enabled: true tools: [trivy] iac: enabled: true tools: [trivy, checkov] severity: fail_on: CRITICAL report_threshold: LOW reporting: formats: [json, html, markdown] build: enabled: true tool: auto # auto, maven, gradle ``` ## 性能 - **小型项目** (<100 文件): ~30 秒 - **中型项目** (100-500 文件): ~90 秒 - **大型项目** (500+ 文件): ~150 秒 **优化技巧:** - 使用 cache volumes 加快后续扫描速度 - 为 /tmp 目录使用 tmpfs - 扫描器自动并行运行 ## 文档 - [EXAMPLES.md](docs/EXAMPLES.md) - 使用示例和模式 - [TOOLS.md](docs/TOOLS.md) - 详细的工具描述 - [TEST_RESULTS.md](docs/TEST_RESULTS.md) - 测试结果和基准 ## 系统要求 - Docker 20.10+ - 4GB RAM (最低) - 10GB 磁盘空间 (用于 Docker 镜像 + 缓存) - 互联网连接 (用于 CVE 数据库更新) ## 项目结构 ``` laria/ ├── laria.py # Main orchestrator ├── install.sh # Standalone installer ├── Dockerfile # Production Docker image ├── config.yaml # Default configuration ├── scan-repo.sh # Convenience script ├── scanners/ # Scanner implementations │ ├── secrets_scanner.py │ ├── sast_scanner.py │ ├── dependency_scanner.py │ ├── iac_scanner.py │ └── lint_scanner.py ├── utils/ # Utilities │ ├── repo_manager.py │ ├── artifact_detector.py │ ├── report_generator.py │ └── report_formatter.py ├── tests/ # Unit and integration tests └── docs/ # Documentation ``` ## 安全与隐私 Laria 的设计是安全且透明的: 1. **本地执行**:所有扫描均在 Docker 容器内本地进行。不会将任何源代码或报告上传到外部服务器。 2. **网络使用**:容器仅连接到互联网以: * 下载漏洞数据库更新 (Trivy, Grype)。 * 在构建阶段下载项目依赖项。 3. **卷挂载**: * **仓库**:以读写方式挂载,以便构建过程 (例如 `mvn package`) 可以在 `target/` 中创建工件。 * **Maven Cache**:挂载 `~/.m2` 以共享您的本地依赖缓存,加速构建并使用您配置的仓库。 4. **权限**:容器默认以非 root 用户 (`laria`) 运行,以最大程度降低风险。 ## 贡献 欢迎贡献!请随时提交 Pull Request。 ## 许可证 MIT License - 详见 [LICENSE](LICENSE) 文件 ## 致谢 本项目集成了以下开源安全工具: - [Gitleaks](https://github.com/gitleaks/gitleaks) - [Semgrep](https://github.com/returntocorp/semgrep) - [SpotBugs](https://github.com/spotbugs/spotbugs) - [Trivy](https://github.com/aquasecurity/trivy) - [Checkov](https://github.com/bridgecrewio/checkov) - [Hadolint](https://github.com/hadolint/hadolint) ## 支持 如有问题、疑问或贡献,请在 GitHub 上提交 issue。 **由 Laria 团队用 🛡️ 制作**
标签:AI应用开发, API安全, Chrome Headless, CI/CD安全, DevSecOps, DNS 反向解析, Dockerfile检查, Docker容器, GHAS, Gitleaks, GraphQL安全矩阵, HelmChart, IaC安全, Java安全, Java开发工具, JSON输出, Kubernetes安全, Llama, SAST, SBOM生成, Semgrep, StruQ, Web截图, WordPress安全扫描, 上游代理, 依赖扫描, 安全专业人员, 安全扫描器, 容器安全, 密钥泄露检测, 开源安全工具, 攻击面发现, 文档安全, 模型提供商, 深度防御, 版本冲突检测, 盲注攻击, 聊天机器人, 请求拦截, 软件供应链安全, 远程方法调用, 逆向工具, 逆向工程平台, 错误基检测, 静态代码分析