Skip to content

Commit 40da3a6

Browse files
committed
PR comments
1 parent 8ddde20 commit 40da3a6

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

testdata/tfvars/.auto.tfvars.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"four":"jason"}
1+
{"four":"jason"}

testdata/tfvars/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ data "coder_parameter" "variable_values" {
5858
name = "four"
5959
value = var.four
6060
}
61-
}
61+
}

tfvars/load.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Code taken from https://github.com/aquasecurity/trivy/blob/main/pkg/iac/scanners/terraform/parser/load_vars.go
1+
// Code taken from https://github.com/aquasecurity/trivy/blob/0449787eb52854cbdd7f4c5794adbf58965e60f8/pkg/iac/scanners/terraform/parser/load_vars.go
22
package tfvars
33

44
import (
@@ -46,21 +46,11 @@ func TFVarFiles(path string, dir fs.FS) ([]string, error) {
4646
func LoadTFVars(srcFS fs.FS, filenames []string) (map[string]cty.Value, error) {
4747
combinedVars := make(map[string]cty.Value)
4848

49-
// Intentionally commented out to avoid loading from host environment
49+
// Intentionally avoid loading terraform variables from the host environment.
50+
// Trivy (and terraform) use os.Environ() to search for "TF_VAR_" prefixed
51+
// environment variables.
5052
//
51-
//for _, env := range os.Environ() {
52-
// split := strings.Split(env, "=")
53-
// key := split[0]
54-
// if !strings.HasPrefix(key, "TF_VAR_") {
55-
// continue
56-
// }
57-
// key = strings.TrimPrefix(key, "TF_VAR_")
58-
// var val string
59-
// if len(split) > 1 {
60-
// val = split[1]
61-
// }
62-
// combinedVars[key] = cty.StringVal(val)
63-
//}
53+
// Preview should be sandboxed, so this code should not be included.
6454

6555
for _, filename := range filenames {
6656
vars, err := LoadTFVarsFile(srcFS, filename)

0 commit comments

Comments
 (0)