Remove unused compliance_sbom tool
Bug: 395941388
Test: presubmits
Change-Id: Ia0f62e71d6c034c3a117a802c5bdc743241aec41
diff --git a/tools/compliance/Android.bp b/tools/compliance/Android.bp
index ef5c760..2527df7 100644
--- a/tools/compliance/Android.bp
+++ b/tools/compliance/Android.bp
@@ -131,22 +131,6 @@
testSrcs: ["cmd/xmlnotice/xmlnotice_test.go"],
}
-blueprint_go_binary {
- name: "compliance_sbom",
- srcs: ["cmd/sbom/sbom.go"],
- deps: [
- "compliance-module",
- "blueprint-deptools",
- "soong-response",
- "spdx-tools-spdxv2_2",
- "spdx-tools-builder2v2",
- "spdx-tools-spdxcommon",
- "spdx-tools-spdx-json",
- "spdx-tools-spdxlib",
- ],
- testSrcs: ["cmd/sbom/sbom_test.go"],
-}
-
bootstrap_go_package {
name: "compliance-module",
srcs: [
diff --git a/tools/compliance/cmd/sbom/sbom.go b/tools/compliance/cmd/sbom/sbom.go
deleted file mode 100644
index a53741f..0000000
--- a/tools/compliance/cmd/sbom/sbom.go
+++ /dev/null
@@ -1,547 +0,0 @@
-// Copyright 2022 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "bytes"
- "crypto/sha1"
- "encoding/hex"
- "flag"
- "fmt"
- "io"
- "io/fs"
- "os"
- "path/filepath"
- "sort"
- "strings"
- "time"
-
- "android/soong/response"
- "android/soong/tools/compliance"
- "android/soong/tools/compliance/projectmetadata"
-
- "github.com/google/blueprint/deptools"
-
- "github.com/spdx/tools-golang/builder/builder2v2"
- spdx_json "github.com/spdx/tools-golang/json"
- "github.com/spdx/tools-golang/spdx/common"
- spdx "github.com/spdx/tools-golang/spdx/v2_2"
- "github.com/spdx/tools-golang/spdxlib"
-)
-
-var (
- failNoneRequested = fmt.Errorf("\nNo license metadata files requested")
- failNoLicenses = fmt.Errorf("No licenses found")
-)
-
-const NOASSERTION = "NOASSERTION"
-
-type context struct {
- stdout io.Writer
- stderr io.Writer
- rootFS fs.FS
- product string
- stripPrefix []string
- creationTime creationTimeGetter
- buildid string
-}
-
-func (ctx context) strip(installPath string) string {
- for _, prefix := range ctx.stripPrefix {
- if strings.HasPrefix(installPath, prefix) {
- p := strings.TrimPrefix(installPath, prefix)
- if 0 == len(p) {
- p = ctx.product
- }
- if 0 == len(p) {
- continue
- }
- return p
- }
- }
- return installPath
-}
-
-// newMultiString creates a flag that allows multiple values in an array.
-func newMultiString(flags *flag.FlagSet, name, usage string) *multiString {
- var f multiString
- flags.Var(&f, name, usage)
- return &f
-}
-
-// multiString implements the flag `Value` interface for multiple strings.
-type multiString []string
-
-func (ms *multiString) String() string { return strings.Join(*ms, ", ") }
-func (ms *multiString) Set(s string) error { *ms = append(*ms, s); return nil }
-
-func main() {
- var expandedArgs []string
- for _, arg := range os.Args[1:] {
- if strings.HasPrefix(arg, "@") {
- f, err := os.Open(strings.TrimPrefix(arg, "@"))
- if err != nil {
- fmt.Fprintln(os.Stderr, err.Error())
- os.Exit(1)
- }
-
- respArgs, err := response.ReadRspFile(f)
- f.Close()
- if err != nil {
- fmt.Fprintln(os.Stderr, err.Error())
- os.Exit(1)
- }
- expandedArgs = append(expandedArgs, respArgs...)
- } else {
- expandedArgs = append(expandedArgs, arg)
- }
- }
-
- flags := flag.NewFlagSet("flags", flag.ExitOnError)
-
- flags.Usage = func() {
- fmt.Fprintf(os.Stderr, `Usage: %s {options} file.meta_lic {file.meta_lic...}
-
-Outputs an SBOM.spdx.
-
-Options:
-`, filepath.Base(os.Args[0]))
- flags.PrintDefaults()
- }
-
- outputFile := flags.String("o", "-", "Where to write the SBOM spdx file. (default stdout)")
- depsFile := flags.String("d", "", "Where to write the deps file")
- product := flags.String("product", "", "The name of the product for which the notice is generated.")
- stripPrefix := newMultiString(flags, "strip_prefix", "Prefix to remove from paths. i.e. path to root (multiple allowed)")
- buildid := flags.String("build_id", "", "Uniquely identifies the build. (default timestamp)")
-
- flags.Parse(expandedArgs)
-
- // Must specify at least one root target.
- if flags.NArg() == 0 {
- flags.Usage()
- os.Exit(2)
- }
-
- if len(*outputFile) == 0 {
- flags.Usage()
- fmt.Fprintf(os.Stderr, "must specify file for -o; use - for stdout\n")
- os.Exit(2)
- } else {
- dir, err := filepath.Abs(filepath.Dir(*outputFile))
- if err != nil {
- fmt.Fprintf(os.Stderr, "cannot determine path to %q: %s\n", *outputFile, err)
- os.Exit(1)
- }
- fi, err := os.Stat(dir)
- if err != nil {
- fmt.Fprintf(os.Stderr, "cannot read directory %q of %q: %s\n", dir, *outputFile, err)
- os.Exit(1)
- }
- if !fi.IsDir() {
- fmt.Fprintf(os.Stderr, "parent %q of %q is not a directory\n", dir, *outputFile)
- os.Exit(1)
- }
- }
-
- var ofile io.Writer
- ofile = os.Stdout
- var obuf *bytes.Buffer
- if *outputFile != "-" {
- obuf = &bytes.Buffer{}
- ofile = obuf
- }
-
- ctx := &context{ofile, os.Stderr, compliance.FS, *product, *stripPrefix, actualTime, *buildid}
-
- spdxDoc, deps, err := sbomGenerator(ctx, flags.Args()...)
-
- if err != nil {
- if err == failNoneRequested {
- flags.Usage()
- }
- fmt.Fprintf(os.Stderr, "%s\n", err.Error())
- os.Exit(1)
- }
-
- // writing the spdx Doc created
- if err := spdx_json.Save2_2(spdxDoc, ofile); err != nil {
- fmt.Fprintf(os.Stderr, "failed to write document to %v: %v", *outputFile, err)
- os.Exit(1)
- }
-
- if *outputFile != "-" {
- err := os.WriteFile(*outputFile, obuf.Bytes(), 0666)
- if err != nil {
- fmt.Fprintf(os.Stderr, "could not write output to %q: %s\n", *outputFile, err)
- os.Exit(1)
- }
- }
-
- if *depsFile != "" {
- err := deptools.WriteDepFile(*depsFile, *outputFile, deps)
- if err != nil {
- fmt.Fprintf(os.Stderr, "could not write deps to %q: %s\n", *depsFile, err)
- os.Exit(1)
- }
- }
- os.Exit(0)
-}
-
-type creationTimeGetter func() string
-
-// actualTime returns current time in UTC
-func actualTime() string {
- t := time.Now().UTC()
- return t.UTC().Format("2006-01-02T15:04:05Z")
-}
-
-// replaceSlashes replaces "/" by "-" for the library path to be used for packages & files SPDXID
-func replaceSlashes(x string) string {
- return strings.ReplaceAll(x, "/", "-")
-}
-
-// stripDocName removes the outdir prefix and meta_lic suffix from a target Name
-func stripDocName(name string) string {
- // remove outdir prefix
- if strings.HasPrefix(name, "out/") {
- name = name[4:]
- }
-
- // remove suffix
- if strings.HasSuffix(name, ".meta_lic") {
- name = name[:len(name)-9]
- } else if strings.HasSuffix(name, "/meta_lic") {
- name = name[:len(name)-9] + "/"
- }
-
- return name
-}
-
-// getPackageName returns a package name of a target Node
-func getPackageName(_ *context, tn *compliance.TargetNode) string {
- return replaceSlashes(tn.Name())
-}
-
-// getDocumentName returns a package name of a target Node
-func getDocumentName(ctx *context, tn *compliance.TargetNode, pm *projectmetadata.ProjectMetadata) string {
- if len(ctx.product) > 0 {
- return replaceSlashes(ctx.product)
- }
- if len(tn.ModuleName()) > 0 {
- if pm != nil {
- return replaceSlashes(pm.Name() + ":" + tn.ModuleName())
- }
- return replaceSlashes(tn.ModuleName())
- }
-
- return stripDocName(replaceSlashes(tn.Name()))
-}
-
-// getDownloadUrl returns the download URL if available (GIT, SVN, etc..),
-// or NOASSERTION if not available, none determined or ambiguous
-func getDownloadUrl(_ *context, pm *projectmetadata.ProjectMetadata) string {
- if pm == nil {
- return NOASSERTION
- }
-
- urlsByTypeName := pm.UrlsByTypeName()
- if urlsByTypeName == nil {
- return NOASSERTION
- }
-
- url := urlsByTypeName.DownloadUrl()
- if url == "" {
- return NOASSERTION
- }
- return url
-}
-
-// getProjectMetadata returns the optimal project metadata for the target node
-func getProjectMetadata(_ *context, pmix *projectmetadata.Index,
- tn *compliance.TargetNode) (*projectmetadata.ProjectMetadata, error) {
- pms, err := pmix.MetadataForProjects(tn.Projects()...)
- if err != nil {
- return nil, fmt.Errorf("Unable to read projects for %q: %w\n", tn.Name(), err)
- }
- if len(pms) == 0 {
- return nil, nil
- }
-
- // Getting the project metadata that contains most of the info needed for sbomGenerator
- score := -1
- index := -1
- for i := 0; i < len(pms); i++ {
- tempScore := 0
- if pms[i].Name() != "" {
- tempScore += 1
- }
- if pms[i].Version() != "" {
- tempScore += 1
- }
- if pms[i].UrlsByTypeName().DownloadUrl() != "" {
- tempScore += 1
- }
-
- if tempScore == score {
- if pms[i].Project() < pms[index].Project() {
- index = i
- }
- } else if tempScore > score {
- score = tempScore
- index = i
- }
- }
- return pms[index], nil
-}
-
-// inputFiles returns the complete list of files read
-func inputFiles(lg *compliance.LicenseGraph, pmix *projectmetadata.Index, licenseTexts []string) []string {
- projectMeta := pmix.AllMetadataFiles()
- targets := lg.TargetNames()
- files := make([]string, 0, len(licenseTexts)+len(targets)+len(projectMeta))
- files = append(files, licenseTexts...)
- files = append(files, targets...)
- files = append(files, projectMeta...)
- return files
-}
-
-// generateSPDXNamespace generates a unique SPDX Document Namespace using a SHA1 checksum
-func generateSPDXNamespace(buildid string, created string, files ...string) string {
-
- seed := strings.Join(files, "")
-
- if buildid == "" {
- seed += created
- } else {
- seed += buildid
- }
-
- // Compute a SHA1 checksum of the seed.
- hash := sha1.Sum([]byte(seed))
- uuid := hex.EncodeToString(hash[:])
-
- namespace := fmt.Sprintf("SPDXRef-DOCUMENT-%s", uuid)
-
- return namespace
-}
-
-// sbomGenerator implements the spdx bom utility
-
-// SBOM is part of the new government regulation issued to improve national cyber security
-// and enhance software supply chain and transparency, see https://www.cisa.gov/sbom
-
-// sbomGenerator uses the SPDX standard, see the SPDX specification (https://spdx.github.io/spdx-spec/)
-// sbomGenerator is also following the internal google SBOM styleguide (http://goto.google.com/spdx-style-guide)
-func sbomGenerator(ctx *context, files ...string) (*spdx.Document, []string, error) {
- // Must be at least one root file.
- if len(files) < 1 {
- return nil, nil, failNoneRequested
- }
-
- pmix := projectmetadata.NewIndex(ctx.rootFS)
-
- lg, err := compliance.ReadLicenseGraph(ctx.rootFS, ctx.stderr, files)
-
- if err != nil {
- return nil, nil, fmt.Errorf("Unable to read license text file(s) for %q: %v\n", files, err)
- }
-
- // creating the packages section
- pkgs := []*spdx.Package{}
-
- // creating the relationship section
- relationships := []*spdx.Relationship{}
-
- // creating the license section
- otherLicenses := []*spdx.OtherLicense{}
-
- // spdx document name
- var docName string
-
- // main package name
- var mainPkgName string
-
- // implementing the licenses references for the packages
- licenses := make(map[string]string)
- concludedLicenses := func(licenseTexts []string) string {
- licenseRefs := make([]string, 0, len(licenseTexts))
- for _, licenseText := range licenseTexts {
- license := strings.SplitN(licenseText, ":", 2)[0]
- if _, ok := licenses[license]; !ok {
- licenseRef := "LicenseRef-" + replaceSlashes(license)
- licenses[license] = licenseRef
- }
-
- licenseRefs = append(licenseRefs, licenses[license])
- }
- if len(licenseRefs) > 1 {
- return "(" + strings.Join(licenseRefs, " AND ") + ")"
- } else if len(licenseRefs) == 1 {
- return licenseRefs[0]
- }
- return "NONE"
- }
-
- isMainPackage := true
- visitedNodes := make(map[*compliance.TargetNode]struct{})
-
- // performing a Breadth-first top down walk of licensegraph and building package information
- compliance.WalkTopDownBreadthFirst(nil, lg,
- func(lg *compliance.LicenseGraph, tn *compliance.TargetNode, path compliance.TargetEdgePath) bool {
- if err != nil {
- return false
- }
- var pm *projectmetadata.ProjectMetadata
- pm, err = getProjectMetadata(ctx, pmix, tn)
- if err != nil {
- return false
- }
-
- if isMainPackage {
- docName = getDocumentName(ctx, tn, pm)
- mainPkgName = replaceSlashes(getPackageName(ctx, tn))
- isMainPackage = false
- }
-
- if len(path) == 0 {
- // Add the describe relationship for the main package
- rln := &spdx.Relationship{
- RefA: common.MakeDocElementID("" /* this document */, "DOCUMENT"),
- RefB: common.MakeDocElementID("", mainPkgName),
- Relationship: "DESCRIBES",
- }
- relationships = append(relationships, rln)
-
- } else {
- // Check parent and identify annotation
- parent := path[len(path)-1]
- targetEdge := parent.Edge()
- if targetEdge.IsRuntimeDependency() {
- // Adding the dynamic link annotation RUNTIME_DEPENDENCY_OF relationship
- rln := &spdx.Relationship{
- RefA: common.MakeDocElementID("", replaceSlashes(getPackageName(ctx, tn))),
- RefB: common.MakeDocElementID("", replaceSlashes(getPackageName(ctx, targetEdge.Target()))),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- }
- relationships = append(relationships, rln)
-
- } else if targetEdge.IsDerivation() {
- // Adding the derivation annotation as a CONTAINS relationship
- rln := &spdx.Relationship{
- RefA: common.MakeDocElementID("", replaceSlashes(getPackageName(ctx, targetEdge.Target()))),
- RefB: common.MakeDocElementID("", replaceSlashes(getPackageName(ctx, tn))),
- Relationship: "CONTAINS",
- }
- relationships = append(relationships, rln)
-
- } else if targetEdge.IsBuildTool() {
- // Adding the toolchain annotation as a BUILD_TOOL_OF relationship
- rln := &spdx.Relationship{
- RefA: common.MakeDocElementID("", replaceSlashes(getPackageName(ctx, tn))),
- RefB: common.MakeDocElementID("", replaceSlashes(getPackageName(ctx, targetEdge.Target()))),
- Relationship: "BUILD_TOOL_OF",
- }
- relationships = append(relationships, rln)
-
- } else {
- panic(fmt.Errorf("Unknown dependency type: %v", targetEdge.Annotations()))
- }
- }
-
- if _, alreadyVisited := visitedNodes[tn]; alreadyVisited {
- return false
- }
- visitedNodes[tn] = struct{}{}
- pkgName := getPackageName(ctx, tn)
-
- // Making an spdx package and adding it to pkgs
- pkg := &spdx.Package{
- PackageName: replaceSlashes(pkgName),
- PackageDownloadLocation: getDownloadUrl(ctx, pm),
- PackageSPDXIdentifier: common.ElementID(replaceSlashes(pkgName)),
- PackageLicenseConcluded: concludedLicenses(tn.LicenseTexts()),
- }
-
- if pm != nil && pm.Version() != "" {
- pkg.PackageVersion = pm.Version()
- } else {
- pkg.PackageVersion = NOASSERTION
- }
-
- pkgs = append(pkgs, pkg)
-
- return true
- })
-
- // Adding Non-standard licenses
-
- licenseTexts := make([]string, 0, len(licenses))
-
- for licenseText := range licenses {
- licenseTexts = append(licenseTexts, licenseText)
- }
-
- sort.Strings(licenseTexts)
-
- for _, licenseText := range licenseTexts {
- // open the file
- f, err := ctx.rootFS.Open(filepath.Clean(licenseText))
- if err != nil {
- return nil, nil, fmt.Errorf("error opening license text file %q: %w", licenseText, err)
- }
-
- // read the file
- text, err := io.ReadAll(f)
- if err != nil {
- return nil, nil, fmt.Errorf("error reading license text file %q: %w", licenseText, err)
- }
- // Making an spdx License and adding it to otherLicenses
- otherLicenses = append(otherLicenses, &spdx.OtherLicense{
- LicenseName: strings.Replace(licenses[licenseText], "LicenseRef-", "", -1),
- LicenseIdentifier: string(licenses[licenseText]),
- ExtractedText: string(text),
- })
- }
-
- deps := inputFiles(lg, pmix, licenseTexts)
- sort.Strings(deps)
-
- // Making the SPDX doc
- ci, err := builder2v2.BuildCreationInfoSection2_2("Organization", "Google LLC", nil)
- if err != nil {
- return nil, nil, fmt.Errorf("Unable to build creation info section for SPDX doc: %v\n", err)
- }
-
- ci.Created = ctx.creationTime()
-
- doc := &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: docName,
- DocumentNamespace: generateSPDXNamespace(ctx.buildid, ci.Created, files...),
- CreationInfo: ci,
- Packages: pkgs,
- Relationships: relationships,
- OtherLicenses: otherLicenses,
- }
-
- if err := spdxlib.ValidateDocument2_2(doc); err != nil {
- return nil, nil, fmt.Errorf("Unable to validate the SPDX doc: %v\n", err)
- }
-
- return doc, deps, nil
-}
diff --git a/tools/compliance/cmd/sbom/sbom_test.go b/tools/compliance/cmd/sbom/sbom_test.go
deleted file mode 100644
index 13ba66d..0000000
--- a/tools/compliance/cmd/sbom/sbom_test.go
+++ /dev/null
@@ -1,2558 +0,0 @@
-// Copyright 2022 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "os"
- "reflect"
- "strings"
- "testing"
- "time"
-
- "android/soong/tools/compliance"
-
- "github.com/spdx/tools-golang/builder/builder2v2"
- "github.com/spdx/tools-golang/spdx/common"
- spdx "github.com/spdx/tools-golang/spdx/v2_2"
-)
-
-func TestMain(m *testing.M) {
- // Change into the parent directory before running the tests
- // so they can find the testdata directory.
- if err := os.Chdir(".."); err != nil {
- fmt.Printf("failed to change to testdata directory: %s\n", err)
- os.Exit(1)
- }
- os.Exit(m.Run())
-}
-
-func Test(t *testing.T) {
- tests := []struct {
- condition string
- name string
- outDir string
- roots []string
- stripPrefix string
- expectedOut *spdx.Document
- expectedDeps []string
- }{
- {
- condition: "firstparty",
- name: "apex",
- roots: []string{"highest.apex.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-firstparty-highest.apex",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/highest.apex.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-firstparty-highest.apex.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-highest.apex.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/firstparty/bin/bin1.meta_lic",
- "testdata/firstparty/bin/bin2.meta_lic",
- "testdata/firstparty/highest.apex.meta_lic",
- "testdata/firstparty/lib/liba.so.meta_lic",
- "testdata/firstparty/lib/libb.so.meta_lic",
- "testdata/firstparty/lib/libc.a.meta_lic",
- "testdata/firstparty/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "firstparty",
- name: "application",
- roots: []string{"application.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-firstparty-application",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/application.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-firstparty-application.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-application.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-bin-bin3.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin3.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin3.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
- Relationship: "BUILD_TOOL_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/firstparty/application.meta_lic",
- "testdata/firstparty/bin/bin3.meta_lic",
- "testdata/firstparty/lib/liba.so.meta_lic",
- "testdata/firstparty/lib/libb.so.meta_lic",
- },
- },
- {
- condition: "firstparty",
- name: "container",
- roots: []string{"container.zip.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-firstparty-container.zip",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/container.zip.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-firstparty-container.zip.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-container.zip.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/firstparty/bin/bin1.meta_lic",
- "testdata/firstparty/bin/bin2.meta_lic",
- "testdata/firstparty/container.zip.meta_lic",
- "testdata/firstparty/lib/liba.so.meta_lic",
- "testdata/firstparty/lib/libb.so.meta_lic",
- "testdata/firstparty/lib/libc.a.meta_lic",
- "testdata/firstparty/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "firstparty",
- name: "binary",
- roots: []string{"bin/bin1.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-firstparty-bin-bin1",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/bin/bin1.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-firstparty-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-firstparty-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/firstparty/bin/bin1.meta_lic",
- "testdata/firstparty/lib/liba.so.meta_lic",
- "testdata/firstparty/lib/libc.a.meta_lic",
- },
- },
- {
- condition: "firstparty",
- name: "library",
- roots: []string{"lib/libd.so.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-firstparty-lib-libd.so",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/lib/libd.so.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-firstparty-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
- Relationship: "DESCRIBES",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/firstparty/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "notice",
- name: "apex",
- roots: []string{"highest.apex.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-notice-highest.apex",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/highest.apex.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-notice-highest.apex.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-highest.apex.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/notice/bin/bin1.meta_lic",
- "testdata/notice/bin/bin2.meta_lic",
- "testdata/notice/highest.apex.meta_lic",
- "testdata/notice/lib/liba.so.meta_lic",
- "testdata/notice/lib/libb.so.meta_lic",
- "testdata/notice/lib/libc.a.meta_lic",
- "testdata/notice/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "notice",
- name: "container",
- roots: []string{"container.zip.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-notice-container.zip",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/container.zip.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-notice-container.zip.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-container.zip.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/notice/bin/bin1.meta_lic",
- "testdata/notice/bin/bin2.meta_lic",
- "testdata/notice/container.zip.meta_lic",
- "testdata/notice/lib/liba.so.meta_lic",
- "testdata/notice/lib/libb.so.meta_lic",
- "testdata/notice/lib/libc.a.meta_lic",
- "testdata/notice/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "notice",
- name: "application",
- roots: []string{"application.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-notice-application",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/application.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-notice-application.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-application.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-bin-bin3.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin3.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-bin-bin3.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
- Relationship: "BUILD_TOOL_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/notice/application.meta_lic",
- "testdata/notice/bin/bin3.meta_lic",
- "testdata/notice/lib/liba.so.meta_lic",
- "testdata/notice/lib/libb.so.meta_lic",
- },
- },
- {
- condition: "notice",
- name: "binary",
- roots: []string{"bin/bin1.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-notice-bin-bin1",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/bin/bin1.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-notice-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-notice-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/notice/bin/bin1.meta_lic",
- "testdata/notice/lib/liba.so.meta_lic",
- "testdata/notice/lib/libc.a.meta_lic",
- },
- },
- {
- condition: "notice",
- name: "library",
- roots: []string{"lib/libd.so.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-notice-lib-libd.so",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/lib/libd.so.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-notice-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
- Relationship: "DESCRIBES",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/notice/NOTICE_LICENSE",
- "testdata/notice/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "reciprocal",
- name: "apex",
- roots: []string{"highest.apex.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-reciprocal-highest.apex",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/highest.apex.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-reciprocal-highest.apex.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-highest.apex.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- ExtractedText: "$$$Reciprocal License$$$\n",
- LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/reciprocal/RECIPROCAL_LICENSE",
- "testdata/reciprocal/bin/bin1.meta_lic",
- "testdata/reciprocal/bin/bin2.meta_lic",
- "testdata/reciprocal/highest.apex.meta_lic",
- "testdata/reciprocal/lib/liba.so.meta_lic",
- "testdata/reciprocal/lib/libb.so.meta_lic",
- "testdata/reciprocal/lib/libc.a.meta_lic",
- "testdata/reciprocal/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "reciprocal",
- name: "application",
- roots: []string{"application.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-reciprocal-application",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/application.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-reciprocal-application.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-application.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-bin-bin3.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin3.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin3.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
- Relationship: "BUILD_TOOL_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- ExtractedText: "$$$Reciprocal License$$$\n",
- LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/reciprocal/RECIPROCAL_LICENSE",
- "testdata/reciprocal/application.meta_lic",
- "testdata/reciprocal/bin/bin3.meta_lic",
- "testdata/reciprocal/lib/liba.so.meta_lic",
- "testdata/reciprocal/lib/libb.so.meta_lic",
- },
- },
- {
- condition: "reciprocal",
- name: "binary",
- roots: []string{"bin/bin1.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-reciprocal-bin-bin1",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/bin/bin1.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-reciprocal-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- PackageName: "testdata-reciprocal-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- ExtractedText: "$$$Reciprocal License$$$\n",
- LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/reciprocal/RECIPROCAL_LICENSE",
- "testdata/reciprocal/bin/bin1.meta_lic",
- "testdata/reciprocal/lib/liba.so.meta_lic",
- "testdata/reciprocal/lib/libc.a.meta_lic",
- },
- },
- {
- condition: "reciprocal",
- name: "library",
- roots: []string{"lib/libd.so.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-reciprocal-lib-libd.so",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/lib/libd.so.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-reciprocal-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libd.so.meta_lic"),
- Relationship: "DESCRIBES",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/notice/NOTICE_LICENSE",
- "testdata/reciprocal/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "restricted",
- name: "apex",
- roots: []string{"highest.apex.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-restricted-highest.apex",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/highest.apex.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-restricted-highest.apex.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-highest.apex.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-restricted-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-restricted-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- ExtractedText: "$$$Reciprocal License$$$\n",
- LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- ExtractedText: "###Restricted License###\n",
- LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/reciprocal/RECIPROCAL_LICENSE",
- "testdata/restricted/RESTRICTED_LICENSE",
- "testdata/restricted/bin/bin1.meta_lic",
- "testdata/restricted/bin/bin2.meta_lic",
- "testdata/restricted/highest.apex.meta_lic",
- "testdata/restricted/lib/liba.so.meta_lic",
- "testdata/restricted/lib/libb.so.meta_lic",
- "testdata/restricted/lib/libc.a.meta_lic",
- "testdata/restricted/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "restricted",
- name: "container",
- roots: []string{"container.zip.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-restricted-container.zip",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/container.zip.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-restricted-container.zip.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-container.zip.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-restricted-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-restricted-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- ExtractedText: "$$$Reciprocal License$$$\n",
- LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- ExtractedText: "###Restricted License###\n",
- LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/reciprocal/RECIPROCAL_LICENSE",
- "testdata/restricted/RESTRICTED_LICENSE",
- "testdata/restricted/bin/bin1.meta_lic",
- "testdata/restricted/bin/bin2.meta_lic",
- "testdata/restricted/container.zip.meta_lic",
- "testdata/restricted/lib/liba.so.meta_lic",
- "testdata/restricted/lib/libb.so.meta_lic",
- "testdata/restricted/lib/libc.a.meta_lic",
- "testdata/restricted/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "restricted",
- name: "binary",
- roots: []string{"bin/bin1.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-restricted-bin-bin1",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/bin/bin1.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-restricted-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-restricted-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
- ExtractedText: "$$$Reciprocal License$$$\n",
- LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- ExtractedText: "###Restricted License###\n",
- LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/reciprocal/RECIPROCAL_LICENSE",
- "testdata/restricted/RESTRICTED_LICENSE",
- "testdata/restricted/bin/bin1.meta_lic",
- "testdata/restricted/lib/liba.so.meta_lic",
- "testdata/restricted/lib/libc.a.meta_lic",
- },
- },
- {
- condition: "restricted",
- name: "library",
- roots: []string{"lib/libd.so.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-restricted-lib-libd.so",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/lib/libd.so.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-restricted-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
- Relationship: "DESCRIBES",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/notice/NOTICE_LICENSE",
- "testdata/restricted/lib/libd.so.meta_lic",
- },
- },
- {
- condition: "proprietary",
- name: "apex",
- roots: []string{"highest.apex.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-proprietary-highest.apex",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/highest.apex.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-proprietary-highest.apex.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-highest.apex.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- ExtractedText: "@@@Proprietary License@@@\n",
- LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- ExtractedText: "###Restricted License###\n",
- LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/proprietary/PROPRIETARY_LICENSE",
- "testdata/proprietary/bin/bin1.meta_lic",
- "testdata/proprietary/bin/bin2.meta_lic",
- "testdata/proprietary/highest.apex.meta_lic",
- "testdata/proprietary/lib/liba.so.meta_lic",
- "testdata/proprietary/lib/libb.so.meta_lic",
- "testdata/proprietary/lib/libc.a.meta_lic",
- "testdata/proprietary/lib/libd.so.meta_lic",
- "testdata/restricted/RESTRICTED_LICENSE",
- },
- },
- {
- condition: "proprietary",
- name: "container",
- roots: []string{"container.zip.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-proprietary-container.zip",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/container.zip.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-proprietary-container.zip.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-container.zip.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-bin-bin2.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin2.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- ExtractedText: "@@@Proprietary License@@@\n",
- LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- ExtractedText: "###Restricted License###\n",
- LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/notice/NOTICE_LICENSE",
- "testdata/proprietary/PROPRIETARY_LICENSE",
- "testdata/proprietary/bin/bin1.meta_lic",
- "testdata/proprietary/bin/bin2.meta_lic",
- "testdata/proprietary/container.zip.meta_lic",
- "testdata/proprietary/lib/liba.so.meta_lic",
- "testdata/proprietary/lib/libb.so.meta_lic",
- "testdata/proprietary/lib/libc.a.meta_lic",
- "testdata/proprietary/lib/libd.so.meta_lic",
- "testdata/restricted/RESTRICTED_LICENSE",
- },
- },
- {
- condition: "proprietary",
- name: "application",
- roots: []string{"application.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-proprietary-application",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/application.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-proprietary-application.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-application.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-bin-bin3.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin3.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libb.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin3.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
- Relationship: "BUILD_TOOL_OF",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
- Relationship: "RUNTIME_DEPENDENCY_OF",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- ExtractedText: "@@@Proprietary License@@@\n",
- LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
- ExtractedText: "###Restricted License###\n",
- LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/proprietary/PROPRIETARY_LICENSE",
- "testdata/proprietary/application.meta_lic",
- "testdata/proprietary/bin/bin3.meta_lic",
- "testdata/proprietary/lib/liba.so.meta_lic",
- "testdata/proprietary/lib/libb.so.meta_lic",
- "testdata/restricted/RESTRICTED_LICENSE",
- },
- },
- {
- condition: "proprietary",
- name: "binary",
- roots: []string{"bin/bin1.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-proprietary-bin-bin1",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/bin/bin1.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-proprietary-bin-bin1.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- {
- PackageName: "testdata-proprietary-lib-libc.a.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- Relationship: "DESCRIBES",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
- Relationship: "CONTAINS",
- },
- {
- RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
- Relationship: "CONTAINS",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
- ExtractedText: "&&&First Party License&&&\n",
- LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
- },
- {
- LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
- ExtractedText: "@@@Proprietary License@@@\n",
- LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/firstparty/FIRST_PARTY_LICENSE",
- "testdata/proprietary/PROPRIETARY_LICENSE",
- "testdata/proprietary/bin/bin1.meta_lic",
- "testdata/proprietary/lib/liba.so.meta_lic",
- "testdata/proprietary/lib/libc.a.meta_lic",
- },
- },
- {
- condition: "proprietary",
- name: "library",
- roots: []string{"lib/libd.so.meta_lic"},
- expectedOut: &spdx.Document{
- SPDXVersion: "SPDX-2.2",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: "DOCUMENT",
- DocumentName: "testdata-proprietary-lib-libd.so",
- DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/lib/libd.so.meta_lic"),
- CreationInfo: getCreationInfo(t),
- Packages: []*spdx.Package{
- {
- PackageName: "testdata-proprietary-lib-libd.so.meta_lic",
- PackageVersion: "NOASSERTION",
- PackageDownloadLocation: "NOASSERTION",
- PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
- PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- },
- },
- Relationships: []*spdx.Relationship{
- {
- RefA: common.MakeDocElementID("", "DOCUMENT"),
- RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
- Relationship: "DESCRIBES",
- },
- },
- OtherLicenses: []*spdx.OtherLicense{
- {
- LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
- ExtractedText: "%%%Notice License%%%\n",
- LicenseName: "testdata-notice-NOTICE_LICENSE",
- },
- },
- },
- expectedDeps: []string{
- "testdata/notice/NOTICE_LICENSE",
- "testdata/proprietary/lib/libd.so.meta_lic",
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
- stdout := &bytes.Buffer{}
- stderr := &bytes.Buffer{}
-
- rootFiles := make([]string, 0, len(tt.roots))
- for _, r := range tt.roots {
- rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
- }
-
- ctx := context{stdout, stderr, compliance.GetFS(tt.outDir), "", []string{tt.stripPrefix}, fakeTime, ""}
-
- spdxDoc, deps, err := sbomGenerator(&ctx, rootFiles...)
- if err != nil {
- t.Fatalf("sbom: error = %v, stderr = %v", err, stderr)
- return
- }
- if stderr.Len() > 0 {
- t.Errorf("sbom: gotStderr = %v, want none", stderr)
- }
-
- if err := validate(spdxDoc); err != nil {
- t.Fatalf("sbom: document fails to validate: %v", err)
- }
-
- gotData, err := json.Marshal(spdxDoc)
- if err != nil {
- t.Fatalf("sbom: failed to marshal spdx doc: %v", err)
- return
- }
-
- t.Logf("Got SPDX Doc: %s", string(gotData))
-
- expectedData, err := json.Marshal(tt.expectedOut)
- if err != nil {
- t.Fatalf("sbom: failed to marshal spdx doc: %v", err)
- return
- }
-
- t.Logf("Want SPDX Doc: %s", string(expectedData))
-
- // compare the spdx Docs
- compareSpdxDocs(t, spdxDoc, tt.expectedOut)
-
- // compare deps
- t.Logf("got deps: %q", deps)
-
- t.Logf("want deps: %q", tt.expectedDeps)
-
- if g, w := deps, tt.expectedDeps; !reflect.DeepEqual(g, w) {
- t.Errorf("unexpected deps, wanted:\n%s\ngot:\n%s\n",
- strings.Join(w, "\n"), strings.Join(g, "\n"))
- }
- })
- }
-}
-
-func TestGenerateSPDXNamespace(t *testing.T) {
-
- buildID1 := "example-1"
- buildID2 := "example-2"
- files1 := "file1"
- timestamp1 := "2022-05-01"
- timestamp2 := "2022-05-02"
- files2 := "file2"
-
- // Test case 1: different timestamps, same files
- nsh1 := generateSPDXNamespace("", timestamp1, files1)
- nsh2 := generateSPDXNamespace("", timestamp2, files1)
-
- if nsh1 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp1, files1)
- }
-
- if nsh2 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp2, files1)
- }
-
- if nsh1 == nsh2 {
- t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", "", timestamp1, files1, "", timestamp2, files1)
- }
-
- // Test case 2: different build ids, same timestamps and files
- nsh1 = generateSPDXNamespace(buildID1, timestamp1, files1)
- nsh2 = generateSPDXNamespace(buildID2, timestamp1, files1)
-
- if nsh1 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files1)
- }
-
- if nsh2 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID2, timestamp1, files1)
- }
-
- if nsh1 == nsh2 {
- t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", buildID1, timestamp1, files1, buildID2, timestamp1, files1)
- }
-
- // Test case 3: same build ids and files, different timestamps
- nsh1 = generateSPDXNamespace(buildID1, timestamp1, files1)
- nsh2 = generateSPDXNamespace(buildID1, timestamp2, files1)
-
- if nsh1 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files1)
- }
-
- if nsh2 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp2, files1)
- }
-
- if nsh1 != nsh2 {
- t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected same namespace hashes, but got different: %s and %s", buildID1, timestamp1, files1, buildID2, timestamp1, files1, nsh1, nsh2)
- }
-
- // Test case 4: same build ids and timestamps, different files
- nsh1 = generateSPDXNamespace(buildID1, timestamp1, files1)
- nsh2 = generateSPDXNamespace(buildID1, timestamp1, files2)
-
- if nsh1 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files1)
- }
-
- if nsh2 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files2)
- }
-
- if nsh1 == nsh2 {
- t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", buildID1, timestamp1, files1, buildID1, timestamp1, files2)
- }
-
- // Test case 5: empty build ids, same timestamps and different files
- nsh1 = generateSPDXNamespace("", timestamp1, files1)
- nsh2 = generateSPDXNamespace("", timestamp1, files2)
-
- if nsh1 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp1, files1)
- }
-
- if nsh2 == "" {
- t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp1, files2)
- }
-
- if nsh1 == nsh2 {
- t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", "", timestamp1, files1, "", timestamp1, files2)
- }
-}
-
-func getCreationInfo(t *testing.T) *spdx.CreationInfo {
- ci, err := builder2v2.BuildCreationInfoSection2_2("Organization", "Google LLC", nil)
- if err != nil {
- t.Errorf("Unable to get creation info: %v", err)
- return nil
- }
- return ci
-}
-
-// validate returns an error if the Document is found to be invalid
-func validate(doc *spdx.Document) error {
- if doc.SPDXVersion == "" {
- return fmt.Errorf("SPDXVersion: got nothing, want spdx version")
- }
- if doc.DataLicense == "" {
- return fmt.Errorf("DataLicense: got nothing, want Data License")
- }
- if doc.SPDXIdentifier == "" {
- return fmt.Errorf("SPDXIdentifier: got nothing, want SPDX Identifier")
- }
- if doc.DocumentName == "" {
- return fmt.Errorf("DocumentName: got nothing, want Document Name")
- }
- if c := fmt.Sprintf("%v", doc.CreationInfo.Creators[1].Creator); c != "Google LLC" {
- return fmt.Errorf("Creator: got %v, want 'Google LLC'", c)
- }
- _, err := time.Parse(time.RFC3339, doc.CreationInfo.Created)
- if err != nil {
- return fmt.Errorf("Invalid time spec: %q: got error %q, want no error", doc.CreationInfo.Created, err)
- }
-
- for _, license := range doc.OtherLicenses {
- if license.ExtractedText == "" {
- return fmt.Errorf("License file: %q: got nothing, want license text", license.LicenseName)
- }
- }
- return nil
-}
-
-// compareSpdxDocs deep-compares two spdx docs by going through the info section, packages, relationships and licenses
-func compareSpdxDocs(t *testing.T, actual, expected *spdx.Document) {
-
- if actual == nil || expected == nil {
- t.Errorf("SBOM: SPDX Doc is nil! Got %v: Expected %v", actual, expected)
- }
-
- if actual.DocumentName != expected.DocumentName {
- t.Errorf("sbom: unexpected SPDX Document Name got %q, want %q", actual.DocumentName, expected.DocumentName)
- }
-
- if actual.SPDXVersion != expected.SPDXVersion {
- t.Errorf("sbom: unexpected SPDX Version got %s, want %s", actual.SPDXVersion, expected.SPDXVersion)
- }
-
- if actual.DataLicense != expected.DataLicense {
- t.Errorf("sbom: unexpected SPDX DataLicense got %s, want %s", actual.DataLicense, expected.DataLicense)
- }
-
- if actual.SPDXIdentifier != expected.SPDXIdentifier {
- t.Errorf("sbom: unexpected SPDX Identified got %s, want %s", actual.SPDXIdentifier, expected.SPDXIdentifier)
- }
-
- if actual.DocumentNamespace != expected.DocumentNamespace {
- t.Errorf("sbom: unexpected SPDX Document Namespace got %s, want %s", actual.DocumentNamespace, expected.DocumentNamespace)
- }
-
- // compare creation info
- compareSpdxCreationInfo(t, actual.CreationInfo, expected.CreationInfo)
-
- // compare packages
- if len(actual.Packages) != len(expected.Packages) {
- t.Errorf("SBOM: Number of Packages is different! Got %d: Expected %d", len(actual.Packages), len(expected.Packages))
- }
-
- for i, pkg := range actual.Packages {
- if !compareSpdxPackages(t, i, pkg, expected.Packages[i]) {
- break
- }
- }
-
- // compare licenses
- if len(actual.OtherLicenses) != len(expected.OtherLicenses) {
- t.Errorf("SBOM: Number of Licenses in actual is different! Got %d: Expected %d", len(actual.OtherLicenses), len(expected.OtherLicenses))
- }
- for i, license := range actual.OtherLicenses {
- if !compareLicenses(t, i, license, expected.OtherLicenses[i]) {
- break
- }
- }
-
- //compare Relationships
- if len(actual.Relationships) != len(expected.Relationships) {
- t.Errorf("SBOM: Number of Licenses in actual is different! Got %d: Expected %d", len(actual.Relationships), len(expected.Relationships))
- }
- for i, rl := range actual.Relationships {
- if !compareRelationShips(t, i, rl, expected.Relationships[i]) {
- break
- }
- }
-}
-
-func compareSpdxCreationInfo(t *testing.T, actual, expected *spdx.CreationInfo) {
- if actual == nil || expected == nil {
- t.Errorf("SBOM: Creation info is nil! Got %q: Expected %q", actual, expected)
- }
-
- if actual.LicenseListVersion != expected.LicenseListVersion {
- t.Errorf("SBOM: Creation info license version Error! Got %s: Expected %s", actual.LicenseListVersion, expected.LicenseListVersion)
- }
-
- if len(actual.Creators) != len(expected.Creators) {
- t.Errorf("SBOM: Creation info creators Error! Got %d: Expected %d", len(actual.Creators), len(expected.Creators))
- }
-
- for i, info := range actual.Creators {
- if info != expected.Creators[i] {
- t.Errorf("SBOM: Creation info creators Error! Got %q: Expected %q", info, expected.Creators[i])
- }
- }
-}
-
-func compareSpdxPackages(t *testing.T, i int, actual, expected *spdx.Package) bool {
- if actual == nil || expected == nil {
- t.Errorf("SBOM: Packages are nil at index %d! Got %v: Expected %v", i, actual, expected)
- return false
- }
- if actual.PackageName != expected.PackageName {
- t.Errorf("SBOM: Package name Error at index %d! Got %s: Expected %s", i, actual.PackageName, expected.PackageName)
- return false
- }
-
- if actual.PackageVersion != expected.PackageVersion {
- t.Errorf("SBOM: Package version Error at index %d! Got %s: Expected %s", i, actual.PackageVersion, expected.PackageVersion)
- return false
- }
-
- if actual.PackageSPDXIdentifier != expected.PackageSPDXIdentifier {
- t.Errorf("SBOM: Package identifier Error at index %d! Got %s: Expected %s", i, actual.PackageSPDXIdentifier, expected.PackageSPDXIdentifier)
- return false
- }
-
- if actual.PackageDownloadLocation != expected.PackageDownloadLocation {
- t.Errorf("SBOM: Package download location Error at index %d! Got %s: Expected %s", i, actual.PackageDownloadLocation, expected.PackageDownloadLocation)
- return false
- }
-
- if actual.PackageLicenseConcluded != expected.PackageLicenseConcluded {
- t.Errorf("SBOM: Package license concluded Error at index %d! Got %s: Expected %s", i, actual.PackageLicenseConcluded, expected.PackageLicenseConcluded)
- return false
- }
- return true
-}
-
-func compareRelationShips(t *testing.T, i int, actual, expected *spdx.Relationship) bool {
- if actual == nil || expected == nil {
- t.Errorf("SBOM: Relationships is nil at index %d! Got %v: Expected %v", i, actual, expected)
- return false
- }
-
- if actual.RefA != expected.RefA {
- t.Errorf("SBOM: Relationship RefA Error at index %d! Got %s: Expected %s", i, actual.RefA, expected.RefA)
- return false
- }
-
- if actual.RefB != expected.RefB {
- t.Errorf("SBOM: Relationship RefB Error at index %d! Got %s: Expected %s", i, actual.RefB, expected.RefB)
- return false
- }
-
- if actual.Relationship != expected.Relationship {
- t.Errorf("SBOM: Relationship type Error at index %d! Got %s: Expected %s", i, actual.Relationship, expected.Relationship)
- return false
- }
- return true
-}
-
-func compareLicenses(t *testing.T, i int, actual, expected *spdx.OtherLicense) bool {
- if actual == nil || expected == nil {
- t.Errorf("SBOM: Licenses is nil at index %d! Got %v: Expected %v", i, actual, expected)
- return false
- }
-
- if actual.LicenseName != expected.LicenseName {
- t.Errorf("SBOM: License Name Error at index %d! Got %s: Expected %s", i, actual.LicenseName, expected.LicenseName)
- return false
- }
-
- if actual.LicenseIdentifier != expected.LicenseIdentifier {
- t.Errorf("SBOM: License Identifier Error at index %d! Got %s: Expected %s", i, actual.LicenseIdentifier, expected.LicenseIdentifier)
- return false
- }
-
- if actual.ExtractedText != expected.ExtractedText {
- t.Errorf("SBOM: License Extracted Text Error at index %d! Got: %q want: %q", i, actual.ExtractedText, expected.ExtractedText)
- return false
- }
- return true
-}
-
-func fakeTime() string {
- t := time.UnixMicro(0)
- return t.UTC().Format("2006-01-02T15:04:05Z")
-}