Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generate SBOM for a single file #330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

nightlark
Copy link
Collaborator

@nightlark nightlark commented Jan 27, 2025

Enable users to generate an SBOM for a single file, without having to create a config file. If a file name ends with .json it is treated as a specimen config file, rather than generating a single-file SBOM for the JSON file. To override this behavior, several prefixes can be prepended to the file path so the argument to Surfactant will be in the form prefix:filepath -- e.g. file:abc.json.

The prefixes recognized are:

  • file to force Surfactant to generate an SBOM from the single file given after the prefix. Likely only needed to generate a single file SBOM for a JSON file or a file whose name starts with one of the special prefixes as part of the file name, both of which should be rare. e.g. file:config:abc.xyz would generate a single file SBOM for a file with the (odd) name config:abc.xyz
  • config to force Surfactant to treat the given file path as a Surfactant specimen config file. This should never be needed, unless a user decides to omit a .json file extension for their Surfactant specimen config file names.
  • dir to force Surfactant to treat the given file path as a specific directory to generate an SBOM for, with "implied" specimen config file settings (summarized below). This should only be needed if a directory has one of these special prefixes at the start of its name, which is very rare. e.g. dir:config:mydirectory would generate an SBOM over the contents in a directory named config:mydirectory.

For generating a single file or single directory SBOM some assumptions are made for parameters that a specimen config file would usually contain:

  • extractPaths: the path given as an argument to Surfactant
  • installPrefix: either the directory given as the argument to Surfactant, or the parent directory if the path given to Surfactant is for a single file SBOM; a relative path to a file will result in this being a relative path while an absolute path will result in this being the absolute path, which gives some control over the install paths present in the resulting SBOM

Resolves #126

nightlark added a commit that referenced this pull request Jan 28, 2025
@nightlark nightlark marked this pull request as ready for review January 28, 2025 01:36
@nightlark nightlark added the enhancement New feature or request label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX: Generate SBOM info for single file
1 participant