redact sensitive output values in run logs

This commit is contained in:
UKEME BASSEY 2022-09-19 09:02:24 -04:00
parent b54017ef83
commit 7b34e3e743
5 changed files with 7 additions and 6 deletions

View File

@ -246,7 +246,6 @@ func TestApplyJSON_outputs(t *testing.T) {
},
"password": map[string]interface{}{
"sensitive": true,
"value": "horse-battery",
"type": "string",
},
},

View File

@ -42,10 +42,15 @@ func OutputsFromMap(outputValues map[string]*states.OutputValue) (Outputs, tfdia
return nil, diags
}
var redactedValue json.RawMessage
if !ov.Sensitive {
redactedValue = json.RawMessage(value)
}
outputs[name] = Output{
Sensitive: ov.Sensitive,
Type: json.RawMessage(valueType),
Value: json.RawMessage(value),
Value: redactedValue,
}
}

View File

@ -52,12 +52,10 @@ func TestOutputsFromMap(t *testing.T) {
"beep": {
Sensitive: true,
Type: json.RawMessage(`"string"`),
Value: json.RawMessage(`"horse-battery"`),
},
"blorp": {
Sensitive: true,
Type: json.RawMessage(`["object",{"a":["object",{"b":["object",{"c":"string"}]}]}]`),
Value: json.RawMessage(`{"a":{"b":{"c":"oh, hi"}}}`),
},
"honk": {
Sensitive: false,

View File

@ -13,7 +13,7 @@ import (
// This version describes the schema of JSON UI messages. This version must be
// updated after making any changes to this view, the jsonHook, or any of the
// command/views/json package.
const JSON_UI_VERSION = "1.0"
const JSON_UI_VERSION = "1.1"
func NewJSONView(view *View) *JSONView {
log := hclog.New(&hclog.LoggerOptions{

View File

@ -98,7 +98,6 @@ func TestRefreshJSON_outputs(t *testing.T) {
},
"password": map[string]interface{}{
"sensitive": true,
"value": "horse-battery",
"type": "string",
},
},