diff --git a/.github/scripts/queries-validator/requirements.txt b/.github/scripts/queries-validator/requirements.txt index 0f5107906b2..bf0d2b31585 100644 Binary files a/.github/scripts/queries-validator/requirements.txt and b/.github/scripts/queries-validator/requirements.txt differ diff --git a/assets/libraries/azureresourcemanager.rego b/assets/libraries/azureresourcemanager.rego index 58630614180..8a14adc2aaa 100644 --- a/assets/libraries/azureresourcemanager.rego +++ b/assets/libraries/azureresourcemanager.rego @@ -81,7 +81,7 @@ getDefaultValueFromParametersIfPresent(doc, valueToCheck) = [value, propertyType isParameterReference(valueToCheck) = parameterName { startswith(valueToCheck, "[parameters('") endswith(valueToCheck, "')]") - parameterName := trim_right(trim_left(valueToCheck, "[parameters('"),"')]") + parameterName := trim_right(trim_left(trim_left(valueToCheck, "[parameters"), "('"), "')]") } diff --git a/go.mod b/go.mod index d796704ced1..2bf2cde39d1 100644 --- a/go.mod +++ b/go.mod @@ -226,7 +226,7 @@ require ( golang.org/x/sys v0.21.0 // indirect golang.org/x/term v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect - google.golang.org/grpc v1.64.0 // indirect + google.golang.org/grpc v1.64.1 // indirect google.golang.org/protobuf v1.34.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index d8b13c7a133..b849e5cbb75 100644 --- a/go.sum +++ b/go.sum @@ -1421,8 +1421,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= -google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= +google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/pkg/resolver/file/file.go b/pkg/resolver/file/file.go index 07d83e84762..b51e33bc148 100644 --- a/pkg/resolver/file/file.go +++ b/pkg/resolver/file/file.go @@ -450,7 +450,7 @@ func (r *Resolver) resolvePath( return obj, false } } - return r.resolvePathReturnValue(value, filePath, splitPath, sameFileResolve, originalFileContent, obj) + return r.resolvePathReturnValue(value, filePath, splitPath, sameFileResolve, originalFileContent, obj, maxResolverDepth) } func (r *Resolver) resolvePathReturnValue( @@ -458,7 +458,8 @@ func (r *Resolver) resolvePathReturnValue( splitPath []string, sameFileResolve bool, originalFileContent []byte, - obj any) (any, bool) { + obj any, + maxResolverDepth int) (any, bool) { if len(splitPath) > 1 { if sameFileResolve { r.ResolvedFiles[filePath] = model.ResolvedFile{ @@ -469,7 +470,7 @@ func (r *Resolver) resolvePathReturnValue( } section, err := findSection(obj, splitPath[1]) // Check if there was an error finding the section or if the reference is circular - if err != nil || checkIfCircular(value, section) { + if err != nil || checkIfCircular(value, section, maxResolverDepth) { return value, false } if sectionMap, ok := section.(map[string]interface{}); ok { @@ -537,25 +538,27 @@ func findSection(object interface{}, sectionsString string) (interface{}, error) return object, nil } -func checkIfCircular(circularValue string, section interface{}) bool { - sectionAsMap, okMap := section.(map[string]interface{}) - sectionAsList, okList := section.([]interface{}) - if !okList && !okMap { - return false - } - if okMap { - for key, val := range sectionAsMap { - // if there is a reference to the same value that was resolved it is a circular definition - if key == "$ref" && val == circularValue { - return true - } else if checkIfCircular(circularValue, val) { - return true - } +func checkIfCircular(circularValue string, section interface{}, maxResolverDepth int) bool { + if maxResolverDepth > 0 { + sectionAsMap, okMap := section.(map[string]interface{}) + sectionAsList, okList := section.([]interface{}) + if !okList && !okMap { + return false } - } else { - for _, listSection := range sectionAsList { - if checkIfCircular(circularValue, listSection) { - return true + if okMap { + for key, val := range sectionAsMap { + // if there is a reference to the same value that was resolved it is a circular definition + if key == "$ref" && val == circularValue { + return true + } else if checkIfCircular(circularValue, val, maxResolverDepth-1) { + return true + } + } + } else { + for _, listSection := range sectionAsList { + if checkIfCircular(circularValue, listSection, maxResolverDepth-1) { + return true + } } } }