This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue/load: relax places where @tag is allowed
Currently @tag can already be arbitrarily nested. This now also allows embeddings. It now explicitly disallows fields defined within lists or the scope of an optional field in the help. It also reports an error for invalid tag attributes. These restrictions avoid an injection from being spread to widely by being generated, which may increase the ability to analyze a configuration. But if these restrictions prove to be too cumbersome, they could be removed. Closes #437 Change-Id: I3af3a49adb20e67fcce7c6693d40bfd14aa8eb0b Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7082 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
- Loading branch information
Showing
4 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cue eval test.cue -t env=prod | ||
|
||
cmp stdout expect-stdout | ||
|
||
# TODO: report errors for invalid tags? | ||
|
||
-- test.cue -- | ||
{ | ||
environment: "prod" | "staging" @tag(env,short=prod|staging) | ||
} | ||
|
||
-- expect-stdout -- | ||
environment: "prod" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
! cue eval test.cue -t env=prod | ||
|
||
cmp stderr expect-stderr | ||
|
||
# TODO: report errors for invalid tags? | ||
|
||
-- test.cue -- | ||
{ | ||
environment: "prod" | "staging" @tag(env,short=prod|staging) | ||
|
||
// Don't replace in optional | ||
opt?: string @tag(env) | ||
bulk: [string]: foo: string @tag(env) | ||
bulk: x: {} | ||
|
||
// Don't replace in lists. | ||
a: [ | ||
{ no_replace: string @tag(env) } | ||
] | ||
|
||
// Don't allow in comprehensions | ||
src: [1, 2] | ||
for _ in src { | ||
b: string @tag(prod) | ||
} | ||
} | ||
|
||
-- expect-stderr -- | ||
@tag not allowed within optional fields: | ||
./test.cue:5:18 | ||
@tag not allowed within optional fields: | ||
./test.cue:6:33 | ||
@tag not allowed within lists: | ||
./test.cue:11:30 | ||
@tag not allowed within comprehension: | ||
./test.cue:17:19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters