Skip to content

Commit

Permalink
chore: update from upstream latest v1.8.2 release. (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
i4ki authored Sep 30, 2024
2 parents 65abaff + 4b027df commit 2559b9e
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 133 deletions.
30 changes: 28 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
## 1.9.0 (Unreleased)
## 1.8.2

SECURITY:
* Update go version to 1.21.11 to fix CVE-2024-24790

BUG FIXES:
* Better handling of key_provider references ([#1965](https://github.com/opentofu/opentofu/pull/1965))

## 1.8.1

BUG FIXES:
* Fixed crash when module source is not present ([#1888](https://github.com/opentofu/opentofu/pull/1888))

## 1.8.0

UPGRADE NOTES:

Expand All @@ -11,8 +24,21 @@ ENHANCEMENTS:
* Added mutli-line support to the `tofu console` command. ([#1307](https://github.com/opentofu/opentofu/issues/1307))

BUG FIXES:
* Fixed validation for `enforced` flag in encryption configuration. ([#1711](https://github.com/opentofu/opentofu/pull/1711))
* Fixed crash in gcs backend when using certain commands. ([#1618](https://github.com/opentofu/opentofu/pull/1618))
* Fixed inmem backend crash due to missing struct field. ([#1619](https://github.com/opentofu/opentofu/pull/1619))
* Added a check in the `tofu test` to validate that the names of test run blocks do not contain spaces. ([#1489](https://github.com/opentofu/opentofu/pull/1489))
* `tofu test` now supports accessing module outputs when the module has no resources. ([#1409](https://github.com/opentofu/opentofu/pull/1409))
* Fixed support for provider functions in tests ([#1603](https://github.com/opentofu/opentofu/pull/1603))
* Only hide sensitive attributes in plan detail when plan on a set of resources ([#1313](https://github.com/opentofu/opentofu/pull/1313))
* Added a better error message on `for_each` block with sensitive value of unsuitable type. ([#1485](https://github.com/opentofu/opentofu/pull/1485))
* Fix race condition on locking in gcs backend ([#1342](https://github.com/opentofu/opentofu/pull/1342))
* Fix bug where provider functions were unusable in variables and outputs ([#1689](https://github.com/opentofu/opentofu/pull/1689))
* Fix bug where lower-case `http_proxy`/`https_proxy` env variables were no longer supported in the S3 backend ([#1594](https://github.com/opentofu/opentofu/issues/1594))
* Fixed issue with migration between versions can cause an update in-place for resources when no changes are needed. ([#1640](https://github.com/opentofu/opentofu/pull/1640))
* Add source context for the 'insufficient feature blocks' error ([#1777](https://github.com/opentofu/opentofu/pull/1777))
* Remove encryption diags from autocomplete ([#1793](https://github.com/opentofu/opentofu/pull/1793))
* Ensure that using a sensitive path for templatefile that it doesn't panic([#1801](https://github.com/opentofu/opentofu/issues/1801))
* Fixed crash when module source is not present ([#1888](https://github.com/opentofu/opentofu/pull/1888))

## Previous Releases

Expand Down
20 changes: 16 additions & 4 deletions internal/encryption/keyprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,27 @@ func (e *targetBuilder) setupKeyProvider(cfg config.KeyProviderConfig, stack []c
continue
}

// TODO this should be more defensive
// This will always be a TraverseRoot, panic is OK if that's not the case
depRoot := (dep[0].(hcl.TraverseRoot)).Name
depType := (dep[1].(hcl.TraverseAttr)).Name
depName := (dep[2].(hcl.TraverseAttr)).Name

if depRoot != "key_provider" {
nonKeyProviderDeps = append(nonKeyProviderDeps, dep)
continue
}
depTypeAttr, typeOk := dep[1].(hcl.TraverseAttr)
depNameAttr, nameOk := dep[2].(hcl.TraverseAttr)

if !typeOk || !nameOk {
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Invalid Key Provider expression format",
Detail: "Expected key_provider.<type>.<name>",
Subject: dep.SourceRange().Ptr(),
})
continue
}

depType := depTypeAttr.Name
depName := depNameAttr.Name

kpc, ok := e.cfg.GetKeyProvider(depType, depName)
if !ok {
Expand Down
34 changes: 34 additions & 0 deletions internal/encryption/targets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ func TestBaseEncryption_buildTargetMethods(t *testing.T) {
aesgcm.Is,
},
},
"key-from-complex-vars": {
rawConfig: `
key_provider "static" "basic" {
key = var.obj[0].key
}
method "aes_gcm" "example" {
keys = key_provider.static.basic
}
state {
method = method.aes_gcm.example
}
`,
wantMethods: []func(method.Method) bool{
aesgcm.Is,
},
},
"undefined-key-from-vars": {
rawConfig: `
key_provider "static" "basic" {
Expand All @@ -145,6 +161,20 @@ func TestBaseEncryption_buildTargetMethods(t *testing.T) {
`,
wantErr: "Test Config Source:3,12-28: Undefined variable; Undefined variable var.undefinedkey",
},
"bad-keyprovider-format": {
rawConfig: `
key_provider "static" "basic" {
key = key_provider.static[0]
}
method "aes_gcm" "example" {
keys = key_provider.static.basic
}
state {
method = method.aes_gcm.example
}
`,
wantErr: "Test Config Source:3,12-34: Invalid Key Provider expression format; Expected key_provider.<type>.<name>",
},
}

reg := lockingencryptionregistry.New()
Expand All @@ -165,6 +195,10 @@ func TestBaseEncryption_buildTargetMethods(t *testing.T) {
Default: cty.StringVal("6f6f706830656f67686f6834616872756f3751756165686565796f6f72653169"),
Type: cty.String,
},
"obj": {
Name: "obj",
Default: cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"key": cty.StringVal("6f6f706830656f67686f6834616872756f3751756165686565796f6f72653169")})}),
},
},
}

Expand Down
2 changes: 1 addition & 1 deletion version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.0-alpha1
1.8.2
Loading

0 comments on commit 2559b9e

Please sign in to comment.