Repository: inbucket/inbucket
Pull request #513 (2024-06-10 19:08:24)

build(deps): bump goreleaser/goreleaser-action from 5 to 6
Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 5 to 6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/goreleaser/goreleaser-action/releases">goreleaser/goreleaser-action's releases</a>.</em></p>
<blockquote>
<h2>v6.0.0</h2>
<blockquote>
<p>[!WARNING]
<strong>This is a breaking change!</strong></p>
<p>Follow the instructions <a href="https://goreleaser.com/blog/goreleaser-v2/#upgrading">here</a> to upgrade!</p>
</blockquote>
<h2>What's Changed</h2>
<ul>
<li>feat!: use &quot;~&gt; v2&quot; as default by <a href="https://github.com/caarlos0"><code>@​caarlos0</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/463">goreleaser/goreleaser-action#463</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/goreleaser/goreleaser-action/compare/v5...v6.0.0">https://github.com/goreleaser/goreleaser-action/compare/v5...v6.0.0</a></p>
<h2>v5.1.0</h2>
<h2>Important</h2>
<p>This version changes the default behavior of <code>latest</code> to <code>~&gt; v1</code>.</p>
<p>The next major of this action (v6), will change this to <code>~&gt; v2</code>, and will be launched together with GoReleaser v2.</p>
<h2>What's Changed</h2>
<ul>
<li>docs: bump actions to latest major by <a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/435">goreleaser/goreleaser-action#435</a></li>
<li>chore(deps): bump docker/bake-action from 3 to 4 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/436">goreleaser/goreleaser-action#436</a></li>
<li>chore(deps): bump codecov/codecov-action from 3 to 4 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/437">goreleaser/goreleaser-action#437</a></li>
<li>chore(deps): bump actions/setup-go from 4 to 5 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/443">goreleaser/goreleaser-action#443</a></li>
<li>chore(deps): bump actions/upload-artifact from 3 to 4 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/444">goreleaser/goreleaser-action#444</a></li>
<li>Delete .kodiak.toml by <a href="https://github.com/vedantmgoyal9"><code>@​vedantmgoyal9</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/446">goreleaser/goreleaser-action#446</a></li>
<li>chore(deps): bump codecov/codecov-action from 3 to 4 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/448">goreleaser/goreleaser-action#448</a></li>
<li>chore(deps): bump ip from 2.0.0 to 2.0.1 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/450">goreleaser/goreleaser-action#450</a></li>
<li>Upgrade setup-go action version in README by <a href="https://github.com/kishaningithub"><code>@​kishaningithub</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/455">goreleaser/goreleaser-action#455</a></li>
<li>chore(deps): bump tar from 6.1.14 to 6.2.1 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/456">goreleaser/goreleaser-action#456</a></li>
<li>chore: use corepack to install yarn by <a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/458">goreleaser/goreleaser-action#458</a></li>
<li>feat: lock this major version of the action to use '~&gt; v1' as 'latest' by <a href="https://github.com/caarlos0"><code>@​caarlos0</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/461">goreleaser/goreleaser-action#461</a></li>
<li>chore(deps): bump semver from 7.6.0 to 7.6.2 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/462">goreleaser/goreleaser-action#462</a></li>
<li>chore(deps): bump <code>@​actions/http-client</code> from 2.2.0 to 2.2.1 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/451">goreleaser/goreleaser-action#451</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/vedantmgoyal9"><code>@​vedantmgoyal9</code></a> made their first contribution in <a href="https://redirect.github.com/goreleaser/goreleaser-action/pull/446">goreleaser/goreleaser-action#446</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/goreleaser/goreleaser-action/compare/v5.0.0...v5.1.0">https://github.com/goreleaser/goreleaser-action/compare/v5.0.0...v5.1.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/goreleaser/goreleaser-action/commit/286f3b13b1b49da4ac219696163fb8c1c93e1200"><code>286f3b1</code></a> ci: fix tests</li>
<li><a href="https://github.com/goreleaser/goreleaser-action/commit/beac41031402cb955b6b1325b39dc6a3aaddfa61"><code>beac410</code></a> ci: update workflow and .goreleaser.yml</li>
<li><a href="https://github.com/goreleaser/goreleaser-action/commit/18bbabc70c50bcffbadb2dc68d6d5266056978cb"><code>18bbabc</code></a> feat!: use &quot;~&gt; v2&quot; as default (<a href="https://redirect.github.com/goreleaser/goreleaser-action/issues/463">#463</a>)</li>
<li>See full diff in <a href="https://github.com/goreleaser/goreleaser-action/compare/v5...v6">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=goreleaser/goreleaser-action&package-manager=github_actions&previous-version=5&new-version=6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

> **Note**
> Automatic rebases have been disabled on this pull request as it has been open for over 30 days.


coveralls: ## Pull Request Test Coverage Report for [Build 9454132860](https://coveralls.io/builds/67997645)


### Details

* **0** of **0**   changed or added relevant lines in **0** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **55.828%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/67997645/badge)](https://coveralls.io/builds/67997645) |
| :-- | --: |
| Change from base [Build 9073603067](https://coveralls.io/builds/67470658): |  0.0% |
| Covered Lines: | 2687 |
| Relevant Lines: | 4813 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
index 81bfa07..a8eb622 100644
--- a/.github/workflows/docker-build.yml
+++ b/.github/workflows/docker-build.yml
@@ -62,7 +62,7 @@ jobs:
           password: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Build and push
-        uses: docker/build-push-action@v5
+        uses: docker/build-push-action@v6
         with:
           context: .
           platforms: linux/amd64,linux/arm64, linux/arm/v7
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 165b88f..4808aca 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -15,6 +15,3 @@ jobs:
         uses: golangci/golangci-lint-action@v6
         with:
           version: latest
-          # Disable cache to prevent `File exists` errors.
-          # https://github.com/golangci/golangci-lint-action/issues/135
-          skip-pkg-cache: true
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6226a50..131fa25 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -37,14 +37,14 @@ jobs:
         working-directory: ./ui
 
       - name: Test build release
-        uses: goreleaser/goreleaser-action@v5
+        uses: goreleaser/goreleaser-action@v6
         if: "!startsWith(github.ref, 'refs/tags/v')"
         with:
           version: latest
           args: release --snapshot
 
       - name: Build and publish release
-        uses: goreleaser/goreleaser-action@v5
+        uses: goreleaser/goreleaser-action@v6
         if: "startsWith(github.ref, 'refs/tags/v')"
         with:
           version: latest
diff --git a/.golangci.yml b/.golangci.yml
index db96041..10faedf 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -15,7 +15,6 @@ linters:
     - errchkjson
     - errname
     # - errorlint
-    - execinquery
     # - exhaustive
     - exportloopref
     # - forcetypeassert
diff --git a/pkg/server/pop3/handler.go b/pkg/server/pop3/handler.go
index ce7df98..7181a4a 100644
--- a/pkg/server/pop3/handler.go
+++ b/pkg/server/pop3/handler.go
@@ -218,13 +218,13 @@ func (s *Session) authorizationHandler(cmd string, args []string) {
 			// Invalid command since TLS unconfigured.
 			s.logger.Debug().Msgf("-ERR TLS unavailable on the server")
 			s.send("-ERR TLS unavailable on the server")
-			s.ooSeq(cmd)
+			return
 		}
 		if s.tlsState != nil {
 			// TLS state previously valid.
 			s.logger.Debug().Msg("-ERR A TLS session already agreed upon.")
 			s.send("-ERR A TLS session already agreed upon.")
-			s.ooSeq(cmd)
+			return
 		}
 		s.logger.Debug().Msg("Initiating TLS context.")
 


Test patch:
diff --git a/pkg/server/pop3/handler_test.go b/pkg/server/pop3/handler_test.go
index 480dbb3..5405493 100644
--- a/pkg/server/pop3/handler_test.go
+++ b/pkg/server/pop3/handler_test.go
@@ -29,8 +29,7 @@ func TestNoTLS(t *testing.T) {
 	pipe := setupPOPSession(t, server)
 	c := textproto.NewConn(pipe)
 	defer func() {
-		_ = c.PrintfLine("QUIT")
-		_, _ = c.ReadLine()
+		_ = c.Close()
 		server.Drain()
 	}()
 
@@ -41,21 +40,15 @@ func TestNoTLS(t *testing.T) {
 	if !strings.HasPrefix(reply, "+OK") {
 		t.Fatalf("Initial line is not +OK")
 	}
+
+	// Verify CAPA response does not include STLS.
 	if err := c.PrintfLine("CAPA"); err != nil {
 		t.Fatalf("Failed to send CAPA; %v.", err)
 	}
-	replies := []string{}
-	for {
-		reply, err := c.ReadLine()
-		if err != nil {
-			t.Fatalf("Reading CAPA line failed %v", err)
-		}
-		if reply == "." {
-			break
-		}
-		replies = append(replies, reply)
+	replies, err := c.ReadDotLines()
+	if err != nil {
+		t.Fatalf("Reading CAPA line failed %v", err)
 	}
-
 	for _, r := range replies {
 		if r == "STLS" {
 			t.Errorf("TLS not enabled but received STLS.")
@@ -63,14 +56,44 @@ func TestNoTLS(t *testing.T) {
 	}
 }
 
+func TestSTLSWithTLSDisabled(t *testing.T) {
+	ds := test.NewStore()
+	server := setupPOPServer(t, ds, false, false)
+	pipe := setupPOPSession(t, server)
+	_ = pipe.SetDeadline(time.Now().Add(10 * time.Second))
+	c := textproto.NewConn(pipe)
+	defer func() {
+		_ = c.Close()
+		server.Drain()
+	}()
+
+	reply, err := c.ReadLine()
+	if err != nil {
+		t.Fatalf("Reading initial line failed %v", err)
+	}
+	if !strings.HasPrefix(reply, "+OK") {
+		t.Fatalf("Initial line is not +OK")
+	}
+
+	if err := c.PrintfLine("STLS"); err != nil {
+		t.Fatalf("Failed to send STLS; %v.", err)
+	}
+	reply, err = c.ReadLine()
+	if err != nil {
+		t.Fatalf("Reading STLS reply line failed %v", err)
+	}
+	if !strings.HasPrefix(reply, "-ERR") {
+		t.Errorf("STLS should have errored: %s", reply)
+	}
+}
+
 func TestStartTLS(t *testing.T) {
 	ds := test.NewStore()
 	server := setupPOPServer(t, ds, true, false)
 	pipe := setupPOPSession(t, server)
 	c := textproto.NewConn(pipe)
 	defer func() {
-		_ = c.PrintfLine("QUIT")
-		_, _ = c.ReadLine()
+		_ = c.Close()
 		server.Drain()
 	}()
 
@@ -81,28 +104,21 @@ func TestStartTLS(t *testing.T) {
 	if !strings.HasPrefix(reply, "+OK") {
 		t.Fatalf("Initial line is not +OK")
 	}
+
+	// Verify CAPA response does not include STLS.
 	if err := c.PrintfLine("CAPA"); err != nil {
 		t.Fatalf("Failed to send CAPA; %v.", err)
 	}
-	replies := []string{}
-	for {
-		reply, err := c.ReadLine()
-		if err != nil {
-			t.Fatalf("Reading CAPA line failed %v", err)
-		}
-		if reply == "." {
-			break
-		}
-		replies = append(replies, reply)
+	replies, err := c.ReadDotLines()
+	if err != nil {
+		t.Fatalf("Reading CAPA line failed %v", err)
 	}
-
 	sawTLS := false
 	for _, r := range replies {
 		if r == "STLS" {
 			sawTLS = true
 		}
 	}
-
 	if !sawTLS {
 		t.Errorf("TLS enabled but no STLS capability.")
 	}
@@ -138,15 +154,95 @@ func TestStartTLS(t *testing.T) {
 	if !strings.HasPrefix(reply, "+OK") {
 		t.Fatalf("CAPA failed: %s", reply)
 	}
-	for {
-		reply, err := c.ReadLine()
-		if err != nil {
-			t.Fatalf("Reading CAPA line failed %v", err)
-		}
-		if reply == "." {
-			break
+	_, err = c.ReadDotLines()
+	if err != nil {
+		t.Fatalf("Reading CAPA line failed %v", err)
+	}
+}
+
+func TestDupStartTLS(t *testing.T) {
+	ds := test.NewStore()
+	server := setupPOPServer(t, ds, true, false)
+	pipe := setupPOPSession(t, server)
+	_ = pipe.SetDeadline(time.Now().Add(10 * time.Second))
+	c := textproto.NewConn(pipe)
+	defer func() {
+		_ = c.Close()
+		server.Drain()
+	}()
+
+	reply, err := c.ReadLine()
+	if err != nil {
+		t.Fatalf("Reading initial line failed %v", err)
+	}
+	if !strings.HasPrefix(reply, "+OK") {
+		t.Fatalf("Initial line is not +OK")
+	}
+
+	// Verify CAPA response includes STLS.
+	if err := c.PrintfLine("CAPA"); err != nil {
+		t.Fatalf("Failed to send CAPA; %v.", err)
+	}
+	replies, err := c.ReadDotLines()
+	if err != nil {
+		t.Fatalf("Reading CAPA line failed %v", err)
+	}
+	sawTLS := false
+	for _, r := range replies {
+		if r == "STLS" {
+			sawTLS = true
 		}
 	}
+	if !sawTLS {
+		t.Errorf("TLS enabled but no STLS capability.")
+	}
+
+	t.Log("Sending first STLS command, expected to succeed")
+	if err := c.PrintfLine("STLS"); err != nil {
+		t.Fatalf("Failed to send STLS; %v.", err)
+	}
+	reply, err = c.ReadLine()
+	if err != nil {
+		t.Fatalf("Reading STLS reply line failed %v", err)
+	}
+	if !strings.HasPrefix(reply, "+OK") {
+		t.Fatalf("STLS failed: %s", reply)
+	}
+
+	tlsConfig := &tls.Config{
+		InsecureSkipVerify: true,
+	}
+	tlsConn := tls.Client(pipe, tlsConfig)
+	ctx, toCancel := context.WithTimeout(context.Background(), 5*time.Second)
+	defer toCancel()
+	if err := tlsConn.HandshakeContext(ctx); err != nil {
+		t.Fatalf("TLS handshake failed; %v", err)
+	}
+	c = textproto.NewConn(tlsConn)
+
+	t.Log("Sending second STLS command, expected to fail")
+	if err := c.PrintfLine("STLS"); err != nil {
+		t.Fatalf("Failed to send STLS; %v.", err)
+	}
+	reply, err = c.ReadLine()
+	if err != nil {
+		t.Fatalf("Reading STLS reply line failed %v", err)
+	}
+	if !strings.HasPrefix(reply, "-ERR") {
+		t.Fatalf("STLS failed: %s", reply)
+	}
+
+	// Send STAT to verify handler has not crashed.
+	if err := c.PrintfLine("STAT"); err != nil {
+		t.Fatalf("Failed to send STAT; %v.", err)
+	}
+	reply, err = c.ReadLine()
+	if err != nil {
+		t.Fatalf("Reading STAT reply line failed %v", err)
+	}
+	if !strings.HasPrefix(reply, "-ERR") {
+		t.Fatalf("STAT failed: %s", reply)
+	}
 }
 
 func TestForceTLS(t *testing.T) {
@@ -165,8 +261,7 @@ func TestForceTLS(t *testing.T) {
 	}
 	c := textproto.NewConn(tlsConn)
 	defer func() {
-		_ = c.PrintfLine("QUIT")
-		_, _ = c.ReadLine()
+		_ = c.Close()
 		server.Drain()
 	}()
 
@@ -178,27 +273,18 @@ func TestForceTLS(t *testing.T) {
 		t.Fatalf("Initial line is not +OK")
 	}
 
+	// Verify CAPA response does not include STLS.
 	if err := c.PrintfLine("CAPA"); err != nil {
 		t.Fatalf("Failed to send CAPA; %v.", err)
 	}
-	reply, err = c.ReadLine()
+	replies, err := c.ReadDotLines()
 	if err != nil {
-		t.Fatalf("Reading CAPA reply line failed %v", err)
+		t.Fatalf("Reading CAPA line failed %v", err)
 	}
-	if !strings.HasPrefix(reply, "+OK") {
-		t.Fatalf("CAPA failed: %s", reply)
-	}
-	for {
-		reply, err := c.ReadLine()
-		if err != nil {
-			t.Fatalf("Reading CAPA line failed %v", err)
-		}
-		if reply == "STLS" {
+	for _, r := range replies {
+		if r == "STLS" {
 			t.Errorf("STLS in CAPA in forceTLS mode.")
 		}
-		if reply == "." {
-			break
-		}
 	}
 }