Skip to content

Commit

Permalink
Merge pull request #186 from edytuk/v2.11.3
Browse files Browse the repository at this point in the history
Merge sylabs/sif through v2.11.4
  • Loading branch information
DrDaveD authored May 22, 2023
2 parents 5a629b7 + d3ac26f commit 5dbb7a9
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 59 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,8 @@ jobs:
- name: Install syft
run: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin

- name: Check Configuration
run: curl -sSfL https://goreleaser.com/static/run | bash -s -- check

- name: Test Release
run: curl -sL https://git.io/goreleaser | bash -s -- --snapshot --skip-publish
run: curl -sSfL https://goreleaser.com/static/run | bash -s -- --snapshot --skip-publish
4 changes: 2 additions & 2 deletions pkg/integrity/dsse.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ func (s *dsseSigner) Sign(ctx context.Context, data []byte) ([]byte, error) {
return s.s.SignMessage(bytes.NewReader(data), opts...)
}

var errSignNotImplemented = errors.New("sign not implemented")
var errVerifyNotImplemented = errors.New("verify not implemented")

// Verify is not implemented, but required for the dsse.SignerVerifier interface.
func (s *dsseSigner) Verify(_ context.Context, _, _ []byte) error {
return errSignNotImplemented
return errVerifyNotImplemented
}

// Public returns the public key associated with s.
Expand Down
54 changes: 23 additions & 31 deletions pkg/sif/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,60 +626,52 @@ func (f *FileImage) SetPrimPart(id uint32, opts ...SetOpt) error {
return fmt.Errorf("%w", errNotPartition)
}

