File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -295,9 +295,16 @@ type provenanceEnvironment struct {
295295func (p * Package ) inTotoMaterials () ([]in_toto.ProvenanceMaterial , error ) {
296296 res := make ([]in_toto.ProvenanceMaterial , 0 , len (p .Sources ))
297297 for _ , src := range p .Sources {
298- if stat , err := os .Lstat (src ); err != nil {
298+ stat , err := os .Lstat (src );
299+ if err != nil {
299300 return nil , err
300- } else if ! stat .Mode ().IsRegular () {
301+ }
302+
303+ if stat .Mode ().IsDir () {
304+ continue
305+ }
306+
307+ if ! stat .Mode ().IsRegular () {
301308 continue
302309 }
303310
@@ -326,12 +333,14 @@ func sha256Hash(fn string) (res string, err error) {
326333 return "" , xerrors .Errorf ("cannot compute hash of %s: %w" , fn , err )
327334 }
328335
336+ defer f .Close ()
337+
329338 hash := sha256 .New ()
330339 _ , err = io .Copy (hash , f )
331340 if err != nil {
332341 return "" , xerrors .Errorf ("cannot compute hash of %s: %w" , fn , err )
333342 }
334- f . Close ()
343+
335344
336345 return fmt .Sprintf ("%x" , hash .Sum (nil )), nil
337346}
You can’t perform that action at this time.
0 commit comments