mirror of
https://github.com/anchore/syft.git
synced 2025-11-19 01:13:18 +01:00
* add basic documentation for catalogers (with refactoring for simplification) Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add docs for catalog parsers, UI, and event bus Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update bus phrasing Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
30 lines
716 B
Go
30 lines
716 B
Go
package python
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/anchore/syft/syft/cataloger/common"
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/pelletier/go-toml"
|
|
)
|
|
|
|
// integrity check
|
|
var _ common.ParserFn = parsePoetryLock
|
|
|
|
// parsePoetryLock is a parser function for poetry.lock contents, returning all python packages discovered.
|
|
func parsePoetryLock(_ string, reader io.Reader) ([]pkg.Package, error) {
|
|
tree, err := toml.LoadReader(reader)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unable to load poetry.lock for parsing: %v", err)
|
|
}
|
|
|
|
metadata := PoetryMetadata{}
|
|
err = tree.Unmarshal(&metadata)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unable to parse poetry.lock: %v", err)
|
|
}
|
|
|
|
return metadata.Pkgs(), nil
|
|
}
|