Skip to content

Commit 139f69a

Browse files
committed
Check for magic cloud-config comment before yaml
Signed-off-by: Anders F Björklund <[email protected]>
1 parent 47f9960 commit 139f69a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/cidata/schema.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package cidata
22

33
import (
4+
"bytes"
45
_ "embed"
6+
"fmt"
57
"strings"
68

79
"github.com/santhosh-tekuri/jsonschema/v5"
@@ -14,6 +16,9 @@ const schemaURL = "https://raw.githubusercontent.com/canonical/cloud-init/main/c
1416
var schemaText string
1517

1618
func validateCloudConfig(userData []byte) error {
19+
if !bytes.HasPrefix(userData, []byte("#cloud-config")) {
20+
return fmt.Errorf("missing #cloud-config")
21+
}
1722
var m interface{}
1823
err := yaml.Unmarshal(userData, &m)
1924
if err != nil {

0 commit comments

Comments
 (0)