Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ install scripts provided in the respective repositories.
- [clean_cache](docs/actions/clean_cache.md) is used at the end of a successful workflow to clean up the cached objects
- [composer_merge](docs/actions/composer_merge.md) merges a JSON string with composer.json.
- [consolidate_artifacts](docs/actions/consolidate_artifacts.md) consolidates multiple artifacts into one.
- [generate_sbom](docs/actions/generate_sbom.md) generates a CycloneDX SBOM of a Composer project's production dependencies.
- [start_shop](docs/actions/start_shop.md) fetches a shop from cache and starts it.
- [stop_shop](docs/actions/stop_shop.md) stops a running shop.
- [load_cached_testplan](docs/actions/load_cached_testplan.md) loads the cached
Expand Down
25 changes: 25 additions & 0 deletions docs/actions/generate_sbom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# generate_sbom

This action generates a CycloneDX SBOM (Software Bill of Materials) listing the
production dependencies of a Composer project. It installs the
`cyclonedx/cyclonedx-php-composer` plugin globally, resolves the project's
production dependencies, and writes the SBOM file.

## Inputs

**working_directory:** *not required*, *default:* '.'
Composer project to scan, i.e. the directory containing the composer.json.

**spec_version:** *not required*, *default:* '1.4'
CycloneDX specification version. BSI TR-03183-2 requires at least 1.4.

**output_format:** *not required*, *default:* 'JSON'
SBOM output format, either JSON or XML.

**output_file:** *not required*, *default:* 'sbom.json'
Name of the SBOM file, written inside working_directory.

## Outputs

**sbom_path:**
Path to the generated SBOM file, for the caller to upload or publish.
61 changes: 61 additions & 0 deletions generate_sbom/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: 'generate_sbom'

description: 'Generate a CycloneDX SBOM (production dependencies) for a Composer project'

inputs:
working_directory:
type: string
required: false
description: 'Composer project to scan (directory containing composer.json)'
default: '.'
spec_version:
type: string
required: false
description: 'CycloneDX spec version (BSI TR-03183-2 wants >= 1.4)'
default: '1.4'
output_format:
type: string
required: false
description: 'SBOM output format: JSON or XML'
default: 'JSON'
output_file:
type: string
required: false
description: 'SBOM file name, written inside working_directory'
default: 'sbom.json'

outputs:
sbom_path:
description: 'Path to the generated SBOM file'
value: ${{ steps.generate.outputs.path }}

runs:
using: 'composite'
steps:
- name: 'Install the SBOM plugin globally'
shell: bash
run: |
# generate_sbom: Install the SBOM plugin globally
composer global config allow-plugins.cyclonedx/cyclonedx-php-composer true
composer global require cyclonedx/cyclonedx-php-composer --no-interaction

- name: 'Resolve production dependencies'
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
# generate_sbom: Resolve production dependencies
composer update --no-dev --no-scripts --no-plugins --ignore-platform-reqs --no-interaction

- name: 'Generate SBOM'
id: generate
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
# generate_sbom: Generate SBOM
composer CycloneDX:make-sbom \
--output-format='${{ inputs.output_format }}' \
--output-file='${{ inputs.output_file }}' \
--spec-version='${{ inputs.spec_version }}' \
--omit=dev \
--no-interaction
echo "path=${{ inputs.working_directory }}/${{ inputs.output_file }}" >> "$GITHUB_OUTPUT"
Loading