11// Copyright (c) 2020, Control Command Inc. All rights reserved.
2- // Copyright (c) 2020, Sylabs Inc. All rights reserved.
2+ // Copyright (c) 2020-2021 , Sylabs Inc. All rights reserved.
33// This software is licensed under a 3-clause BSD license. Please consult the LICENSE.md file
44// distributed with the sources of this project regarding your rights to use or distribute this
55// software.
@@ -16,15 +16,15 @@ import (
1616
1717 "github.com/sylabs/singularity/internal/pkg/buildcfg"
1818
19+ "github.com/ProtonMail/go-crypto/openpgp"
20+ "github.com/ProtonMail/go-crypto/openpgp/packet"
1921 "github.com/fatih/color"
20- "github.com/sylabs/sif/pkg/integrity"
21- "github.com/sylabs/sif/pkg/sif"
22+ "github.com/sylabs/sif/v2/ pkg/integrity"
23+ "github.com/sylabs/sif/v2/ pkg/sif"
2224 "github.com/sylabs/singularity/internal/app/singularity"
2325 "github.com/sylabs/singularity/internal/pkg/util/interactive"
2426 "github.com/sylabs/singularity/pkg/sylog"
2527 "github.com/sylabs/singularity/pkg/sypgp"
26- "golang.org/x/crypto/openpgp"
27- "golang.org/x/crypto/openpgp/packet"
2828)
2929
3030var (
@@ -175,28 +175,22 @@ func outputVerify(f *sif.FileImage, r integrity.VerifyResult) bool {
175175 fmt .Printf ("%-4s|%-8s|%-8s|%s\n " , "ID" , "GROUP" , "LINK" , "TYPE" )
176176 fmt .Print ("------------------------------------------------\n " )
177177 }
178- for _ , id := range r .Verified () {
179- od , _ , err := f .GetFromDescrID (id )
180- if err != nil {
181- sylog .Errorf ("failed to get descriptor: %v" , err )
182- return false
183- }
184-
178+ for _ , od := range r .Verified () {
185179 group := "NONE"
186- if gid := od .Groupid ; gid != sif . DescrUnusedGroup {
187- group = fmt .Sprintf ("%d" , gid &^ sif . DescrGroupMask )
180+ if gid := od .GroupID () ; gid != 0 {
181+ group = fmt .Sprintf ("%d" , gid )
188182 }
189183
190184 link := "NONE"
191- if l := od .Link ; l != sif . DescrUnusedLink {
192- if l & sif . DescrGroupMask == sif . DescrGroupMask {
193- link = fmt .Sprintf ("%d (G)" , l &^ sif . DescrGroupMask )
185+ if l , isGroup := od .LinkedID () ; l != 0 {
186+ if isGroup {
187+ link = fmt .Sprintf ("%d (G)" , l )
194188 } else {
195189 link = fmt .Sprintf ("%d" , l )
196190 }
197191 }
198192
199- fmt .Printf ("%-4d|%-8s|%-8s|%s\n " , id , group , link , od .Datatype )
193+ fmt .Printf ("%-4d|%-8s|%-8s|%s\n " , od . ID () , group , link , od .DataType () )
200194 }
201195
202196 if err := r .Error (); err != nil {
@@ -246,15 +240,9 @@ func getJSONCallback(kl *keyList) singularity.VerifyCallback {
246240 }
247241
248242 // For each verified object, append an entry to the list.
249- for _ , id := range r .Verified () {
250- od , _ , err := f .GetFromDescrID (id )
251- if err != nil {
252- sylog .Errorf ("failed to get descriptor: %v" , err )
253- continue
254- }
255-
243+ for _ , od := range r .Verified () {
256244 ke := keyEntity {
257- Partition : od .Datatype .String (),
245+ Partition : od .DataType () .String (),
258246 Name : name ,
259247 Fingerprint : fp ,
260248 KeyLocal : keyLocal ,
@@ -266,14 +254,14 @@ func getJSONCallback(kl *keyList) singularity.VerifyCallback {
266254
267255 var integrityError * integrity.ObjectIntegrityError
268256 if errors .As (r .Error (), & integrityError ) {
269- od , _ , err := f .GetFromDescrID ( integrityError .ID )
257+ od , err := f .GetDescriptor ( sif . WithID ( integrityError .ID ) )
270258 if err != nil {
271259 sylog .Errorf ("failed to get descriptor: %v" , err )
272260 return false
273261 }
274262
275263 ke := keyEntity {
276- Partition : od .Datatype .String (),
264+ Partition : od .DataType () .String (),
277265 Name : name ,
278266 Fingerprint : fp ,
279267 KeyLocal : keyLocal ,
0 commit comments