Skip to content

Commit a5ca718

Browse files
committed
fix(plugin-interface): make tests pass
Signed-off-by: Caio Rocha de Oliveira <caiorocoli@gmail.com>
1 parent f16cd60 commit a5ca718

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

plugin/plugin-interface.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (key *MasterKey) GetEnvPrefix() string {
7070
// e.g, if instanceID is "my-vault", env prefix will be "SOPS_PLUGIN_MY_VAULT_",
7171
// and users can then use env vars like "SOPS_PLUGIN_MY_VAULT_TOKEN
7272
// or "SOPS_PLUGIN_MY_VAULT_KEY" in their plugin implementation.
73-
return "SOPS_PLUGIN" + strings.ToUpper(normalized) + "_"
73+
return "SOPS_PLUGIN_" + strings.ToUpper(normalized) + "_"
7474
}
7575

7676
func (key MasterKey) ToMap() map[string]any {
@@ -121,18 +121,18 @@ func (key *MasterKey) Encrypt(dataKey []byte) error {
121121
// - Plugins are expected to be within the user's PATH for flexibility and security.
122122
// - Users are responsible for ensuring that their plugin binaries are secure and trustworthy.
123123
func (key *MasterKey) validateBinaryName() error {
124-
validBinaryName := regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)
125-
if !validBinaryName.MatchString(key.BinaryName) {
126-
return fmt.Errorf("invalid binary name: only alphanumeric, dashes, and underscores allowed")
127-
}
128-
129124
if len(key.BinaryName) > MaxBinaryNameLength || len(key.BinaryName) < MinBinaryNameLength {
130125
return fmt.Errorf(
131126
"invalid binary name: length must be between %d and %d characters",
132127
MinBinaryNameLength,
133128
MaxBinaryNameLength,
134129
)
135130
}
131+
132+
validBinaryName := regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)
133+
if !validBinaryName.MatchString(key.BinaryName) {
134+
return fmt.Errorf("invalid binary name: only alphanumeric, dashes, and underscores allowed")
135+
}
136136
return nil
137137
}
138138

@@ -236,7 +236,7 @@ func executePlugin(
236236
cmd.Stderr = &stderr
237237

238238
if err := cmd.Run(); err != nil {
239-
if errors.Is(err, context.DeadlineExceeded) {
239+
if errors.Is(err, context.DeadlineExceeded) || errors.Is(ctx.Err(), context.DeadlineExceeded) {
240240
return nil, fmt.Errorf("plugin execution timed out (%s)", executableName)
241241
}
242242
if errors.Is(err, exec.ErrNotFound) {

0 commit comments

Comments
 (0)