|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +### Build |
| 8 | +```bash |
| 9 | +# Build the main binary (CGO disabled by default) |
| 10 | +make build |
| 11 | +# Output: ./build/sbomqs |
| 12 | + |
| 13 | +# Clean build artifacts |
| 14 | +make clean |
| 15 | +``` |
| 16 | + |
| 17 | +### Test |
| 18 | +```bash |
| 19 | +# Run all tests with coverage and race detection |
| 20 | +make test |
| 21 | + |
| 22 | +# Run specific package tests |
| 23 | +go test -cover -race ./pkg/sbom/... |
| 24 | +go test -cover -race ./pkg/compliance/... |
| 25 | +``` |
| 26 | + |
| 27 | +### Lint |
| 28 | +```bash |
| 29 | +# Run golangci-lint (uses configuration from golangci.yml) |
| 30 | +golangci-lint run --timeout=5m |
| 31 | + |
| 32 | +# Specific linters enabled: asciicheck, unused, errcheck, errorlint, gofmt, goimports, gosec, revive, misspell, stylecheck, staticcheck, unconvert |
| 33 | +``` |
| 34 | + |
| 35 | +### Dependencies |
| 36 | +```bash |
| 37 | +# Update and tidy dependencies |
| 38 | +make dep |
| 39 | + |
| 40 | +# Update all dependencies to latest versions |
| 41 | +make updatedeps |
| 42 | +``` |
| 43 | + |
| 44 | +### Release |
| 45 | +```bash |
| 46 | +# Create a snapshot release for testing |
| 47 | +make snapshot |
| 48 | + |
| 49 | +# Create a full release |
| 50 | +make release |
| 51 | +``` |
| 52 | + |
| 53 | +## High-Level Architecture |
| 54 | + |
| 55 | +### Core Structure |
| 56 | +sbomqs is a Go application that evaluates SBOM (Software Bill of Materials) quality and compliance. The architecture follows a command-based pattern with clear separation of concerns: |
| 57 | + |
| 58 | +1. **Entry Point**: `main.go` → `cmd/Execute()` using Cobra framework with Fang styling |
| 59 | +2. **Commands Layer** (`cmd/`): User-facing commands (score, compliance, list, share, etc.) |
| 60 | +3. **Engine Layer** (`pkg/engine/`): Orchestrates operations across different components |
| 61 | +4. **Core Business Logic** (`pkg/`): |
| 62 | + - `sbom/`: SBOM parsing and representation (supports SPDX and CycloneDX) |
| 63 | + - `compliance/`: Compliance validation engines (BSI, NTIA, FSCT, OpenChain Telco) |
| 64 | + - `scorer/`: Quality scoring algorithms |
| 65 | + - `reporter/`: Output formatting (basic, detailed, JSON) |
| 66 | + - `policy/`: Custom policy evaluation framework |
| 67 | + |
| 68 | +### Key Architectural Decisions |
| 69 | + |
| 70 | +**Multi-Format SBOM Support**: The `pkg/sbom` package provides a unified interface for both SPDX and CycloneDX formats. Format detection happens automatically in `sbom.go:detectSbomFormat()`. |
| 71 | + |
| 72 | +**Scoring System**: Quality scores are calculated on a 0-10 scale using weighted criteria across multiple categories (NTIA compliance, structural quality, semantic quality). The scoring engine is configurable via YAML profiles. |
| 73 | + |
| 74 | +**Compliance Framework**: Each compliance standard (BSI, NTIA, FSCT, OCT) has its own module in `pkg/compliance/` with dedicated scoring and reporting logic. Common functionality is shared via `pkg/compliance/common/`. |
| 75 | + |
| 76 | +**Extensible Reporter Pattern**: Output formatting uses a strategy pattern where different reporters (basic, detailed, JSON, PDF) implement the same interface, allowing flexible output generation. |
| 77 | + |
| 78 | +### Data Flow |
| 79 | +1. User invokes command → Command parses arguments |
| 80 | +2. Engine loads SBOM file(s) → Auto-detects format (SPDX/CycloneDX) |
| 81 | +3. Creates internal SBOM representation → Unified model across formats |
| 82 | +4. Applies scoring/compliance/analysis → Based on command and flags |
| 83 | +5. Generates report via reporter → Formatted output to stdout |
| 84 | + |
| 85 | +### External Integrations |
| 86 | +- **Dependency-Track**: Integration via `cmd/dtrackScore.go` and `pkg/engine/dtrack.go` |
| 87 | +- **Share Service**: External API for sharing SBOM quality reports (`pkg/share/`) |
| 88 | +- **Docker**: Containerized execution support with official image |
| 89 | + |
| 90 | +### Configuration |
| 91 | +- Scoring profiles can be customized via YAML configuration files |
| 92 | +- Environment variable `INTERLYNK_DISABLE_VERSION_CHECK` disables version checking for air-gapped environments |
| 93 | +- The tool respects standard Go build flags and environment variables |
0 commit comments