opentofu/terraform
Pam Selle 0a02e7040f
Store sensitive attribute paths in state (#26338)
* Add creation test and simplify in-place test

* Add deletion test

* Start adding marking from state

Start storing paths that should be marked
when pulled out of state. Implements deep
copy for attr paths. This commit also includes some
comment noise from investigations, and fixing the diff test

* Fix apply stripping marks

* Expand diff tests

* Basic apply test

* Update comments on equality checks to clarify current understanding

* Add JSON serialization for sensitive paths

We need to serialize a slice of cty.Path values to be used to re-mark
the sensitive values of a resource instance when loading the state file.
Paths consist of a list of steps, each of which may be either getting an
attribute value by name, or indexing into a collection by string or
number.

To serialize these without building a complex parser for a compact
string form, we render a nested array of small objects, like so:

[
  [
    { type: "get_attr", value: "foo" },
    { type: "index", value: { "type": "number", "value": 2 } }
  ]
]

The above example is equivalent to a path `foo[2]`.

* Format diffs with map types

Comparisons need unmarked values to operate on,
so create unmarked values for those operations. Additionally,
change diff to cover map types

* Remove debugging printing

* Fix bug with marking non-sensitive values

When pulling a sensitive value from state,
we were previously using those marks to remark
the planned new value, but that new value
might *not* be sensitive, so let's not do that

* Fix apply test

Apply was not passing the second state
through to the third pass at apply

* Consistency in checking for length of paths vs inspecting into value

* In apply, don't mark with before paths

* AttrPaths test coverage for DeepCopy

* Revert format changes

Reverts format changes in format/diff for this
branch so those changes can be discussed on a separate PR

* Refactor name of AttrPaths to AttrSensitivePaths

* Rename AttributePaths/attributePaths for naming consistency

Co-authored-by: Alisdair McDiarmid <alisdair@users.noreply.github.com>
2020-09-24 12:40:17 -04:00
..
testdata fix tests 2020-09-21 16:17:46 -04:00
context_apply_test.go Store sensitive attribute paths in state (#26338) 2020-09-24 12:40:17 -04:00
context_components_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
context_components.go terraform: Remove some addrs.Provider.LegacyString uses 2020-04-06 09:24:23 -07:00
context_eval_test.go terraform console: enable use of impure functions (#25442) 2020-07-01 09:43:07 -04:00
context_fixtures_test.go Mildwonkey/terraform tests (targeting integration branch) (#24513) 2020-04-06 09:24:23 -07:00
context_graph_type.go remove refresh! 2020-09-22 10:27:45 -04:00
context_import_test.go terraform: Relax provider config ref constraints 2020-06-29 10:58:20 -04:00
context_import.go Mildwonkey/ps import (#24412) 2020-03-20 08:15:29 -04:00
context_input_test.go Mildwonkey/terraform tests (targeting integration branch) (#24513) 2020-04-06 09:24:23 -07:00
context_input.go convert /terraform to use new provider config 2020-03-11 11:21:45 -04:00
context_plan_test.go verify skipRefresh during plan 2020-09-24 09:34:49 -04:00
context_refresh_test.go refresh cbd test 2020-09-24 09:43:48 -04:00
context_test.go use plan state in contextOptsForPlanViaFile 2020-09-17 09:54:59 -04:00
context_validate_test.go module and output depends_on validation tests 2020-06-16 13:17:21 -04:00
context.go add SkipRefresh to the terraform context 2020-09-24 09:34:49 -04:00
diff_test.go re-count the flatmapped containers 2018-11-16 15:26:16 -05:00
diff.go prevent panics when encountering nil diffs 2019-09-04 16:51:42 -04:00
eval_apply.go Store sensitive attribute paths in state (#26338) 2020-09-24 12:40:17 -04:00
eval_check_prevent_destroy.go vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00
eval_context_builtin_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
eval_context_builtin.go Add RefreshState to the eval context 2020-09-17 09:54:59 -04:00
eval_context_mock.go Add RefreshState to the eval context 2020-09-17 09:54:59 -04:00
eval_context.go Add RefreshState to the eval context 2020-09-17 09:54:59 -04:00
eval_count.go fixup count transition for refresh state 2020-09-17 09:54:59 -04:00
eval_diff_test.go vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00
eval_diff.go Store sensitive attribute paths in state (#26338) 2020-09-24 12:40:17 -04:00
eval_error.go core: [refactor] store Deposed resource instances as a list 2015-03-04 12:25:59 -06:00
eval_filter_operation.go terraform: clean up EvalNodes 2015-02-19 12:08:32 -08:00
eval_filter.go terraform: more eval stuff 2015-02-19 12:07:54 -08:00
eval_for_each_test.go terraform: check for unknows in for_each type before validating set (#25426) 2020-06-29 09:12:36 -04:00
eval_for_each.go Disallow sensitive values as for_each arguments 2020-09-10 11:04:17 -04:00
eval_if.go core: [refactor] pull Deposed out of Tainted list 2015-03-04 12:25:47 -06:00
eval_noop.go terraform: clean up EvalNodes 2015-02-19 12:08:32 -08:00
eval_provider_test.go terraform: refactor ProviderEvalTree (#26236) 2020-09-16 12:17:17 -04:00
eval_provider.go terraform: refactor ProviderEvalTree (#26236) 2020-09-16 12:17:17 -04:00
eval_read_data_apply.go Simplify data lifecycle for the no-refresh world 2020-09-22 09:55:19 -04:00
eval_read_data_plan.go Simplify data lifecycle for the no-refresh world 2020-09-22 09:55:19 -04:00
eval_read_data.go add a way to force depends_on behavior of data 2020-06-04 18:03:32 -04:00
eval_refresh.go Store sensitive attribute paths in state (#26338) 2020-09-24 12:40:17 -04:00
eval_sequence_test.go terraform: Refresh, Read/Write state 2015-02-19 12:08:00 -08:00
eval_sequence.go core: EvalSequence to handle EvalEarlyExitError 2018-10-16 18:49:20 -07:00
eval_state_test.go terraform: NodeDestroyResourceInstance refactor (#26246) 2020-09-16 11:33:55 -04:00
eval_state_upgrade_test.go remove extra attrs found in state json 2020-08-06 22:55:36 -04:00
eval_state_upgrade.go remove extra attrs found in state json 2020-08-06 22:55:36 -04:00
eval_state.go add Addr field for logging 2020-09-24 09:49:22 -04:00
eval_test.go terraform: clean up EvalNodes 2015-02-19 12:08:32 -08:00
eval_validate_selfref_test.go vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00
eval_validate_selfref.go vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00
eval_validate_test.go Mildwonkey/node resource validate (#26206) 2020-09-14 08:43:14 -04:00
eval_validate.go terraform: refactor ProviderEvalTree (#26236) 2020-09-16 12:17:17 -04:00
eval_variable.go terraform: refactor nodeModuleVariable and NodeRootVariable EvalTree()s (#26245) 2020-09-16 11:32:48 -04:00
eval.go don't log path in EvalRaw 2020-03-25 17:03:06 -04:00
evaluate_test.go Add test for GetInputVariable, with sensitive config 2020-09-22 16:35:40 -04:00
evaluate_valid_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
evaluate_valid.go Mildwonkey/terraform tests (targeting integration branch) (#24513) 2020-04-06 09:24:23 -07:00
evaluate.go update comments around evaluating 0 instances 2020-09-17 09:54:59 -04:00
execute.go terraform: refactor Node*Ouput 2020-09-09 08:45:54 -04:00
features.go output warning flag 2017-11-28 14:18:54 -05:00
graph_builder_apply_test.go terraform: remove DisableReduce from refresh, plan and apply graphs (#25824) 2020-08-14 14:13:33 -04:00
graph_builder_apply.go terraform: remove DisableReduce from refresh, plan and apply graphs (#25824) 2020-08-14 14:13:33 -04:00
graph_builder_destroy_plan.go make the root node a nodeCloseModule for root 2020-04-02 16:00:36 -04:00
graph_builder_eval.go Add expansion transformer to eval graph 2020-04-27 13:09:08 -04:00
graph_builder_import.go terraform: Relax provider config ref constraints 2020-06-29 10:58:20 -04:00
graph_builder_plan_test.go terraform: remove DisableReduce from refresh, plan and apply graphs (#25824) 2020-08-14 14:13:33 -04:00
graph_builder_plan.go thread skipContext through to the instance node 2020-09-24 09:34:49 -04:00
graph_builder_test.go core: Get tests compiling again 2018-10-16 18:46:46 -07:00
graph_builder_validate.go add module expansion to validation 2020-04-05 12:13:48 -04:00
graph_builder.go update terraform to work with new dag changes 2020-02-19 14:53:19 -05:00
graph_dot_test.go terraform: remove ConnectDependents and related interfaces 2017-02-03 14:25:54 +01:00
graph_dot.go Remove dot package 2016-11-14 08:50:34 -05:00
graph_interface_subgraph.go rename GraphNodeSubPath -> GraphNodeModuleInstance 2020-03-10 17:25:11 -04:00
graph_test.go update some graph builder tests 2018-10-16 19:14:11 -07:00
graph_walk_context.go Get the new RefreshState into the right contexts 2020-09-17 09:54:59 -04:00
graph_walk_operation.go remove refresh! 2020-09-22 10:27:45 -04:00
graph_walk_test.go terraform: trying this graphwalker thing 2015-02-19 12:07:56 -08:00
graph_walk.go terraform: add GraphNodeExecutable interface (#26132) 2020-09-04 14:03:45 -04:00
graph.go terraform: add GraphNodeExecutable interface (#26132) 2020-09-04 14:03:45 -04:00
graphtype_string.go remove refresh! 2020-09-22 10:27:45 -04:00
hook_mock.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00
hook_stop_test.go terraform: stopHook and tests 2014-07-02 16:16:38 -07:00
hook_stop.go command: Fix TestPlan_shutdown 2018-11-08 08:57:11 -08:00
hook_test.go add locks to testHook 2020-04-08 10:02:43 -04:00
hook.go terraform: More wiring in of new provider types 2018-10-16 19:12:54 -07:00
instance_expanders.go remove requiresInstanceExpansion 2020-05-28 21:30:44 -04:00
instancetype_string.go stringer: Regenerate files with latest version 2019-05-13 15:34:27 +01:00
instancetype.go Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
node_count_boundary_test.go Mildwonkey/eval local (#26182) 2020-09-09 15:59:29 -04:00
node_count_boundary.go Mildwonkey/eval local (#26182) 2020-09-09 15:59:29 -04:00
node_data_destroy_test.go terraform: refactor Node*Ouput 2020-09-09 08:45:54 -04:00
node_data_destroy.go terraform: refactor Node*Ouput 2020-09-09 08:45:54 -04:00
node_local_test.go Mildwonkey/eval local (#26182) 2020-09-09 15:59:29 -04:00
node_local.go Mildwonkey/eval local (#26182) 2020-09-09 15:59:29 -04:00
node_module_expand_test.go Mildwonkey/eval local (#26182) 2020-09-09 15:59:29 -04:00
node_module_expand.go Mildwonkey/eval local (#26182) 2020-09-09 15:59:29 -04:00
node_module_variable_test.go rename module variables and remove extra methods 2020-04-08 14:41:52 -04:00
node_module_variable.go remove refresh! 2020-09-22 10:27:45 -04:00
node_output_test.go terraform: refactor Node*Ouput 2020-09-09 08:45:54 -04:00
node_output.go remove refresh! 2020-09-22 10:27:45 -04:00
node_provider_abstract.go remove unused interfaces 2020-06-24 10:45:58 -04:00
node_provider_eval.go terraform: refactor ProviderEvalTree (#26236) 2020-09-16 12:17:17 -04:00
node_provider_test.go terraform: refactor ProviderEvalTree (#26236) 2020-09-16 12:17:17 -04:00
node_provider.go remove refresh! 2020-09-22 10:27:45 -04:00
node_provisioner.go Mildwonkey/node resource validate (#26206) 2020-09-14 08:43:14 -04:00
node_resource_abstract_test.go core: NodeAbstractResourceInstance.Provider correct implied provider 2020-08-24 11:41:28 -07:00
node_resource_abstract.go core: NodeAbstractResourceInstance.Provider correct implied provider 2020-08-24 11:41:28 -07:00
node_resource_apply_instance.go cleanup unused CBD code 2020-09-16 11:14:36 -04:00
node_resource_apply.go ignore module indices in pre-expansion targeting 2020-06-10 15:39:29 -04:00
node_resource_destroy_deposed.go remove refresh! 2020-09-22 10:27:45 -04:00
node_resource_destroy.go terraform: NodeDestroyResourceInstance refactor (#26246) 2020-09-16 11:33:55 -04:00
node_resource_plan_destroy.go s/GraphNodeResource/GraphNodeConfigResource/ 2020-03-16 11:16:23 -04:00
node_resource_plan_instance.go add Addr field for logging 2020-09-24 09:49:22 -04:00
node_resource_plan_orphan.go s/GraphNodeResource/GraphNodeConfigResource/ 2020-03-16 11:16:23 -04:00
node_resource_plan.go thread skipContext through to the instance node 2020-09-24 09:34:49 -04:00
node_resource_validate.go Mildwonkey/node resource validate (#26206) 2020-09-14 08:43:14 -04:00
node_root_variable_test.go terraform: refactor nodeModuleVariable and NodeRootVariable EvalTree()s (#26245) 2020-09-16 11:32:48 -04:00
node_root_variable.go terraform: refactor nodeModuleVariable and NodeRootVariable EvalTree()s (#26245) 2020-09-16 11:32:48 -04:00
node_value.go prune unused values based on behavior 2020-04-02 16:00:36 -04:00
plan.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
provider_mock.go Add support for provider metadata to modules. (#22583) 2020-03-05 16:53:24 -08:00
provisioner_mock.go check resource-level connections block for refs 2019-12-12 12:57:23 -05:00
resource_address_test.go prune references to config/module 2019-08-07 17:50:59 -04:00
resource_address.go Typo: heirarchical => hierarchical 2020-07-23 15:09:22 +02:00
resource_mode_string.go prune references to config/module 2019-08-07 17:50:59 -04:00
resource_mode.go Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
resource_provider_mock_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
resource_provider_mock.go minor race issue in mockResourceProvider 2017-12-20 09:18:38 -05:00
resource_provider.go terraform: return initialization required error when provider schemas not found (#24715) 2020-04-21 16:29:27 -04:00
resource_provisioner_mock_test.go replace provider and provisioner types in tests 2018-10-16 19:11:09 -07:00
resource_provisioner_mock.go move "configschema" from "config" to "configs" 2018-10-16 18:50:29 -07:00
resource_provisioner.go Run gofmt 2020-08-28 09:41:00 -04:00
resource_test.go s/GraphNodeResource/GraphNodeConfigResource/ 2020-03-16 11:16:23 -04:00
resource.go core: Remove the last few HIL remnants 2020-09-02 15:53:33 -07:00
schemas_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
schemas.go terraform: Remove some addrs.Provider.LegacyString uses 2020-04-06 09:24:23 -07:00
state_filter.go restore (via copypaste) terraform.State.Remove 2019-01-03 22:06:30 -05:00
state_test.go prune references to config/module 2019-08-07 17:50:59 -04:00
state_upgrade_v1_to_v2.go terraform: convert empty path to root path in V1 state 2017-03-21 11:37:12 -07:00
state_upgrade_v2_to_v3.go terraform: V1 to V2 upgrade should treat nil path as root path 2017-03-21 11:12:44 -07:00
state_v1.go core: Introduce state v3 and upgrade process 2016-06-09 10:49:49 +01:00
state.go Add support for provider metadata to modules. (#22583) 2020-03-05 16:53:24 -08:00
terraform_test.go fix apply tests 2020-05-28 21:30:44 -04:00
testing.go terraform: support backends in the state 2017-01-26 14:33:49 -08:00
transform_attach_config_provider_meta.go s/GraphNodeResource/GraphNodeConfigResource/ 2020-03-16 11:16:23 -04:00
transform_attach_config_provider.go minor cleanup 2020-03-12 14:54:47 -04:00
transform_attach_config_resource.go s/GraphNodeResource/GraphNodeConfigResource/ 2020-03-16 11:16:23 -04:00
transform_attach_schema.go terraform: large refactor to use Provider from configs.Resource (#24396) 2020-03-18 08:58:20 -04:00
transform_attach_state.go attach a deep copy of ResourceState 2018-12-17 18:08:53 -05:00
transform_config_test.go NewNodeAbstractResource accepts a ResourceConfig 2020-03-25 17:03:06 -04:00
transform_config.go NewNodeAbstractResource accepts a ResourceConfig 2020-03-25 17:03:06 -04:00
transform_count_boundary.go core: Update EvalCountFixZeroOneBoundaryGlobal for new state types 2018-10-16 19:14:11 -07:00
transform_destroy_cbd_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_destroy_cbd.go cleanup unused CBD code 2020-09-16 11:14:36 -04:00
transform_destroy_edge_test.go core: Skip edges between resource instances in different module instances 2020-07-17 08:40:13 -07:00
transform_destroy_edge.go cleanup unused CBD code 2020-09-16 11:14:36 -04:00
transform_diff_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_diff.go s/GraphNodeResource/GraphNodeConfigResource/ 2020-03-16 11:16:23 -04:00
transform_expand.go GraphNodeExpand is not used 2020-03-10 17:25:11 -04:00
transform_import_state_test.go terraform: refactor graphNodeImportState and graphNodeImportState (#26243) 2020-09-14 16:53:37 -04:00
transform_import_state.go terraform: refactor graphNodeImportState and graphNodeImportState (#26243) 2020-09-14 16:53:37 -04:00
transform_local.go rename plannable local 2020-05-12 11:07:00 -04:00
transform_module_expansion.go don't connect module closers to destroy nodes 2020-09-09 12:23:23 -04:00
transform_module_variable_test.go update test strings 2020-05-12 11:07:00 -04:00
transform_module_variable.go eval variables with unknown expansion data 2020-04-08 15:37:38 -04:00
transform_orphan_count_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_orphan_count.go expansion resource and instance orphans 2020-04-02 16:00:35 -04:00
transform_orphan_output.go get rid of the NodeOutputOrphan 2020-05-28 21:30:44 -04:00
transform_orphan_resource_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_orphan_resource.go make the root node a nodeCloseModule for root 2020-04-02 16:00:36 -04:00
transform_output.go remove root output eval nodes from destroy 2020-07-07 11:10:15 -04:00
transform_provider_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_provider.go terraform: refactor ProviderEvalTree (#26236) 2020-09-16 12:17:17 -04:00
transform_provisioner_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_provisioner.go Mildwonkey/node resource validate (#26206) 2020-09-14 08:43:14 -04:00
transform_reference_test.go core: Skip edges between resource instances in different module instances 2020-07-17 08:40:13 -07:00
transform_reference.go delay data source reads with pending resource ref 2020-09-18 09:10:45 -04:00
transform_removed_modules.go pruneUnusedNodesTransformer 2020-05-28 21:30:42 -04:00
transform_resource_count.go s/GraphNodeResource/GraphNodeConfigResource/ 2020-03-16 11:16:23 -04:00
transform_root_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_root.go make the root node a nodeCloseModule for root 2020-04-02 16:00:36 -04:00
transform_state.go cleanup from resource state mods 2020-03-16 11:16:23 -04:00
transform_targets_test.go TransformTargets cannot depends on knowing Destroy 2020-06-10 15:38:35 -04:00
transform_targets.go re-add ModuleInstance -> Module conversion 2020-08-12 10:22:13 -04:00
transform_transitive_reduction_test.go Mildwonkey/tests (#24522) 2020-04-06 09:24:23 -07:00
transform_transitive_reduction.go terraform: add TransitiveReductionTransformer 2015-02-27 19:18:04 -08:00
transform_variable.go terraform: ugly huge change to weave in new HCL2-oriented types 2018-10-16 18:46:46 -07:00
transform_vertex_test.go terraform: GraphVertexTransformers 2015-02-19 12:07:57 -08:00
transform_vertex.go terraform: GraphVertexTransformers 2015-02-19 12:07:57 -08:00
transform.go helper/logging: Bring the LevelFilter into our own codebase 2019-12-05 15:22:03 -08:00
ui_input_mock.go core: add a context to the UIInput interface 2019-03-08 10:24:40 +01:00
ui_input_prefix_test.go core: add a context to the UIInput interface 2019-03-08 10:24:40 +01:00
ui_input_prefix.go core: add a context to the UIInput interface 2019-03-08 10:24:40 +01:00
ui_input.go command/login: Require "yes" to confirm 2020-06-25 11:46:51 -04:00
ui_output_callback_test.go terraform: provisioners 2015-02-19 12:08:06 -08:00
ui_output_callback.go terraform: provisioners 2015-02-19 12:08:06 -08:00
ui_output_mock_test.go terraform: UIOutput interface 2014-10-04 09:00:07 -07:00
ui_output_mock.go minor race fix in tests 2017-10-02 16:19:01 -04:00
ui_output_provisioner_test.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
ui_output_provisioner.go terraform: Ugly huge change to weave in new State and Plan types 2018-10-16 19:11:09 -07:00
ui_output.go terraform: UIOutput interface 2014-10-04 09:00:07 -07:00
upgrade_state_v1_test.go Fix swallowed tests in terraform package tests 2017-07-20 02:23:43 -07:00
upgrade_state_v2_test.go core: Add test for V2->V3 state upgrade 2016-06-09 11:16:34 +01:00
user_agent.go httpclient: Introduce composable UserAgent() 2019-08-05 11:07:21 +01:00
util_test.go Resolve resource provider types in config package 2017-06-09 14:03:59 -07:00
util.go Fix negative parallelism and negative semaphore (#23902) 2020-02-12 10:10:52 -05:00
valuesourcetype_string.go stringer: Regenerate files with latest version 2019-05-13 15:34:27 +01:00
variables_test.go vendor: upgrade go-cty dependency to 1.4.1 (#24983) 2020-05-18 14:10:19 -04:00
variables.go Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
version_required.go terraform: Fix required version constraint diags 2020-08-18 09:35:32 -04:00
version.go httpclient: Introduce composable UserAgent() 2019-08-05 11:07:21 +01:00
walkoperation_string.go remove refresh! 2020-09-22 10:27:45 -04:00