refactor: upgrade golangci-lint to v2.0.2 (#28416)

This commit is contained in:
McKayla はな
2026-08-21 23:46:27 -06:00
committed by GitHub
parent 610f321d52
commit 5ca0143992
134 changed files with 552 additions and 626 deletions
+1 -1
View File
@@ -1094,7 +1094,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
require.NoError(t, err)
// Verify the prefix is in the token.
require.Equal(t, prefixedOwnerApp.Prefix, tok.Request.Prefix)
require.Equal(t, prefixedOwnerApp.Prefix, tok.Prefix)
// Ensure the signed app token cookie is valid by making a request with
// it with no session token.
+4 -4
View File
@@ -322,8 +322,8 @@ func (p *DBTokenProvider) authorizeRequest(ctx context.Context, roles *rbac.Subj
// Figure out which RBAC resource to check. For terminals we use execution
// instead of application connect.
var (
rbacAction policy.Action = policy.ActionApplicationConnect
rbacResource rbac.Object = dbReq.Workspace.RBACObject()
rbacAction = policy.ActionApplicationConnect
rbacResource = dbReq.Workspace.RBACObject()
// rbacResourceOwned is for the level "authenticated". We still need to
// make sure the API key has permissions to connect to the actor's own
// workspace. Scopes would prevent this.
@@ -336,7 +336,7 @@ func (p *DBTokenProvider) authorizeRequest(ctx context.Context, roles *rbac.Subj
// the object to check the proper permissions. AnyOrg is almost the same,
// but technically excludes users who are not in any organization. This is
// the closest we can get though without more significant refactoring.
rbacResourceOwned rbac.Object = rbac.ResourceWorkspace.WithOwner(roles.ID).AnyOrganization()
rbacResourceOwned = rbac.ResourceWorkspace.WithOwner(roles.ID).AnyOrganization()
)
if dbReq.AccessMethod == AccessMethodTerminal {
rbacAction = policy.ActionSSH
@@ -446,7 +446,7 @@ func (p *DBTokenProvider) connLogInitRequest(w http.ResponseWriter, r *http.Requ
// Approximation of the status code.
// #nosec G115 - Safe conversion as HTTP status code is expected to be within int32 range (typically 100-599)
var statusCode int32 = int32(sw.Status)
statusCode := int32(sw.Status)
if statusCode == 0 {
statusCode = http.StatusOK
}
+1 -1
View File
@@ -835,7 +835,7 @@ func Test_ResolveRequest(t *testing.T) {
require.Equal(t, req.BasePath, token.BasePath)
require.Empty(t, token.UsernameOrID)
require.Empty(t, token.WorkspaceNameOrID)
require.Equal(t, req.AgentNameOrID, token.Request.AgentNameOrID)
require.Equal(t, req.AgentNameOrID, token.AgentNameOrID)
require.Empty(t, token.AppSlugOrPort)
require.Empty(t, token.AppURL)
assertConnLogContains(t, rw, r, connLogger, workspace, agentName, "terminal", database.ConnectionTypeWorkspaceApp, me.ID)
+2 -2
View File
@@ -32,7 +32,7 @@ type SignedToken struct {
// MatchesRequest returns true if the token matches the request. Any token that
// does not match the request should be considered invalid.
func (t SignedToken) MatchesRequest(req Request) bool {
tokenBasePath := t.Request.BasePath
tokenBasePath := t.BasePath
if !strings.HasSuffix(tokenBasePath, "/") {
tokenBasePath += "/"
}
@@ -111,7 +111,7 @@ func FromRequest(r *http.Request, mgr cryptokeys.SigningKeycache) (*SignedToken,
Time: time.Now(),
}))
if err == nil {
req := token.Request.Normalize()
req := token.Normalize()
if hasQueryParam && req.AccessMethod != AccessMethodTerminal {
// The request must be a terminal request if we're using a
// query parameter.
+1 -1
View File
@@ -316,7 +316,7 @@ func Test_FromRequest(t *testing.T) {
// Add an expired cookie
expired := token
expired.RegisteredClaims.Expiry = jwt.NewNumericDate(time.Now().Add(time.Hour * -1))
expired.Expiry = jwt.NewNumericDate(time.Now().Add(time.Hour * -1))
expiredStr, err := jwtutils.Sign(ctx, signer, expired)
require.NoError(t, err)
r.AddCookie(&http.Cookie{