File: presets.go

package info (click to toggle)
golang-github-containers-buildah 1.39.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,724 kB
  • sloc: sh: 2,398; makefile: 236; perl: 187; asm: 16; awk: 12; ansic: 1
file content (65 lines) | stat: -rw-r--r-- 2,502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package sbom

import "github.com/containers/buildah/define"

// Preset returns a predefined SBOMScanOptions structure that has the passed-in
// name as one of its "Type" values.
func Preset(name string) (preset *define.SBOMScanOptions, err error) {
	// If you change these, make sure you update references in
	// buildah-commit.1.md and buildah-build.1.md to match!
	presets := []define.SBOMScanOptions{
		{
			Type:  []string{"", "syft", "syft-cyclonedx"},
			Image: "ghcr.io/anchore/syft",
			Commands: []string{
				"/syft scan -q dir:{ROOTFS} --output cyclonedx-json={OUTPUT}",
				"/syft scan -q dir:{CONTEXT} --output cyclonedx-json={OUTPUT}",
			},
			// ImageSBOMOutput: "/root/buildinfo/content_manifests/sbom-cyclonedx.json",
			// ImagePURLOutput: "/root/buildinfo/content_manifests/sbom-purl.json",
			MergeStrategy: define.SBOMMergeStrategyCycloneDXByComponentNameAndVersion,
		},
		{
			Type:  []string{"syft-spdx"},
			Image: "ghcr.io/anchore/syft",
			Commands: []string{
				"/syft scan -q dir:{ROOTFS} --output spdx-json={OUTPUT}",
				"/syft scan -q dir:{CONTEXT} --output spdx-json={OUTPUT}",
			},
			// ImageSBOMOutput: "/root/buildinfo/content_manifests/sbom-spdx.json",
			// ImagePURLOutput: "/root/buildinfo/content_manifests/sbom-purl.json",
			MergeStrategy: define.SBOMMergeStrategySPDXByPackageNameAndVersionInfo,
		},

		{
			Type:  []string{"trivy", "trivy-cyclonedx"},
			Image: "ghcr.io/aquasecurity/trivy",
			Commands: []string{
				"trivy filesystem -q {ROOTFS} --format cyclonedx --output {OUTPUT}",
				"trivy filesystem -q {CONTEXT} --format cyclonedx --output {OUTPUT}",
			},
			// ImageSBOMOutput: "/root/buildinfo/content_manifests/sbom-cyclonedx.json",
			// ImagePURLOutput: "/root/buildinfo/content_manifests/sbom-purl.json",
			MergeStrategy: define.SBOMMergeStrategyCycloneDXByComponentNameAndVersion,
		},
		{
			Type:  []string{"trivy-spdx"},
			Image: "ghcr.io/aquasecurity/trivy",
			Commands: []string{
				"trivy filesystem -q {ROOTFS} --format spdx-json --output {OUTPUT}",
				"trivy filesystem -q {CONTEXT} --format spdx-json --output {OUTPUT}",
			},
			// ImageSBOMOutput: "/root/buildinfo/content_manifests/sbom-spdx.json",
			// ImagePURLOutput: "/root/buildinfo/content_manifests/sbom-purl.json",
			MergeStrategy: define.SBOMMergeStrategySPDXByPackageNameAndVersionInfo,
		},
	}
	for _, preset := range presets {
		for _, presetName := range preset.Type {
			if presetName == name {
				return &preset, nil
			}
		}
	}
	return nil, nil
}