Skip to content

Commit

Permalink
[cpackget] Debug log level not working on some commands #131
Browse files Browse the repository at this point in the history
fixed:
- Init was missing in COBRA structs: PersistentPreRunE: configureInstaller
- function crashes on empty string: sanitizeVersionForSignature()
  • Loading branch information
thorstendb-ARM committed Jun 13, 2023
1 parent a5d4242 commit c2f80b7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions cmd/commands/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ The default Cryptographic Hash Function used is "` + cryptography.Hashes[0] + `"
might be supported. The used function will be prefixed to the ".checksum" extension.
By default the checksum file will be created in the same directory as the provided pack.`,
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
PersistentPreRunE: configureInstaller,
RunE: func(cmd *cobra.Command, args []string) error {
return cryptography.GenerateChecksum(args[0], checksumCreateCmdFlags.outputDir, checksumCreateCmdFlags.hashAlgorithm)
},
Expand All @@ -73,7 +74,8 @@ with "checksum-create"), present in the same directory:
The used hash function is inferred from the checksum filename, and if any of the digests
computed doesn't match the one provided in the checksum file an error will be thrown.
If the .checksum file is in another directory, specify it with the -p/--path flag`,
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
PersistentPreRunE: configureInstaller,
RunE: func(cmd *cobra.Command, args []string) error {
if checksumVerifyCmdFlags.checksumPath != "" {
return cryptography.VerifyChecksum(args[0], checksumVerifyCmdFlags.checksumPath)
Expand Down
3 changes: 2 additions & 1 deletion cmd/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ or via the CMSIS_PACK_ROOT environment variable with the following contents:
- .Web/
- .Web/index.pidx (downloaded from <index-url>)
The index-url is mandatory. Ex "cpackget init --pack-root path/to/mypackroot https://www.keil.com/pack/index.pidx"`,
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
PersistentPreRunE: configureInstaller,
RunE: func(cmd *cobra.Command, args []string) error {
packRoot := viper.GetString("pack-root")
indexPath := args[0]
Expand Down
6 changes: 4 additions & 2 deletions cmd/commands/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ These can be viewed with any text/hex editor or dedicated zip tools like "zipinf
The referenced pack must be in its original/compressed form (.pack), and be present locally:
$ cpackget signature-create Vendor.Pack.1.2.3.pack -k private.key -c certificate.pem`,
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
PersistentPreRunE: configureInstaller,
RunE: func(cmd *cobra.Command, args []string) error {
if signatureCreateflags.keyPath == "" {
if !signatureCreateflags.certOnly {
Expand Down Expand Up @@ -152,7 +153,8 @@ the publisher's public PGP key.
The referenced pack must be in its original/compressed form (.pack), and be present locally:
$ cpackget signature-verify Vendor.Pack.1.2.3.pack.signed`,
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
PersistentPreRunE: configureInstaller,
RunE: func(cmd *cobra.Command, args []string) error {
if signatureVerifyflags.export && (signatureVerifyflags.skipCertValidation || signatureVerifyflags.skipInfo) {
log.Error("-e/--export does not need any other flags")
Expand Down
2 changes: 1 addition & 1 deletion cmd/cryptography/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func isPrivateKeyFromCertificate(cert *x509.Certificate, keyDER []byte, keyType
// from source vs an automated release.
func sanitizeVersionForSignature(version string) string {
v := sigVersionPrefix
if string(version[0]) != "v" {
if version != "" && string(version[0]) != "v" {
return v + "v" + version
}
return v + version
Expand Down

0 comments on commit c2f80b7

Please sign in to comment.