nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: helm/helm
Pull request #7558 (2020-02-07 23:21:18)

fix recursion count in templates
The count in `includedNames` is incremented every time a name is seen, but is not decremented after executing the template. In a large helm chart, a function could be included many times, which exceeds the `1000` limit, without necessarily including any recursion.

Recursive functions such as
```
{{- define "test.recursionTest" -}}
{{- printf "%s" (include "test.recursionTest" .) -}}
{{- end -}}
```
are still detected and result in an error.

Closes https://github.com/helm/helm/issues/7559


Patch:
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go
index 490561037..1cc94d685 100644
--- a/pkg/engine/engine.go
+++ b/pkg/engine/engine.go
@@ -120,6 +120,7 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render
 			includedNames[name] = 1
 		}
 		err := t.ExecuteTemplate(&buf, name, data)
+		includedNames[name]--
 		return buf.String(), err
 	}
 


Test patch:
diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go
index f3609fcbd..d5f36aac8 100644
--- a/pkg/engine/engine_test.go
+++ b/pkg/engine/engine_test.go
@@ -643,3 +643,58 @@ func TestAlterFuncMap_tplinclude(t *testing.T) {
 	}
 
 }
+
+func TestRenderRecursionLimit(t *testing.T) {
+	// endless recursion should produce an error
+	c := &chart.Chart{
+		Metadata: &chart.Metadata{Name: "bad"},
+		Templates: []*chart.File{
+			{Name: "templates/base", Data: []byte(`{{include "recursion" . }}`)},
+			{Name: "templates/recursion", Data: []byte(`{{define "recursion"}}{{include "recursion" . }}{{end}}`)},
+		},
+	}
+	v := chartutil.Values{
+		"Values": "",
+		"Chart":  c.Metadata,
+		"Release": chartutil.Values{
+			"Name": "TestRelease",
+		},
+	}
+	expectErr := "rendering template has a nested reference name: recursion: unable to execute template"
+
+	_, err := Render(c, v)
+	if err == nil || !strings.HasSuffix(err.Error(), expectErr) {
+		t.Errorf("Expected err with suffix: %s", expectErr)
+	}
+
+	// calling the same function many times is ok
+	times := 4000
+	phrase := "All work and no play makes Jack a dull boy"
+	printFunc := `{{define "overlook"}}{{printf "` + phrase + `\n"}}{{end}}`
+	var repeatedIncl string
+	for i := 0; i < times; i++ {
+		repeatedIncl += `{{include "overlook" . }}`
+	}
+
+	d := &chart.Chart{
+		Metadata: &chart.Metadata{Name: "overlook"},
+		Templates: []*chart.File{
+			{Name: "templates/quote", Data: []byte(repeatedIncl)},
+			{Name: "templates/_function", Data: []byte(printFunc)},
+		},
+	}
+
+	out, err := Render(d, v)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var expect string
+	for i := 0; i < times; i++ {
+		expect += phrase + "\n"
+	}
+	if got := out["overlook/templates/quote"]; got != expect {
+		t.Errorf("Expected %q, got %q (%v)", expect, got, out)
+	}
+
+}
Repository: helm/helm
Pull request #7707 (2020-02-28 17:56:19)

Add verification output to the verify command
This complements the verification output fixed in #7706. On verify
there should be some detail about the verification rather than
no information.


Patch:
diff --git a/cmd/helm/verify.go b/cmd/helm/verify.go
index d3ae517c9..f26fb377f 100644
--- a/cmd/helm/verify.go
+++ b/cmd/helm/verify.go
@@ -16,6 +16,7 @@ limitations under the License.
 package main
 
 import (
+	"fmt"
 	"io"
 
 	"github.com/spf13/cobra"
@@ -44,7 +45,14 @@ func newVerifyCmd(out io.Writer) *cobra.Command {
 		Long:  verifyDesc,
 		Args:  require.ExactArgs(1),
 		RunE: func(cmd *cobra.Command, args []string) error {
-			return client.Run(args[0])
+			err := client.Run(args[0])
+			if err != nil {
+				return err
+			}
+
+			fmt.Fprint(out, client.Out)
+
+			return nil
 		},
 	}
 
diff --git a/pkg/action/verify.go b/pkg/action/verify.go
index c66b14b47..f36239496 100644
--- a/pkg/action/verify.go
+++ b/pkg/action/verify.go
@@ -17,6 +17,9 @@ limitations under the License.
 package action
 
 import (
+	"fmt"
+	"strings"
+
 	"helm.sh/helm/v3/pkg/downloader"
 )
 
@@ -25,6 +28,7 @@ import (
 // It provides the implementation of 'helm verify'.
 type Verify struct {
 	Keyring string
+	Out     string
 }
 
 // NewVerify creates a new Verify object with the given configuration.
@@ -34,6 +38,22 @@ func NewVerify() *Verify {
 
 // Run executes 'helm verify'.
 func (v *Verify) Run(chartfile string) error {
-	_, err := downloader.VerifyChart(chartfile, v.Keyring)
-	return err
+	var out strings.Builder
+	p, err := downloader.VerifyChart(chartfile, v.Keyring)
+	if err != nil {
+		return err
+	}
+
+	for name := range p.SignedBy.Identities {
+		fmt.Fprintf(&out, "Signed by: %v\n", name)
+	}
+	fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", p.SignedBy.PrimaryKey.Fingerprint)
+	fmt.Fprintf(&out, "Chart Hash Verified: %s\n", p.FileHash)
+
+	// TODO(mattfarina): The output is set as a property rather than returned
+	// to maintain the Go API. In Helm v4 this function should return the out
+	// and the property on the struct can be removed.
+	v.Out = out.String()
+
+	return nil
 }


Test patch:
diff --git a/cmd/helm/verify_test.go b/cmd/helm/verify_test.go
index a70051ff6..ccbcb3cf2 100644
--- a/cmd/helm/verify_test.go
+++ b/cmd/helm/verify_test.go
@@ -65,7 +65,7 @@ func TestVerifyCmd(t *testing.T) {
 		{
 			name:      "verify validates a properly signed chart",
 			cmd:       "verify testdata/testcharts/signtest-0.1.0.tgz --keyring testdata/helm-test-key.pub",
-			expect:    "",
+			expect:    "Signed by: Helm Testing (This key should only be used for testing. DO NOT TRUST.) <helm-testing@helm.sh>\nUsing Key With Fingerprint: 5E615389B53CA37F0EE60BD3843BBF981FC18762\nChart Hash Verified: sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55\n",
 			wantError: false,
 		},
 	}