1
1
package tfparse
2
2
3
3
import (
4
- "fmt"
5
-
6
4
"github.com/aquasecurity/trivy-iac/pkg/scanners/terraform/parser/funcs"
7
5
"github.com/hashicorp/hcl/v2/ext/tryfunc"
8
6
ctyyaml "github.com/zclconf/go-cty-yaml"
9
7
"github.com/zclconf/go-cty/cty"
10
8
"github.com/zclconf/go-cty/cty/function"
11
9
"github.com/zclconf/go-cty/cty/function/stdlib"
10
+ "golang.org/x/xerrors"
12
11
)
13
12
14
13
// Functions returns a set of functions that are safe to use in the context of
@@ -131,7 +130,8 @@ var (
131
130
"filesha1" : makeStubFunction ("filesha1" , cty .String , function.Parameter {Name : "path" , Type : cty .String }),
132
131
"filesha256" : makeStubFunction ("filesha256" , cty .String , function.Parameter {Name : "path" , Type : cty .String }),
133
132
"filesha512" : makeStubFunction ("filesha512" , cty .String , function.Parameter {Name : "path" , Type : cty .String }),
134
- "pathexpand" : makeStubFunction ("pathexpand" , cty .String , function.Parameter {Name : "path" , Type : cty .String })}
133
+ "pathexpand" : makeStubFunction ("pathexpand" , cty .String , function.Parameter {Name : "path" , Type : cty .String }),
134
+ }
135
135
136
136
allFunctions = mergeMaps (safeFunctions , unsafeFileFunctions )
137
137
)
@@ -155,8 +155,8 @@ func makeStubFunction(name string, returnType cty.Type, params ...function.Param
155
155
var spec function.Spec
156
156
spec .Params = params
157
157
spec .Type = function .StaticReturnType (returnType )
158
- spec .Impl = func (args []cty.Value , retType cty.Type ) (cty.Value , error ) {
159
- return cty .UnknownVal (returnType ), fmt .Errorf ("function %q may not be used here" , name )
158
+ spec .Impl = func (_ []cty.Value , _ cty.Type ) (cty.Value , error ) {
159
+ return cty .UnknownVal (returnType ), xerrors .Errorf ("function %q may not be used here" , name )
160
160
}
161
161
return function .New (& spec )
162
162
}
0 commit comments