Skip to content

Commit 67a593f

Browse files
committed
Add minimal sanitization for applylib
1 parent f43e3e7 commit 67a593f

File tree

1 file changed

+8
-0
lines changed
  • porch/controllers/remoterootsync/pkg/applyset

1 file changed

+8
-0
lines changed

porch/controllers/remoterootsync/pkg/applyset/applyset.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"encoding/json"
2020
"fmt"
21+
"strings"
2122
"sync"
2223

2324
"k8s.io/apimachinery/pkg/api/meta"
@@ -202,6 +203,13 @@ func (a *ApplySet) ApplyOnce(ctx context.Context) (*ApplyResults, error) {
202203
continue
203204
}
204205

206+
// Special case: errors are very cryptic with / in the name (we get a 404), and also avoid injection attacks
207+
if strings.Contains(name, "/") {
208+
err := fmt.Errorf("name %q is not valid", name)
209+
results.applyError(gvk, nn, fmt.Errorf("error from apply: %w", err))
210+
continue
211+
}
212+
205213
applied, err := dynamicResource.Patch(ctx, name, types.ApplyPatchType, j, a.patchOptions)
206214
if err != nil {
207215
results.applyError(gvk, nn, fmt.Errorf("error from apply: %w", err))

0 commit comments

Comments
 (0)