opentofu/internal/repl
Alisdair McDiarmid 691b98b612 cli: Prevent overuse of console-only type function
The console-only `type` function allows interrogation of any value's
type.  An implementation quirk is that we use a cty.Mark to allow the
console to display this type information without the usual HCL quoting.
For example:

> type("boop")
string

instead of:

> type("boop")
"string"

Because these marks can propagate when used in complex expressions,
using the type function as part of a complex expression could result in
this "print as raw" mark being attached to a collection. When this
happened, it would result in a crash when we tried to iterate over a
marked value.

The `type` function was never intended to be used in this way, which is
why its use is limited to the console command. Its purpose was as a
pseudo-builtin, used only at the top level to display the type of a
given value.

This commit goes some way to preventing the use of the `type` function
in complex expressions, by refusing to display any non-string value
which was marked by `type`, or contains a sub-value which was so marked.
2022-02-09 17:43:54 -05:00
..
testdata/config-fixture Move repl/ to internal/repl/ 2021-05-17 14:09:07 -07:00
format_test.go update to use typed sensitive marks 2021-06-25 12:49:07 -04:00
format.go cli: Prevent overuse of console-only type function 2022-02-09 17:43:54 -05:00
repl.go Move repl/ to internal/repl/ 2021-05-17 14:09:07 -07:00
session_test.go cli: Prevent overuse of console-only type function 2022-02-09 17:43:54 -05:00
session.go cli: Prevent overuse of console-only type function 2022-02-09 17:43:54 -05:00