Skip to content

Commit

Permalink
evaluate path before checking empty sha256 to unpack artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
thyton committed Dec 18, 2024
1 parent 2acd09d commit 0d1b748
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions vault/plugincatalog/plugin_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,15 @@ func (c *PluginCatalog) setInternal(ctx context.Context, plugin pluginutil.SetPl
var enterprise bool

if plugin.OCIImage == "" {
if len(plugin.Sha256) == 0 {
// Enterprise only: unpack the plugin artifact
command = filepath.Join(c.directory, plugin.Command)
sym, err := filepath.EvalSymlinks(command)
if err != nil {
if len(plugin.Sha256) != 0 {
return nil, fmt.Errorf("error while validating the command path: %w", err)
}

// When binary is missing and sha256 is unset, attempt to unpack the plugin artifact
// Enterprise only
var unpackErr error
enterprise, plugin.Command, plugin.Sha256, unpackErr = c.entUnpackArtifact(plugin)
if unpackErr != nil {
Expand All @@ -984,11 +991,6 @@ func (c *PluginCatalog) setInternal(ctx context.Context, plugin pluginutil.SetPl
} else {
// Best effort check to make sure the command isn't breaking out of the
// configured plugin directory.
command = filepath.Join(c.directory, plugin.Command)
sym, err := filepath.EvalSymlinks(command)
if err != nil {
return nil, fmt.Errorf("error while validating the command path: %w", err)
}
symAbs, err := filepath.Abs(filepath.Dir(sym))
if err != nil {
return nil, fmt.Errorf("error while validating the command path: %w", err)
Expand Down

0 comments on commit 0d1b748

Please sign in to comment.