@@ -15,6 +15,7 @@ import (
15
15
"strings"
16
16
17
17
gp "github.com/hashicorp/go-plugin"
18
+ "github.com/hashicorp/go-secure-stdlib/base62"
18
19
"golang.org/x/crypto/sha3"
19
20
)
20
21
@@ -236,6 +237,7 @@ func CreatePlugin(plugin *PluginInfo, opt ...Option) (interface{}, func() error,
236
237
return nil , nil , fmt .Errorf ("error reading gzip compressed data from reader: %w" , err )
237
238
}
238
239
buf = uncompBuf .Bytes ()
240
+ name = strings .TrimSuffix (name , ".gz" )
239
241
}
240
242
241
243
cleanup := func () error {
@@ -255,8 +257,13 @@ func CreatePlugin(plugin *PluginInfo, opt ...Option) (interface{}, func() error,
255
257
dir = tmpDir
256
258
}
257
259
pluginPath := filepath .Join (dir , name )
260
+ randSuffix , err := base62 .Random (5 )
261
+ if err != nil {
262
+ return nil , nil , fmt .Errorf ("error generating random suffix for plugin execution: %w" , err )
263
+ }
264
+ pluginPath = fmt .Sprintf ("%s-%s" , pluginPath , randSuffix )
258
265
if runtime .GOOS == "windows" {
259
- pluginPath += " .exe"
266
+ pluginPath = fmt . Sprintf ( "%s .exe", pluginPath )
260
267
}
261
268
if err := ioutil .WriteFile (pluginPath , buf , fs .FileMode (0o700 )); err != nil {
262
269
return nil , cleanup , fmt .Errorf ("error writing out plugin for execution: %w" , err )
0 commit comments