Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
rchincha committed Apr 15, 2024
1 parent 13f890e commit 3c87b14
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/distro/apk/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func ParsePackage(input, output, author, organization, license string) error {

sfile := &spdx.File{
Entity: spdx.Entity{
Name: "/" + hdr.Name,
FileName: "/" + hdr.Name,
Checksum: map[string]string{
"SHA1": hex.EncodeToString(cksumSHA1[:]),
"SHA256": hex.EncodeToString(cksumSHA256[:]),
Expand Down
2 changes: 1 addition & 1 deletion pkg/distro/deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func ParsePackage(input, output, author, organization, license string) error {

sfile := &spdx.File{
Entity: spdx.Entity{
Name: hdr.Name[1:],
FileName: hdr.Name[1:],
Checksum: map[string]string{
"SHA1": hex.EncodeToString(cksumSHA1[:]),
"SHA256": hex.EncodeToString(cksumSHA256[:]),
Expand Down
2 changes: 1 addition & 1 deletion pkg/distro/rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func ParsePackage(input, output, author, organization, license string) error {
sfile.LicenseInfoInFile = pkglicense
sfile.SetEntity(
&spdx.Entity{
Name: finfo.Name(),
FileName: finfo.Name(),
Checksum: map[string]string{
"SHA1": hex.EncodeToString(cksumSHA1[:]),
"SHA256": hex.EncodeToString(cksumSHA256[:]),
Expand Down
6 changes: 4 additions & 2 deletions pkg/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ func BuildPackageFromDir(input string, kdoc *k8spdx.Document, kpkg *k8spdx.Packa
kfile := k8spdx.NewFile()
kfile.SetEntity(
&k8spdx.Entity{
Name: path,
FileName: path,
Checksum: map[string]string{
"SHA1": hex.EncodeToString(cksumSHA1[:]),
"SHA256": hex.EncodeToString(cksumSHA256[:]),
},
},
)
kfile.LicenseInfoInFile = license
kfile.BuildID("")

log.Error().Interface("conv3 kfile", kfile).Msg("CONV")

Expand Down Expand Up @@ -292,13 +293,14 @@ func BuildPackageFromFile(input string, kpkg *k8spdx.Package, license string) er
kfile := k8spdx.NewFile()
kfile.SetEntity(
&k8spdx.Entity{
Name: input,
FileName: input,
Checksum: map[string]string{
"SHA1": hex.EncodeToString(cksumSHA1[:]),
"SHA256": hex.EncodeToString(cksumSHA256[:]),
},
},
)
kfile.BuildID("")

log.Error().Interface("conv2 kfile", kfile).Msg("CONV")

Expand Down
16 changes: 8 additions & 8 deletions pkg/fs/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ func checkBOM(input, pathEntry string) error {

for _, pkg := range doc.Packages {
for _, file := range pkg.Files() {
symlink, err := filepath.EvalSymlinks(file.Name)
symlink, err := filepath.EvalSymlinks(file.FileName)
if err != nil {
log.Error().Err(err).Str("path", file.Name).Str("package", pkg.Name).Msg("unable to resolve symlink")
log.Error().Err(err).Str("path", file.FileName).Str("package", pkg.Name).Msg("unable to resolve symlink")

return err
}

if file.Name != pathEntry && symlink != pathEntry {
if file.FileName != pathEntry && symlink != pathEntry {
continue
}

file.Entity.Opts = &spdx.ObjectOptions{}

if err := file.ReadSourceFile(file.Name); err != nil {
log.Error().Err(err).Str("path", file.Name).Msg("doesn't match entry in SBOM document")
if err := file.ReadSourceFile(file.FileName); err != nil {
log.Error().Err(err).Str("path", file.FileName).Msg("doesn't match entry in SBOM document")

return err
}
Expand All @@ -58,9 +58,9 @@ func checkBOM(input, pathEntry string) error {
}

for _, file := range doc.Files {
symlink, err := filepath.EvalSymlinks(file.Name)
symlink, err := filepath.EvalSymlinks(file.FileName)
if err != nil {
log.Error().Err(err).Str("path", file.Name).Msg("unable to resolve symlink")
log.Error().Err(err).Str("path", file.FileName).Msg("unable to resolve symlink")

return err
}
Expand Down Expand Up @@ -126,7 +126,7 @@ func Verify(input, inventory, missing string) error {
sfile := spdx.NewFile()
sfile.SetEntity(
&spdx.Entity{
Name: entry.Path,
FileName: entry.Path,
Checksum: map[string]string{"SHA256": strings.Split(entry.Checksum, ":")[1]},
},
)
Expand Down

0 comments on commit 3c87b14

Please sign in to comment.