anchore / syft

CLI tool and library for generating a Software Bill of Materials from container images and filesystems
Apache License 2.0
6.29k stars 578 forks source link

Go source cataloger #3452

Open spiffcs opened 4 days ago

spiffcs commented 4 days ago

Description

This PR adds a new directory source cataloger that goes beyond reading declarations from the go.mod file.

The go-module-source-file-cataloger uses the golang.org/x/tools/go/packages library to read the "main" module from detected go.mod files. It then uses this main module information to load all the root packages for a given main module. The tool chain then visits all the packages in the import graph whose roots are packages in the discovered root packages.

This PR is currently WIP and needs further discussion around the following sections:

Type of change

Checklist: