mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 22:12:28 +01:00
* add location annotations + deb evidence annotations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * rename LocationData struct and Annotation helper function Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add failing integration test for evidence coverage Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add evidence to aplm cataloger locations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * change location annotation helper to return a location copy Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add evidence to binary cataloger locations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * updated remaining catalogers with location annotations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix unit tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * bump json schema Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * partial addressing of review comments Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * rename location.WithAnnotation Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package haskell
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
"github.com/anchore/syft/syft/artifact"
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/anchore/syft/syft/pkg/cataloger/generic"
|
|
"github.com/anchore/syft/syft/source"
|
|
)
|
|
|
|
var _ generic.Parser = parseStackYaml
|
|
|
|
type stackYaml struct {
|
|
ExtraDeps []string `yaml:"extra-deps"`
|
|
}
|
|
|
|
// parseStackYaml is a parser function for stack.yaml contents, returning all packages discovered.
|
|
func parseStackYaml(_ source.FileResolver, _ *generic.Environment, reader source.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
|
bytes, err := io.ReadAll(reader)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("failed to load stack.yaml file: %w", err)
|
|
}
|
|
|
|
var stackFile stackYaml
|
|
|
|
if err := yaml.Unmarshal(bytes, &stackFile); err != nil {
|
|
return nil, nil, fmt.Errorf("failed to parse stack.yaml file: %w", err)
|
|
}
|
|
|
|
var pkgs []pkg.Package
|
|
for _, dep := range stackFile.ExtraDeps {
|
|
pkgName, pkgVersion, pkgHash := parseStackPackageEncoding(dep)
|
|
pkgs = append(
|
|
pkgs,
|
|
newPackage(
|
|
pkgName,
|
|
pkgVersion,
|
|
&pkg.HackageMetadata{
|
|
PkgHash: pkgHash,
|
|
},
|
|
reader.Location.WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation),
|
|
),
|
|
)
|
|
}
|
|
|
|
return pkgs, nil, nil
|
|
}
|