File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,24 @@ import (
1414
1515// VariableFromBlock extracts a terraform variable, but not it's final resolved value.
1616// code taken mostly from https://github.com/aquasecurity/trivy/blob/main/pkg/iac/scanners/terraform/parser/evaluator.go#L479
17- func VariableFromBlock (block * terraform.Block ) types.Variable {
17+ func VariableFromBlock (block * terraform.Block ) (tfVar types.Variable ) {
18+ defer func () {
19+ // Extra safety mechanism to ensure that if a panic occurs, we do not break
20+ // everything else.
21+ if r := recover (); r != nil {
22+ tfVar = types.Variable {
23+ Name : block .Label (),
24+ Diagnostics : types.Diagnostics {
25+ {
26+ Severity : hcl .DiagError ,
27+ Summary : "Panic occurred in extracting variable. This should not happen, please report this to Coder." ,
28+ Detail : fmt .Sprintf ("panic in variable extract: %+v" , r ),
29+ },
30+ },
31+ }
32+ }
33+ }()
34+
1835 attributes := block .Attributes ()
1936
2037 var valType cty.Type
You can’t perform that action at this time.
0 commit comments