fs, pt, arch, err := descr.getPartitionMetadata()
if err != nil {
var p partition
if err := descr.getExtra(binaryUnmarshaler{&p}); err != nil {
return fmt.Errorf("%w", err)
}

// if already primary system partition, nothing to do
if pt == PartPrimSys {
if p.Parttype == PartPrimSys {
return nil
}

if pt != PartSystem {
if p.Parttype != PartSystem {
return fmt.Errorf("%w", errNotSystem)
}

olddescr, err := f.getDescriptor(WithPartitionType(PartPrimSys))
if err != nil && !errors.Is(err, ErrObjectNotFound) {
return fmt.Errorf("%w", err)
}
extra := partition{
Fstype: fs,
Parttype: PartPrimSys,
}
copy(extra.Arch[:], arch)

if err := descr.setExtra(extra); err != nil {
return fmt.Errorf("%w", err)
}

descr.ModifiedAt = so.t.Unix()

if olddescr != nil {
oldfs, _, oldarch, err := olddescr.getPartitionMetadata()
if err != nil {
// If there is currently a primary system partition, update it.
if d, err := f.getDescriptor(WithPartitionType(PartPrimSys)); err == nil {
var p partition
if err := d.getExtra(binaryUnmarshaler{&p}); err != nil {
return fmt.Errorf("%w", err)
}

oldextra := partition{
Fstype: oldfs,
Parttype: PartSystem,
Arch: getSIFArch(oldarch),
}
p.Parttype = PartSystem

if err := olddescr.setExtra(oldextra); err != nil {
if err := d.setExtra(p); err != nil {
return fmt.Errorf("%w", err)
}

olddescr.ModifiedAt = so.t.Unix()
d.ModifiedAt = so.t.Unix()
} else if !errors.Is(err, ErrObjectNotFound) {
return fmt.Errorf("%w", err)
}

// Update the descriptor of the new primary system partition.
p.Parttype = PartPrimSys

if err := descr.setExtra(p); err != nil {
return fmt.Errorf("%w", err)
}

descr.ModifiedAt = so.t.Unix()

if err := f.writeDescriptors(); err != nil {
return fmt.Errorf("%w", err)
}

f.h.Arch = getSIFArch(arch)
f.h.Arch = p.Arch
f.h.ModifiedAt = so.t.Unix()

if err := f.writeHeader(); err != nil {
Expand Down
Binary file modified pkg/sif/testdata/TestSetPrimPart/Deterministic.golden
Binary file not shown.
Binary file modified pkg/sif/testdata/TestSetPrimPart/One.golden
Binary file not shown.
Binary file modified pkg/sif/testdata/TestSetPrimPart/Two.golden
Binary file not shown.
Binary file modified pkg/sif/testdata/TestSetPrimPart/WithTime.golden
Binary file not shown.
26 changes: 13 additions & 13 deletions pkg/siftool/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Apptainer a Series of LF Projects LLC.
// For website terms of use, trademark policy, privacy policy and other
// project policies see https://lfprojects.org/policies
// Copyright (c) 2019-2022, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2023, Sylabs Inc. All rights reserved.
// Copyright (c) 2017, SingularityWare, LLC. All rights reserved.
// Copyright (c) 2017, Yannick Cote <[email protected]> All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
Expand Down Expand Up @@ -42,11 +42,11 @@ var (
func getAddExamples(rootPath string) string {
examples := []string{
rootPath +
" add image.sif recipe.def -datatype 1",
" add image.sif recipe.def --datatype 1",
rootPath +
" add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 ----partarch 2",
" add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 --partarch 2",
rootPath +
" add image.sif signature.bin -datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1",
" add image.sif signature.bin --datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1",
}
return strings.Join(examples, "\n")
}
Expand All @@ -58,34 +58,34 @@ func addFlags(fs *pflag.FlagSet) {
1-Deffile, 2-EnvVar, 3-Labels,
4-Partition, 5-Signature, 6-GenericJSON,
7-Generic, 8-CryptoMessage, 9-SBOM`)
partType = fs.Int32("parttype", 0, `the type of partition (with -datatype 4-Partition)
partType = fs.Int32("parttype", 0, `the type of partition (with --datatype 4-Partition)
[NEEDED, no default]:
1-System, 2-PrimSys, 3-Data,
4-Overlay`)
partFS = fs.Int32("partfs", 0, `the filesystem used (with -datatype 4-Partition)
partFS = fs.Int32("partfs", 0, `the filesystem used (with --datatype 4-Partition)
[NEEDED, no default]:
1-Squash, 2-Ext3, 3-ImmuObj,
4-Raw`)
partArch = fs.Int32("partarch", 0, `the main architecture used (with -datatype 4-Partition)
partArch = fs.Int32("partarch", 0, `the main architecture used (with --datatype 4-Partition)
[NEEDED, no default]:
1-386, 2-amd64, 3-arm,
4-arm64, 5-ppc64, 6-ppc64le,
7-mips, 8-mipsle, 9-mips64,
10-mips64le, 11-s390x, 12-riscv64`)
signHash = fs.Int32("signhash", 0, `the signature hash used (with -datatype 5-Signature)
signHash = fs.Int32("signhash", 0, `the signature hash used (with --datatype 5-Signature)
[NEEDED, no default]:
1-SHA256, 2-SHA384, 3-SHA512,
4-BLAKE2s_256, 5-BLAKE2b_256`)
signEntity = fs.String("signentity", "", `the entity that signs (with -datatype 5-Signature)
signEntity = fs.String("signentity", "", `the entity that signs (with --datatype 5-Signature)
[NEEDED, no default]:
example: 433FE984155206BD962725E20E8713472A879943`)
sbomFormat = fs.String("sbomformat", "", `the SBOM format (with -datatype 9-sbom):
sbomFormat = fs.String("sbomformat", "", `the SBOM format (with --datatype 9-sbom):
cyclonedx-json, cyclonedx-xml, github-json,
spdx-json, spdx-rdf, spdx-tag-value,
spdx-yaml, syft-json`)
groupID = fs.Uint32("groupid", 0, "set groupid [default: 0]")
linkID = fs.Uint32("link", 0, "set link pointer [default: 0]")
alignment = fs.Int("alignment", 0, "set alignment [default: 4096 with -datatype 4-Partition, 0 otherwise]")
alignment = fs.Int("alignment", 0, "set alignment [default: 4096 with --datatype 4-Partition, 0 otherwise]")
name = fs.String("filename", "", "set logical filename/handle [default: input filename]")
}

Expand Down Expand Up @@ -193,9 +193,9 @@ func getSBOMFormat() (sif.SBOMFormat, error) {
}

var (
errPartitionArgs = errors.New("with partition datatype, -partfs, -parttype and -partarch must be passed")
errPartitionArgs = errors.New("with partition datatype, --partfs, --parttype and --partarch must be passed")
errInvalidFingerprintLength = errors.New("invalid signing entity fingerprint length")
errSBOMArgs = errors.New("with SBOM datatype, -sbomformat must be passed")
errSBOMArgs = errors.New("with SBOM datatype, --sbomformat must be passed")
)

func getOptions(dt sif.DataType, fs *pflag.FlagSet) ([]sif.DescriptorInputOpt, error) {
Expand Down
20 changes: 10 additions & 10 deletions pkg/siftool/testdata/TestAddCommands/Add/out.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Usage:
siftool add <sif_path> <object_path> [flags]

Examples:
siftool add image.sif recipe.def -datatype 1
siftool add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 ----partarch 2
siftool add image.sif signature.bin -datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1
siftool add image.sif recipe.def --datatype 1
siftool add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 --partarch 2
siftool add image.sif signature.bin --datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1

Flags:
--alignment int set alignment [default: 4096 with -datatype 4-Partition, 0 otherwise]
--alignment int set alignment [default: 4096 with --datatype 4-Partition, 0 otherwise]
--datatype int the type of data to add
[NEEDED, no default]:
1-Deffile, 2-EnvVar, 3-Labels,
Expand All @@ -19,28 +19,28 @@ Flags:
--groupid uint32 set groupid [default: 0]
-h, --help help for add
--link uint32 set link pointer [default: 0]
--partarch int32 the main architecture used (with -datatype 4-Partition)
--partarch int32 the main architecture used (with --datatype 4-Partition)
[NEEDED, no default]:
1-386, 2-amd64, 3-arm,
4-arm64, 5-ppc64, 6-ppc64le,
7-mips, 8-mipsle, 9-mips64,
10-mips64le, 11-s390x, 12-riscv64
--partfs int32 the filesystem used (with -datatype 4-Partition)
--partfs int32 the filesystem used (with --datatype 4-Partition)
[NEEDED, no default]:
1-Squash, 2-Ext3, 3-ImmuObj,
4-Raw
--parttype int32 the type of partition (with -datatype 4-Partition)
--parttype int32 the type of partition (with --datatype 4-Partition)
[NEEDED, no default]:
1-System, 2-PrimSys, 3-Data,
4-Overlay
--sbomformat string the SBOM format (with -datatype 9-sbom):
--sbomformat string the SBOM format (with --datatype 9-sbom):
cyclonedx-json, cyclonedx-xml, github-json,
spdx-json, spdx-rdf, spdx-tag-value,
spdx-yaml, syft-json
--signentity string the entity that signs (with -datatype 5-Signature)
--signentity string the entity that signs (with --datatype 5-Signature)
[NEEDED, no default]:
example: 433FE984155206BD962725E20E8713472A879943
--signhash int32 the signature hash used (with -datatype 5-Signature)
--signhash int32 the signature hash used (with --datatype 5-Signature)
[NEEDED, no default]:
1-SHA256, 2-SHA384, 3-SHA512,
4-BLAKE2s_256, 5-BLAKE2b_256
4 changes: 2 additions & 2 deletions test/keys/gen_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func writeKeys() error {
},
},
{
pubPath: "ecdsa-public.pem",
priPath: "ecdsa-private.pem",
pubPath: "ed25519-public.pem",
priPath: "ed25519-private.pem",
keyFn: func() (crypto.PublicKey, crypto.PrivateKey, error) {
return ed25519.GenerateKey(rand.Reader)
},
Expand Down

0 comments on commit 5dbb7a9

Please sign in to comment.