Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CDK v1 signature verify #1408

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cmd/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func installComponent(cmd *cobra.Command, args []string) (err error) {
err = errors.Wrap(err, "Install of component failed")
return
}
cli.OutputChecklist(successIcon, "Component installed\n")
cli.OutputChecklist(successIcon, "Component version %s installed\n", component.InstalledVersion())

// @jon-stewart: TODO: Component lifecycle `cdk-init` command

Expand Down
30 changes: 19 additions & 11 deletions lwcomponent/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path/filepath"
"runtime"

"aead.dev/minisign"
"github.com/Masterminds/semver"
"github.com/lacework/go-sdk/api"
"github.com/lacework/go-sdk/internal/cache"
Expand Down Expand Up @@ -164,22 +165,22 @@ func (c *Catalog) Stage(component *CDKComponent, version string) (stageClose fun
}

func (c *Catalog) Verify(component *CDKComponent) (err error) {
_, err = component.stage.Signature()
data, err := os.ReadFile(filepath.Join(component.stage.Directory(), component.Name))
if err != nil {
return
}

// var publicKey string
sig, err := component.stage.Signature()
if err != nil {
return
}

// @jon-stewart: TODO: signature failures
// rootPublicKey := minisign.PublicKey{}
// if err := rootPublicKey.UnmarshalText([]byte(publicKey)); err != nil {
// return errors.Wrap(err, "unable to load root public key")
// }
rootPublicKey := minisign.PublicKey{}
if err := rootPublicKey.UnmarshalText([]byte(publicKey)); err != nil {
return errors.Wrap(err, "unable to load root public key")
}

// @jon-stewart: TODO: signature failures
// return verifySignature(rootPublicKey, data, sig)
return
return verifySignature(rootPublicKey, data, sig)
}

func (c *Catalog) Install(component *CDKComponent) (err error) {
Expand All @@ -197,7 +198,14 @@ func (c *Catalog) Install(component *CDKComponent) (err error) {
return
}

return component.stage.Commit(componentDir)
err = component.stage.Commit(componentDir)
if err != nil {
return
}

component.hostInfo = NewHostInfo(componentDir)

return
}

// Delete a CDKComponent
Expand Down