An open API service indexing awesome lists of open source software.

https://github.com/scality/sbom-upload

Upload SOM to Dependenccy Track
https://github.com/scality/sbom-upload

dependency-track github-actions python sbom security

Last synced: about 2 months ago
JSON representation

Upload SOM to Dependenccy Track

Awesome Lists containing this project

README

          

# SBOM Upload Action

[![GitHub release](https://img.shields.io/github/release/scality/sbom-upload.svg)](https://github.com/scality/sbom-upload/releases/latest)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/scality/sbom/blob/main/LICENSE)

A GitHub Action and CLI tool for uploading Software Bill of Materials (SBOM) files to [Dependency Track](https://dependencytrack.org/).

## โœจ Features

- ๐Ÿš€ **GitHub Action Integration** - Seamless CI/CD pipeline integration
- ๐Ÿ“ **Multiple Upload Methods** - Single SBOMs, batch uploads, or custom hierarchies
- ๐Ÿ—๏ธ **Hierarchical Projects** - Create parent/child project relationships
- ๐ŸŽจ **Auto Hierarchy Generation** - Generate 3-level hierarchies from nested SBOM structures
- ๐Ÿ”„ **Version Management** - Semantic version comparison and latest detection
- ๐Ÿงช **Local Testing** - CLI for development and debugging
- ๐ŸŽฏ **Auto-Detection** - Extract project info from SBOM metadata
- ๐Ÿ” **Secure** - API key authentication with proper error handling
- ๐Ÿ†” **Unique Naming** - UUID suffixes prevent project name conflicts

## ๐Ÿš€ Quick Start

### GitHub Action (Recommended)

```yaml
name: Upload SBOM
on: [push]

jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: scality/sbom-upload@v1
with:
url: 'https://dependency-track.example.com'
api-key: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
project-sbom: 'sbom.json'
```

### CLI Usage

```bash
# Set environment variables
export INPUT_URL="https://dependency-track.example.com"
export INPUT_API_KEY="your-api-key"

# Test connection
PYTHONPATH=src python src/main.py test-connection

# Upload single SBOM file
export INPUT_PROJECT_SBOM="sbom.json"
PYTHONPATH=src python src/main.py upload

# Upload SBOM with custom project details (via environment)
export INPUT_PROJECT_SBOM="sbom.json"
export INPUT_PROJECT_NAME="my-app"
export INPUT_PROJECT_VERSION="1.0.0"
PYTHONPATH=src python src/main.py upload
```

## ๐Ÿ“– Documentation

- **[Quick Start Guide](docs/QUICKSTART.md)** - Get started in minutes
- **[Usage Examples](docs/USAGE_EXAMPLES.md)** - Comprehensive examples for GitHub Actions and CLI
- **[Hierarchy Configuration](docs/HIERARCHY_CONFIG.md)** - Advanced project structures
- **[CLI Reference](docs/CLI.md)** - Complete command-line interface documentation

## ๐Ÿ› ๏ธ Installation

### For GitHub Actions
No installation required - just reference the action in your workflow.

### For CLI Development
```bash
git clone https://github.com/scality/sbom-upload.git
cd sbom-upload
pip install -r requirements.txt
```

## ๐ŸŽฏ Use Cases

- **CI/CD Integration** - Automatically upload SBOMs on builds/releases
- **Multi-Service Applications** - Manage complex project hierarchies
- **Security Compliance** - Track dependencies across your organization
- **Version Management** - Maintain accurate version histories
- **Development Workflows** - Test uploads locally before deployment

## ๐Ÿ“Š Supported Scenarios

| Scenario | GitHub Action | CLI | Documentation |
|----------|:-------------:|:---:|:-------------:|
| Single SBOM Upload | โœ… | โœ… | [Examples](docs/USAGE_EXAMPLES.md#basic-single-sbom-upload) |
| Multiple SBOMs | โœ… | โœ… | [Examples](docs/USAGE_EXAMPLES.md#multiple-sboms-from-file-list) |
| Nested Projects | โœ… | โœ… | [Examples](docs/USAGE_EXAMPLES.md#advanced-configuration-with-custom-hierarchy) |
| Auto Hierarchy Generation | โœ… | โœ… | [Usage Examples](docs/USAGE_EXAMPLES.md#hierarchy-generation-from-nested-sbom-structure) |
| Custom Hierarchies | โŒ | โœ… | [Hierarchy Config](docs/HIERARCHY_CONFIG.md) |
| Version Detection | โœ… | โœ… | [Usage Examples](docs/USAGE_EXAMPLES.md#with-version-detection) |
| Dry Run Testing | โŒ | โœ… | [CLI Reference](docs/CLI.md) |

## ๐Ÿ”ง Configuration

### GitHub Action Inputs

| Input | Required | Description | Example |
|-------|:--------:|-------------|---------|
| `url` | โœ… | Dependency Track server URL | `https://dt.example.com` |
| `api-key` | โœ… | API key for authentication | `${{ secrets.DT_API_KEY }}` |
| `project-sbom` | โœ…* | Path to single SBOM file | `dist/sbom.json` |
| `project-sbom-list` | โœ…* | Path to file with SBOM list | `sbom-files.txt` |
| `project-sbom-dir` | โœ…* | Directory containing SBOMs | `dist/sboms/` |
| `project-name` | โŒ | Override project name | `my-application` |
| `project-version` | โŒ | Override project version | `1.2.3` |
| `parent-project-name` | โŒ | Parent project name | `main-app` |
| `parent-project-version` | โŒ | Parent project version | `2.0.0` |
| `project-classifier` | โŒ | Project type classifier | `APPLICATION` |
| `parent-project-classifier` | โŒ | Parent project classifier | `APPLICATION` |
| `project-collection-logic` | โŒ | Collection logic for children | `AGGREGATE_DIRECT_CHILDREN` |
| `parent-project-collection-logic` | โŒ | Parent collection logic | `AGGREGATE_DIRECT_CHILDREN` |
| `is-latest` | โŒ | Mark as latest version | `true` |
| `auto-detect-latest` | โŒ | Auto-detect latest flag | `true` |
| `api-timeout` | โŒ | API timeout (seconds) | `300` |
| `dry-run` | โŒ | Validate without uploading | `true` |
| `project-prefix` | โŒ | Prefix for project names | `ci-` |
| `project-suffix` | โŒ | Suffix for project names | `-prod` |
| `project-tags` | โŒ | Comma-separated tags | `production,ci-cd` |
| `delete-on-version-suffix-match` | โŒ | Delete existing leaf project when version matches suffix pattern (default `false`) | `true` |
| `delete-version-suffix-pattern` | โŒ | Case-insensitive regex evaluated against project version when delete is enabled (default `dev`) | `dev$` |

*One of `project-sbom`, `project-sbom-list`, or `project-sbom-dir` is required.

[View all inputs โ†’](docs/USAGE_EXAMPLES.md#environment-variables)

## ๐Ÿงช Local Development

```bash
# Start local Dependency Track instance
cd tests
docker-compose up -d

# Test connection
PYTHONPATH=src python src/main.py test-connection

# Upload test SBOM
export INPUT_PROJECT_SBOM="tests/single_sbom/nginx_12.9.1.json"
export INPUT_DRY_RUN="true"
PYTHONPATH=src python src/main.py upload
```

## ๐Ÿค Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ”— Related Projects

- [Dependency Track](https://dependencytrack.org/) - Software composition analysis platform
- [CycloneDX](https://cyclonedx.org/) - SBOM standard specification
- [SPDX](https://spdx.dev/) - Software package data exchange format

## ๐Ÿ“ž Support

- ๐Ÿ“š [Documentation](docs/)
- ๐Ÿ› [Issues](https://github.com/scality/sbom-upload/issues)
- ๐Ÿ’ฌ [Discussions](https://github.com/scality/sbom-upload/discussions)