Skip to content

Commit

Permalink
build: Ensure constant format strings in fmt and printf calls
Browse files Browse the repository at this point in the history
Go 1.24 introduces stricter checks for format string validation.
This commit fixes instances where non-constant format strings were
used in calls to functions like `fmt.Errorf`, `fmt.Printf`, and similar.

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
  • Loading branch information
mikelolasagasti committed Jan 20, 2025
1 parent 6d84e0c commit 7edc77c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/iac/scanners/terraform/parser/funcs/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ var SumFunc = function.New(&function.Spec{
ty := args[0].Type()

if !ty.IsListType() && !ty.IsSetType() && !ty.IsTupleType() {
return cty.NilVal, function.NewArgErrorf(0, fmt.Sprintf("argument must be list, set, or tuple. Received %s", ty.FriendlyName()))
return cty.NilVal, function.NewArgErrorf(0, "argument must be list, set, or tuple. Received %s", ty.FriendlyName())

}

if !args[0].IsWhollyKnown() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/iac/scanners/terraform/parser/funcs/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var RsaDecryptFunc = function.New(&function.Spec{
default:
errStr = fmt.Sprintf("invalid private key: %s", e)
}
return cty.UnknownVal(cty.String), function.NewArgErrorf(1, errStr)
return cty.UnknownVal(cty.String), function.NewArgErrorf(1, "%s", errStr)
}
privateKey, ok := rawKey.(*rsa.PrivateKey)
if !ok {
Expand Down

0 comments on commit 7edc77c

Please sign in to comment.