Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stores/yaml/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"strings"
"time"

"github.com/getsops/sops/v3"
"github.com/getsops/sops/v3/config"
Expand Down Expand Up @@ -83,6 +84,9 @@ func (store Store) nodeToTreeValue(node *yaml.Node, commentsWereHandled bool) (i
case yaml.ScalarNode:
var result interface{}
node.Decode(&result)
if time, ok := result.(time.Time); ok {
return nil, fmt.Errorf("Unsupported time element found: %q", time)
}
return result, nil
case yaml.AliasNode:
return store.nodeToTreeValue(node.Alias, false)
Expand Down
7 changes: 7 additions & 0 deletions stores/yaml/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ func TestLoadAliasesPlainFile(t *testing.T) {
assert.Equal(t, ALIASES_BRANCHES, branches)
}

func TestLoadPlainFileTime(t *testing.T) {
branches, err := (&Store{}).LoadPlainFile([]byte("foo: 2025-02-15"))
assert.NotNil(t, err)
assert.Nil(t, branches)
assert.Equal(t, `Error unmarshaling input YAML: Unsupported time element found: "2025-02-15 00:00:00 +0000 UTC"`, err.Error())
}

func TestComment1(t *testing.T) {
// First iteration: load and store
branches, err := (&Store{}).LoadPlainFile(COMMENT_1)
Expand Down
Loading