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 1b118d9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions vault/plugincatalog/plugin_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,11 @@ func (c *PluginCatalog) setInternal(ctx context.Context, plugin pluginutil.SetPl
var enterprise bool

if plugin.OCIImage == "" {
if len(plugin.Sha256) == 0 {
command = filepath.Join(c.directory, plugin.Command)
sym, err := filepath.EvalSymlinks(command)
if err != nil && len(plugin.Sha256) != 0 {
return nil, fmt.Errorf("error while validating the command path: %w", err)
} else if len(plugin.Sha256) == 0 {
// Enterprise only: unpack the plugin artifact
var unpackErr error
enterprise, plugin.Command, plugin.Sha256, unpackErr = c.entUnpackArtifact(plugin)
Expand All @@ -984,11 +988,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 1b118d9

Please sign in to comment.