diff --git a/stores/yaml/store.go b/stores/yaml/store.go index 5d5c41d8d..3c0888d80 100644 --- a/stores/yaml/store.go +++ b/stores/yaml/store.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "strings" + "time" "github.com/getsops/sops/v3" "github.com/getsops/sops/v3/config" @@ -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) diff --git a/stores/yaml/store_test.go b/stores/yaml/store_test.go index 5c8a59953..ae47661bf 100644 --- a/stores/yaml/store_test.go +++ b/stores/yaml/store_test.go @@ -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)