Skip to content

Commit

Permalink
update TODO and log entries
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
  • Loading branch information
wagoodman committed Nov 19, 2021
1 parent cde16e1 commit eadb555
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
9 changes: 3 additions & 6 deletions cmd/power_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import (
"fmt"
"sync"

"github.com/anchore/syft/internal/formats/syftjson"

"github.com/anchore/syft/syft/artifact"

"github.com/anchore/syft/syft/sbom"

"github.com/anchore/stereoscope"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/bus"
"github.com/anchore/syft/internal/formats/syftjson"
"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/internal/ui"
"github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/event"
"github.com/anchore/syft/syft/sbom"
"github.com/anchore/syft/syft/source"
"github.com/pkg/profile"
"github.com/spf13/cobra"
Expand Down
17 changes: 7 additions & 10 deletions internal/formats/spdx22json/to_format_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import (
"strings"
"time"

"github.com/anchore/syft/syft/file"

"github.com/anchore/syft/syft/artifact"

"github.com/anchore/syft/syft/sbom"

"github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/formats/common/spdxhelpers"
"github.com/anchore/syft/internal/formats/spdx22json/model"
"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/internal/spdxlicense"
"github.com/anchore/syft/internal/version"
"github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/sbom"
"github.com/anchore/syft/syft/source"
"github.com/google/uuid"
)
Expand Down Expand Up @@ -173,8 +171,7 @@ func toFiles(s sbom.SBOM) []model.File {
results = append(results, model.File{
Item: model.Item{
Element: model.Element{
SPDXID: string(coordinates.ID()),
// TODO: this is encoding layer id... is there a better way?
SPDXID: string(coordinates.ID()),
Name: filepath.Base(coordinates.RealPath),
Comment: comment,
},
Expand Down Expand Up @@ -231,7 +228,7 @@ func toFileTypes(metadata *source.FileMetadata) (ty []string) {
ty = append(ty, string(model.ArchiveFileType))
}

// TODO: source, spdx, and documentation
// TODO: add support for source, spdx, and documentation file types
if len(ty) == 0 {
ty = append(ty, string(model.OtherFileType))
}
Expand All @@ -244,7 +241,7 @@ func toRelationships(relationships []artifact.Relationship) (result []model.Rela
exists, relationshipType, comment := lookupRelationship(r.Type)

if !exists {
// TODO: should we warn about lossyness here?
log.Warnf("unable to convert relationship from SPDX 2.2 JSON, dropping: %+v", r)
continue
}

Expand Down
1 change: 0 additions & 1 deletion internal/formats/syftjson/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

func encoder(output io.Writer, s sbom.SBOM, appConfig interface{}) error {
// TODO: application config not available yet
doc := ToFormatModel(s, appConfig)

enc := json.NewEncoder(output)
Expand Down
11 changes: 5 additions & 6 deletions syft/pkg/cataloger/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func Catalog(resolver source.FileResolver, theDistro *distro.Distro, catalogers
catalog := pkg.NewCatalog()
var allRelationships []artifact.Relationship

// TODO: update to show relationships
filesProcessed, packagesDiscovered := newMonitor()

// perform analysis, accumulating errors for each failed analysis
Expand All @@ -60,7 +59,6 @@ func Catalog(resolver source.FileResolver, theDistro *distro.Distro, catalogers

catalogedPackages := len(packages)

// TODO: update to show relationships and files
log.Debugf("package cataloger %q discovered %d packages", theCataloger.Name(), catalogedPackages)
packagesDiscovered.N += int64(catalogedPackages)

Expand All @@ -71,7 +69,6 @@ func Catalog(resolver source.FileResolver, theDistro *distro.Distro, catalogers
// generate PURL
p.PURL = generatePackageURL(p, theDistro)

// TODO: break out into another function (refactor this function)
// create file-to-package relationships for files owned by the package
owningRelationships, err := packageFileOwnershipRelationships(p, resolver)
if err != nil {
Expand Down Expand Up @@ -113,9 +110,11 @@ func packageFileOwnershipRelationships(p pkg.Package, resolver source.FilePathRe
return nil, fmt.Errorf("unable to find path for path=%q: %w", path, err)
}

// if len(locations) == 0 {
// // TODO: this is notable, we should at least log it(?)... however, ideally there is something in the SBOM about this
// }
if len(locations) == 0 {
// TODO: this is a known-unknown that could later be persisted in the SBOM (or as a validation failure)
log.Warnf("unable to find location which a package claims ownership of: %s", path)
continue
}

for _, l := range locations {
relationships = append(relationships, artifact.Relationship{
Expand Down

0 comments on commit eadb555

Please sign in to comment.