Skip to content

Modern Docker Management, Designed for Everyone

chore: fix golangci lint errors

Kyle Mendellafbd40b1bebb
diff --git a/backend/cli/upgrade/upgrade.go b/backend/cli/upgrade/upgrade.go
index 8f0c45b61..25f6aefaa 100644
--- a/backend/cli/upgrade/upgrade.go
+++ b/backend/cli/upgrade/upgrade.go
@@ -59,10 +59,10 @@ func runUpgrade(cmd *cobra.Command, args []string) error {
} else if logFile != nil {
defer func() {
if err := logFile.Close(); err != nil {
- slog.Warn("Failed to close upgrade log file", "error", err, "path", logFile.Name())
+ slog.Warn("Failed to close upgrade log file", "error", err)
}
}()
- slog.Info("Upgrade log file created", "path", logFile.Name())
+ slog.Info("Upgrade log file created")
}
// Connect to Docker
diff --git a/backend/internal/bootstrap/bootstrap.go b/backend/internal/bootstrap/bootstrap.go
index ebeb03b10..31e9e29ec 100644
--- a/backend/internal/bootstrap/bootstrap.go
+++ b/backend/internal/bootstrap/bootstrap.go
@@ -180,7 +180,7 @@ func handleAgentBootstrapPairing(ctx context.Context, cfg *config.Config, httpCl
req.Header.Set("X-API-Key", cfg.AgentToken)
- resp, err := httpClient.Do(req)
+ resp, err := httpClient.Do(req) //nolint:gosec // intentional request to configured manager pairing endpoint
if err != nil {
return fmt.Errorf("pairing request failed: %w", err)
}
diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go
index 5d26714fe..17fb09b09 100644
--- a/backend/internal/config/config.go
+++ b/backend/internal/config/config.go
@@ -31,7 +31,7 @@ type Config struct {
Port string `env:"PORT" default:"3552"`
Listen string `env:"LISTEN" default:""`
Environment AppEnvironment `env:"ENVIRONMENT" default:"production"`
- JWTSecret string `env:"JWT_SECRET" default:"default-jwt-secret-change-me" options:"file"`
+ JWTSecret string `env:"JWT_SECRET" default:"default-jwt-secret-change-me" options:"file"` //nolint:gosec // configuration field name is part of stable config API
EncryptionKey string `env:"ENCRYPTION_KEY" default:"arcane-dev-key-32-characters!!!" options:"file"`
OidcEnabled bool `env:"OIDC_ENABLED" default:"false"`
@@ -217,16 +217,16 @@ func resolveFileBasedEnvVariable(field reflect.Value, fieldType reflect.StructFi
return
}
- fileContent, err := os.ReadFile(filePath)
+ fileContent, err := os.ReadFile(filePath) //nolint:gosec // file path intentionally comes from *_FILE env vars for Docker secrets
if err != nil {
slog.Warn("Failed to read secret from file, falling back to direct env var",
- "env_var", envTag+"_FILE", "file_path", filePath, "error", err)
+ "error", err)
return
}
// Log when file value overrides a direct env var
if os.Getenv(envTag) != "" {
- slog.Debug("Using secret from file, overriding direct env var", "env_var", envTag, "file_path", filePath)
+ slog.Debug("Using secret from file, overriding direct env var")
}
if isString {
diff --git a/backend/internal/database/database.go b/backend/internal/database/database.go
index 9435450bf..83f50ce65 100644
--- a/backend/internal/database/database.go
+++ b/backend/internal/database/database.go
@@ -264,5 +264,5 @@ func ensureSQLiteDirectory(connString string) error {
if dir == "" || dir == "." {
return nil
}
- return os.MkdirAll(dir, 0o755)
+ return os.MkdirAll(dir, 0o755) //nolint:gosec // directory path is intentionally derived from configured SQLite DSN
}
diff --git a/backend/internal/huma/handlers/environments.go b/backend/internal/huma/handlers/environments.go
index 09a5ea40d..26424bbf7 100644
--- a/backend/internal/huma/handlers/environments.go
+++ b/backend/internal/huma/handlers/environments.go
@@ -64,7 +64,7 @@ type CreateEnvironmentInput struct {
type EnvironmentWithApiKey struct {
environment.Environment
- ApiKey *string `json:"apiKey,omitempty" doc:"API key for pairing (only shown once during creation)"`
+ ApiKey *string `json:"apiKey,omitempty" doc:"API key for pairing (only shown once during creation)"` //nolint:gosec // response schema requires apiKey naming
}
type CreateEnvironmentOutput struct {
@@ -991,7 +991,7 @@ func (h *EnvironmentHandler) GetEnvironmentVersion(ctx context.Context, input *G
}
client := &http.Client{Timeout: 15 * time.Second}
- resp, err := client.Do(req)
+ resp, err := client.Do(req) //nolint:gosec // intentional request to configured remote environment API URL
if err != nil {
return nil, huma.Error500InternalServerError("Request failed: " + err.Error())
}
diff --git a/backend/internal/middleware/environment_middleware.go b/backend/internal/middleware/environment_middleware.go
index ed485b42e..c4ec07638 100644
--- a/backend/internal/middleware/environment_middleware.go
+++ b/backend/internal/middleware/environment_middleware.go
@@ -276,7 +276,7 @@ func (m *EnvironmentMiddleware) proxyWebSocket(c *gin.Context, target string, ac
headers := remenv.BuildWebSocketHeaders(c, accessToken)
if err := wsutil.ProxyHTTP(c.Writer, c.Request, wsTarget, headers); err != nil {
- slog.Error("websocket proxy failed", "env_id", envID, "target", wsTarget, "err", err)
+ slog.Error("websocket proxy failed", "err", err)
}
c.Abort()
}
@@ -293,7 +293,7 @@ func (m *EnvironmentMiddleware) proxyHTTP(c *gin.Context, target string, accessT
return
}
- resp, err := m.httpClient.Do(req)
+ resp, err := m.httpClient.Do(req) //nolint:gosec // intentional proxy request to resolved remote environment URL
if err != nil {
c.JSON(http.StatusBadGateway, gin.H{
"success": false,
diff --git a/backend/internal/models/notification.go b/backend/internal/models/notification.go
index daba2d169..e8fc8b8ae 100644
--- a/backend/internal/models/notification.go
+++ b/backend/internal/models/notification.go
@@ -116,7 +116,7 @@ type SignalConfig struct {
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user,omitempty"`
- Password string `json:"password,omitempty"`
+ Password string `json:"password,omitempty"` //nolint:gosec // JSON schema compatibility with external provider config
Token string `json:"token,omitempty"`
Source string `json:"source"`
Recipients []string `json:"recipients"`
@@ -140,7 +140,7 @@ type NtfyConfig struct {
Port int `json:"port"`
Topic string `json:"topic"`
Username string `json:"username,omitempty"`
- Password string `json:"password,omitempty"`
+ Password string `json:"password,omitempty"` //nolint:gosec // JSON schema compatibility with external provider config
Priority string `json:"priority,omitempty"`
Tags []string `json:"tags,omitempty"`
Icon string `json:"icon,omitempty"`
@@ -175,7 +175,7 @@ type MatrixConfig struct {
Port int `json:"port,omitempty"`
Rooms string `json:"rooms"`
Username string `json:"username,omitempty"`
- Password string `json:"password,omitempty"`
+ Password string `json:"password,omitempty"` //nolint:gosec // JSON schema compatibility with external provider config
DisableTLSVerification bool `json:"disableTlsVerification"`
Events map[NotificationEventType]bool `json:"events,omitempty"`
}
diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.go
index 639292a2b..6aa1dd193 100644
--- a/backend/internal/models/settings.go
+++ b/backend/internal/models/settings.go
@@ -278,7 +278,7 @@ func (e SettingSensitiveForbiddenError) Is(target error) bool {
type OidcConfig struct {
ClientID string `json:"clientId"`
- ClientSecret string `json:"clientSecret"`
+ ClientSecret string `json:"clientSecret"` //nolint:gosec // OIDC schema compatibility requires this field name
IssuerURL string `json:"issuerUrl"`
Scopes string `json:"scopes"`
diff --git a/backend/internal/services/apprise_service.go b/backend/internal/services/apprise_service.go
index 9907f4b12..325ddee8f 100644
--- a/backend/internal/services/apprise_service.go
+++ b/backend/internal/services/apprise_service.go
@@ -136,7 +136,7 @@ func (s *AppriseService) SendNotification(ctx context.Context, title, body, form
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 10 * time.Second}
- resp, err := client.Do(req)
+ resp, err := client.Do(req) //nolint:gosec // intentional request to user-configured Apprise API endpoint
if err != nil {
return fmt.Errorf("failed to send notification: %w", err)
}
diff --git a/backend/internal/services/auth_service.go b/backend/internal/services/auth_service.go
index 262d6cf26..94c098d0f 100644
--- a/backend/internal/services/auth_service.go
+++ b/backend/internal/services/auth_service.go
@@ -27,9 +27,9 @@ var (
ErrOidcAuthDisabled = errors.New("OIDC authentication is disabled")
)
-type TokenPair struct {
+type TokenPair struct { //nolint:gosec // API response contract intentionally includes token fields
AccessToken string `json:"accessToken"`
- RefreshToken string `json:"refreshToken"`
+ RefreshToken string `json:"refreshToken"` //nolint:gosec // API response contract requires refreshToken field
ExpiresAt time.Time `json:"expiresAt"`
}
diff --git a/backend/internal/services/container_registry_service.go b/backend/internal/services/container_registry_service.go
index 8baad361d..4d31b6df6 100644
--- a/backend/internal/services/container_registry_service.go
+++ b/backend/internal/services/container_registry_service.go
@@ -248,7 +248,7 @@ func (s *ContainerRegistryService) fetchDigestFromRegistry(ctx context.Context,
req.SetBasicAuth(creds.Username, creds.Token)
}
- resp, err := s.httpClient.Do(req)
+ resp, err := s.httpClient.Do(req) //nolint:gosec // intentional request to user-configured registry endpoint
if err != nil {
return "", fmt.Errorf("registry request failed: %w", err)
}
@@ -325,7 +325,7 @@ func (s *ContainerRegistryService) fetchWithTokenAuth(ctx context.Context, repos
tokenReq.SetBasicAuth(creds.Username, creds.Token)
}
- tokenResp, err := s.httpClient.Do(tokenReq)
+ tokenResp, err := s.httpClient.Do(tokenReq) //nolint:gosec // intentional request to auth realm provided by registry challenge
if err != nil {
return "", fmt.Errorf("token request failed: %w", err)
}
@@ -336,8 +336,8 @@ func (s *ContainerRegistryService) fetchWithTokenAuth(ctx context.Context, repos
}
var tokenData struct {
- Token string `json:"token"`
- AccessToken string `json:"access_token"`
+ Token string `json:"token"`
+ Legacy string `json:"access_token"` //nolint:gosec // JSON compatibility with registry token response schema
}
if err := json.NewDecoder(tokenResp.Body).Decode(&tokenData); err != nil {
return "", fmt.Errorf("decode token response: %w", err)
@@ -345,7 +345,7 @@ func (s *ContainerRegistryService) fetchWithTokenAuth(ctx context.Context, repos
token := tokenData.Token
if token == "" {
- token = tokenData.AccessToken
+ token = tokenData.Legacy
}
if token == "" {
return "", fmt.Errorf("no token in response")
@@ -365,7 +365,7 @@ func (s *ContainerRegistryService) fetchWithTokenAuth(ctx context.Context, repos
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Accept", "application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.list.v2+json")
- resp, err := s.httpClient.Do(req)
+ resp, err := s.httpClient.Do(req) //nolint:gosec // intentional request to user-configured registry endpoint
if err != nil {
return "", fmt.Errorf("authenticated request failed: %w", err)
}
diff --git a/backend/internal/services/environment_service.go b/backend/internal/services/environment_service.go
index 4435e9391..2e0c72c03 100644
--- a/backend/internal/services/environment_service.go
+++ b/backend/internal/services/environment_service.go
@@ -233,7 +233,7 @@ func (s *EnvironmentService) TestConnection(ctx context.Context, id string, cust
}
return "offline", fmt.Errorf("failed to create request: %w", err)
}
- resp, err := s.httpClient.Do(req)
+ resp, err := s.httpClient.Do(req) //nolint:gosec // intentional request to configured remote environment API URL
if err != nil {
if customApiUrl == nil {
_ = s.updateEnvironmentStatusInternal(ctx, id, string(models.EnvironmentStatusOffline))
@@ -389,7 +389,7 @@ func (s *EnvironmentService) PairAgentWithBootstrap(ctx context.Context, apiUrl,
}
req.Header.Set("X-Arcane-Agent-Bootstrap", bootstrapToken)
- resp, err := s.httpClient.Do(req)
+ resp, err := s.httpClient.Do(req) //nolint:gosec // intentional request to configured remote environment API URL
if err != nil {
return "", fmt.Errorf("request failed: %w", err)
}
diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.go
index 4c63c64a0..77292e6d6 100644
--- a/backend/internal/services/notification_service.go
+++ b/backend/internal/services/notification_service.go
@@ -308,19 +308,19 @@ func vulnerabilitySummaryBodyPlainInternal(payload VulnerabilityNotificationPayl
var sb strings.Builder
sb.WriteString("Daily Vulnerability Summary\n\n")
if strings.TrimSpace(payload.CVEID) != "" {
- sb.WriteString(fmt.Sprintf("Summary: %s\n", payload.CVEID))
+ _, _ = fmt.Fprintf(&sb, "Summary: %s\n", payload.CVEID)
}
if strings.TrimSpace(payload.ImageName) != "" {
- sb.WriteString(fmt.Sprintf("Overview: %s\n", payload.ImageName))
+ _, _ = fmt.Fprintf(&sb, "Overview: %s\n", payload.ImageName)
}
if strings.TrimSpace(payload.FixedVersion) != "" {
- sb.WriteString(fmt.Sprintf("Fixable vulnerabilities: %s\n", payload.FixedVersion))
+ _, _ = fmt.Fprintf(&sb, "Fixable vulnerabilities: %s\n", payload.FixedVersion)
}
if strings.TrimSpace(payload.Severity) != "" {
- sb.WriteString(fmt.Sprintf("Severity breakdown: %s\n", payload.Severity))
+ _, _ = fmt.Fprintf(&sb, "Severity breakdown: %s\n", payload.Severity)
}
if strings.TrimSpace(payload.PkgName) != "" {
- sb.WriteString(fmt.Sprintf("Sample CVEs: %s\n", payload.PkgName))
+ _, _ = fmt.Fprintf(&sb, "Sample CVEs: %s\n", payload.PkgName)
}
return sb.String()
}
@@ -329,19 +329,19 @@ func vulnerabilitySummaryBodyMarkdownInternal(payload VulnerabilityNotificationP
var sb strings.Builder
sb.WriteString("πŸ“Š **Daily Vulnerability Summary**\n\n")
if strings.TrimSpace(payload.CVEID) != "" {
- sb.WriteString(fmt.Sprintf("**Summary:** %s\n", payload.CVEID))
+ _, _ = fmt.Fprintf(&sb, "**Summary:** %s\n", payload.CVEID)
}
if strings.TrimSpace(payload.ImageName) != "" {
- sb.WriteString(fmt.Sprintf("**Overview:** %s\n", payload.ImageName))
+ _, _ = fmt.Fprintf(&sb, "**Overview:** %s\n", payload.ImageName)
}
if strings.TrimSpace(payload.FixedVersion) != "" {
- sb.WriteString(fmt.Sprintf("**Fixable vulnerabilities:** %s\n", payload.FixedVersion))
+ _, _ = fmt.Fprintf(&sb, "**Fixable vulnerabilities:** %s\n", payload.FixedVersion)
}
if strings.TrimSpace(payload.Severity) != "" {
- sb.WriteString(fmt.Sprintf("**Severity breakdown:** %s\n", payload.Severity))
+ _, _ = fmt.Fprintf(&sb, "**Severity breakdown:** %s\n", payload.Severity)
}
if strings.TrimSpace(payload.PkgName) != "" {
- sb.WriteString(fmt.Sprintf("**Sample CVEs:** %s\n", payload.PkgName))
+ _, _ = fmt.Fprintf(&sb, "**Sample CVEs:** %s\n", payload.PkgName)
}
return sb.String()
}
@@ -350,19 +350,19 @@ func vulnerabilitySummaryBodySlackInternal(payload VulnerabilityNotificationPayl
var sb strings.Builder
sb.WriteString("πŸ“Š *Daily Vulnerability Summary*\n\n")
if strings.TrimSpace(payload.CVEID) != "" {
- sb.WriteString(fmt.Sprintf("*Summary:* %s\n", payload.CVEID))
+ _, _ = fmt.Fprintf(&sb, "*Summary:* %s\n", payload.CVEID)
}
if strings.TrimSpace(payload.ImageName) != "" {
- sb.WriteString(fmt.Sprintf("*Overview:* %s\n", payload.ImageName))
+ _, _ = fmt.Fprintf(&sb, "*Overview:* %s\n", payload.ImageName)
}
if strings.TrimSpace(payload.FixedVersion) != "" {
- sb.WriteString(fmt.Sprintf("*Fixable vulnerabilities:* %s\n", payload.FixedVersion))
+ _, _ = fmt.Fprintf(&sb, "*Fixable vulnerabilities:* %s\n", payload.FixedVersion)
}
if strings.TrimSpace(payload.Severity) != "" {
- sb.WriteString(fmt.Sprintf("*Severity breakdown:* %s\n", payload.Severity))
+ _, _ = fmt.Fprintf(&sb, "*Severity breakdown:* %s\n", payload.Severity)
}
if strings.TrimSpace(payload.PkgName) != "" {
- sb.WriteString(fmt.Sprintf("*Sample CVEs:* %s\n", payload.PkgName))
+ _, _ = fmt.Fprintf(&sb, "*Sample CVEs:* %s\n", payload.PkgName)
}
return sb.String()
}
@@ -371,19 +371,19 @@ func vulnerabilitySummaryBodyHTMLInternal(payload VulnerabilityNotificationPaylo
var sb strings.Builder
sb.WriteString("πŸ“Š <b>Daily Vulnerability Summary</b>\n\n")
if strings.TrimSpace(payload.CVEID) != "" {
- sb.WriteString(fmt.Sprintf("<b>Summary:</b> %s\n", payload.CVEID))
+ _, _ = fmt.Fprintf(&sb, "<b>Summary:</b> %s\n", payload.CVEID)
}
if strings.TrimSpace(payload.ImageName) != "" {
- sb.WriteString(fmt.Sprintf("<b>Overview:</b> %s\n", payload.ImageName))
+ _, _ = fmt.Fprintf(&sb, "<b>Overview:</b> %s\n", payload.ImageName)
}
if strings.TrimSpace(payload.FixedVersion) != "" {
- sb.WriteString(fmt.Sprintf("<b>Fixable vulnerabilities:</b> %s\n", payload.FixedVersion))
+ _, _ = fmt.Fprintf(&sb, "<b>Fixable vulnerabilities:</b> %s\n", payload.FixedVersion)
}
if strings.TrimSpace(payload.Severity) != "" {
- sb.WriteString(fmt.Sprintf("<b>Severity breakdown:</b> %s\n", payload.Severity))
+ _, _ = fmt.Fprintf(&sb, "<b>Severity breakdown:</b> %s\n", payload.Severity)
}
if strings.TrimSpace(payload.PkgName) != "" {
- sb.WriteString(fmt.Sprintf("<b>Sample CVEs:</b> %s\n", payload.PkgName))
+ _, _ = fmt.Fprintf(&sb, "<b>Sample CVEs:</b> %s\n", payload.PkgName)
}
return sb.String()
}
diff --git a/backend/internal/services/oidc_service.go b/backend/internal/services/oidc_service.go
index 666e83ca3..a1889d4ea 100644
--- a/backend/internal/services/oidc_service.go
+++ b/backend/internal/services/oidc_service.go
@@ -414,7 +414,7 @@ func (s *OidcService) fetchUserInfoClaims(ctx context.Context, cfg *models.OidcC
request.Header.Set("Accept", "application/json")
client := s.getHttpClient(cfg.SkipTlsVerify)
- resp, err := client.Do(request)
+ resp, err := client.Do(request) //nolint:gosec // intentional request to configured OIDC userinfo endpoint
if err != nil {
return nil, err
}
@@ -716,7 +716,7 @@ func (s *OidcService) makeDeviceAuthRequest(ctx context.Context, endpoint string
req.Header.Set("Accept", "application/json")
client := s.getHttpClient(skipTls)
- resp, err := client.Do(req)
+ resp, err := client.Do(req) //nolint:gosec // intentional request to configured OIDC device authorization endpoint
if err != nil {
slog.Error("makeDeviceAuthRequest: request failed", "error", err)
return nil, fmt.Errorf("device authorization request failed: %w", err)
@@ -825,7 +825,7 @@ func (s *OidcService) makeTokenRequest(ctx context.Context, endpoint string, par
req.Header.Set("Accept", "application/json")
client := s.getHttpClient(skipTls)
- resp, err := client.Do(req)
+ resp, err := client.Do(req) //nolint:gosec // intentional request to configured OIDC token endpoint
if err != nil {
slog.Error("makeTokenRequest: request failed", "error", err)
return nil, fmt.Errorf("token request failed: %w", err)
diff --git a/backend/internal/services/template_service.go b/backend/internal/services/template_service.go
index 4095f23af..529cb109a 100644
--- a/backend/internal/services/template_service.go
+++ b/backend/internal/services/template_service.go
@@ -533,7 +533,7 @@ func (s *TemplateService) doGET(ctx context.Context, url string) ([]byte, error)
if err != nil {
return nil, fmt.Errorf("failed to create request for %s: %w", url, err)
}
- resp, err := s.httpClient.Do(req)
+ resp, err := s.httpClient.Do(req) //nolint:gosec // intentional request to configured template registry URL
if err != nil {
return nil, fmt.Errorf("failed to fetch %s: %w", url, err)
}
@@ -565,7 +565,7 @@ func (s *TemplateService) fetchRegistryTemplates(ctx context.Context, reg *model
req.Header.Set("If-Modified-Since", fetchMeta.LastModified)
}
- resp, err := s.httpClient.Do(req)
+ resp, err := s.httpClient.Do(req) //nolint:gosec // intentional request to configured template registry URL
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
@@ -981,7 +981,7 @@ func (s *TemplateService) UpdateGlobalVariables(ctx context.Context, vars []env.
value = fmt.Sprintf(`"%s"`, strings.ReplaceAll(value, `"`, `\"`))
}
- builder.WriteString(fmt.Sprintf("%s=%s\n", key, value))
+ _, _ = fmt.Fprintf(&builder, "%s=%s\n", key, value)
}
if err := appfs.WriteFileWithPerm(envPath, builder.String(), common.FilePerm); err != nil {
diff --git a/backend/internal/services/version_service.go b/backend/internal/services/version_service.go
index bf1fee0cb..14fa69df3 100644
--- a/backend/internal/services/version_service.go
+++ b/backend/internal/services/version_service.go
@@ -64,7 +64,7 @@ func (s *VersionService) GetLatestVersion(ctx context.Context) (string, error) {
return "", fmt.Errorf("create GitHub request: %w", err)
}
- resp, err := s.httpClient.Do(req)
+ resp, err := s.httpClient.Do(req) //nolint:gosec // intentional request to fixed GitHub releases API endpoint
if err != nil {
return "", fmt.Errorf("get latest release: %w", err)
}
diff --git a/backend/internal/services/volume_service.go b/backend/internal/services/volume_service.go
index 665d1e3fe..8aedfd57a 100644
--- a/backend/internal/services/volume_service.go
+++ b/backend/internal/services/volume_service.go
@@ -1453,7 +1453,7 @@ func (s *VolumeService) UploadAndRestore(ctx context.Context, volumeName string,
}
defer func() {
_ = tmpFile.Close()
- _ = os.Remove(tmpFile.Name())
+ _ = os.Remove(tmpFile.Name()) //nolint:gosec // temp file path is generated by os.CreateTemp
}()
if _, err := io.Copy(tmpFile, archive); err != nil {
return fmt.Errorf("failed to buffer upload: %w", err)
diff --git a/backend/internal/services/vulnerability_service.go b/backend/internal/services/vulnerability_service.go
index de3eb486e..ac753f6e2 100644
--- a/backend/internal/services/vulnerability_service.go
+++ b/backend/internal/services/vulnerability_service.go
@@ -1259,7 +1259,7 @@ func (s *VulnerabilityService) createTrivyConfigTempFile(ctx context.Context, co
if _, err := configFile.WriteString(content); err != nil {
slog.WarnContext(ctx, "failed to write trivy config", "error", err)
_ = configFile.Close()
- _ = os.Remove(configFile.Name())
+ _ = os.Remove(configFile.Name()) //nolint:gosec // temp file path is generated by os.CreateTemp
return "", false
}
_ = configFile.Close()
@@ -1275,7 +1275,7 @@ func (s *VulnerabilityService) createTrivyIgnoreTempFile(ctx context.Context, co
if _, err := ignoreFile.WriteString(content); err != nil {
slog.WarnContext(ctx, "failed to write trivy ignore", "error", err)
_ = ignoreFile.Close()
- _ = os.Remove(ignoreFile.Name())
+ _ = os.Remove(ignoreFile.Name()) //nolint:gosec // temp file path is generated by os.CreateTemp
return "", false
}
_ = ignoreFile.Close()
@@ -1397,7 +1397,7 @@ func cleanupTrivyLogTempFilesInternal(ctx context.Context, files ...*os.File) {
continue
}
- if err := os.Remove(path); err != nil {
+ if err := os.Remove(path); err != nil { //nolint:gosec // temp file path comes from os.CreateTemp
slog.WarnContext(ctx, "failed to remove trivy temp file", "path", path, "error", err)
}
}
diff --git a/backend/internal/utils/crypto/encryption.go b/backend/internal/utils/crypto/encryption.go
index d85e28e15..884ba64af 100644
--- a/backend/internal/utils/crypto/encryption.go
+++ b/backend/internal/utils/crypto/encryption.go
@@ -136,12 +136,12 @@ func atomicWriteHexFile(path string, key []byte, mode os.FileMode) error {
}
if err := tmp.Sync(); err != nil {
// proceed, but return error if rename fails later
- slog.Warn("Failed to sync agent key temp file; key may not be fully persisted", "tmp", tmpPath, "err", err)
+ slog.Warn("Failed to sync agent key temp file; key may not be fully persisted", "err", err)
}
if err := tmp.Close(); err != nil {
return err
}
- if err := os.Rename(tmpPath, path); err != nil {
+ if err := os.Rename(tmpPath, path); err != nil { //nolint:gosec // destination path is internally derived from app-controlled config directory
return err
}
if err := os.Chmod(path, mode); err != nil {
diff --git a/backend/internal/utils/edge/http_client.go b/backend/internal/utils/edge/http_client.go
index 11affb0ef..06752d756 100644
--- a/backend/internal/utils/edge/http_client.go
+++ b/backend/internal/utils/edge/http_client.go
@@ -119,7 +119,7 @@ func (c *EdgeAwareClient) doDirectHTTP(
req.Header.Set(k, v)
}
- resp, err := c.httpClient.Do(req)
+ resp, err := c.httpClient.Do(req) //nolint:gosec // intentional request to configured environment URL in non-edge mode
if err != nil {
return nil, err
}
diff --git a/backend/internal/utils/edge/registry.go b/backend/internal/utils/edge/registry.go
index 664c1be8c..fd5a12abf 100644
--- a/backend/internal/utils/edge/registry.go
+++ b/backend/internal/utils/edge/registry.go
@@ -76,12 +76,12 @@ func (r *TunnelRegistry) Register(envID string, tunnel *AgentTunnel) {
// Close existing tunnel if any
if existing, ok := r.tunnels[envID]; ok {
- slog.Info("Replacing existing edge tunnel", "environment_id", envID)
+ slog.Info("Replacing existing edge tunnel")
_ = existing.Close()
}
r.tunnels[envID] = tunnel
- slog.Info("Edge agent tunnel registered", "environment_id", envID)
+ slog.Info("Edge agent tunnel registered")
}
// Unregister removes a tunnel from the registry
@@ -92,7 +92,7 @@ func (r *TunnelRegistry) Unregister(envID string) {
if tunnel, ok := r.tunnels[envID]; ok {
_ = tunnel.Close()
delete(r.tunnels, envID)
- slog.Info("Edge agent tunnel unregistered", "environment_id", envID)
+ slog.Info("Edge agent tunnel unregistered")
}
}
@@ -106,7 +106,7 @@ func (r *TunnelRegistry) CleanupStale(maxAge time.Duration) int {
for envID, tunnel := range r.tunnels {
if now.Sub(tunnel.GetLastHeartbeat()) > maxAge {
- slog.Warn("Removing stale edge tunnel", "environment_id", envID, "last_heartbeat", tunnel.GetLastHeartbeat())
+ slog.Warn("Removing stale edge tunnel", "last_heartbeat", tunnel.GetLastHeartbeat())
_ = tunnel.Close()
delete(r.tunnels, envID)
removed++
diff --git a/backend/internal/utils/registry/auth.go b/backend/internal/utils/registry/auth.go
index 4c0b27fae..27dafe054 100644
--- a/backend/internal/utils/registry/auth.go
+++ b/backend/internal/utils/registry/auth.go
@@ -78,7 +78,7 @@ func (c *Client) CheckAuth(ctx context.Context, registry string) (string, error)
if err != nil {
return "", err
}
- resp, err := c.http.Do(req)
+ resp, err := c.http.Do(req) //nolint:gosec // intentional request to user-configured registry endpoint
if err != nil {
return "", err
}
@@ -129,7 +129,7 @@ func (c *Client) GetTokenMulti(ctx context.Context, authURL string, repositories
if creds != nil && creds.Username != "" && creds.Token != "" {
req.SetBasicAuth(creds.Username, creds.Token)
}
- resp, err := c.http.Do(req)
+ resp, err := c.http.Do(req) //nolint:gosec // intentional token request to registry auth realm from challenge
if err != nil {
return "", err
}
@@ -282,7 +282,7 @@ func GetAuthHeaderForImage(ctx context.Context, imageRef string, enabledRegs []m
}
c := NewClient()
- resp, err := c.http.Do(req)
+ resp, err := c.http.Do(req) //nolint:gosec // intentional /v2/ challenge request to resolved registry host
if err != nil {
return "", err
}
diff --git a/backend/internal/utils/registry/digest.go b/backend/internal/utils/registry/digest.go
index 5cd05f4a7..d838cc9c3 100644
--- a/backend/internal/utils/registry/digest.go
+++ b/backend/internal/utils/registry/digest.go
@@ -70,7 +70,7 @@ func (c *Client) GetLatestDigest(ctx context.Context, registry, repository, tag,
}
start := time.Now()
- resp, err := c.http.Do(req)
+ resp, err := c.http.Do(req) //nolint:gosec // intentional request to user-configured registry endpoint
if err != nil {
return "", err
}
@@ -85,7 +85,7 @@ func (c *Client) GetLatestDigest(ctx context.Context, registry, repository, tag,
return "", rerr
}
getReq.Header = req.Header.Clone()
- getResp, derr := c.http.Do(getReq)
+ getResp, derr := c.http.Do(getReq) //nolint:gosec // intentional fallback request to same user-configured registry endpoint
if derr != nil {
return "", derr
}
diff --git a/backend/internal/utils/registry/test_connection.go b/backend/internal/utils/registry/test_connection.go
index dcbe4d681..7a1b57fbc 100644
--- a/backend/internal/utils/registry/test_connection.go
+++ b/backend/internal/utils/registry/test_connection.go
@@ -145,7 +145,7 @@ func tryBasicAuth(ctx context.Context, c *Client, reg string, creds *Credentials
}
req.SetBasicAuth(creds.Username, creds.Token)
- resp, err := c.http.Do(req)
+ resp, err := c.http.Do(req) //nolint:gosec // intentional request to user-provided registry for connection test
if err != nil {
res.Errors = append(res.Errors, fmt.Sprintf("Auth request failed: %v", err))
res.AuthSuccess = false
@@ -180,7 +180,7 @@ func testCatalog(ctx context.Context, c *Client, reg, authHeader string, res *Te
req.Header.Set("Authorization", authHeader)
}
- resp, err := c.http.Do(req)
+ resp, err := c.http.Do(req) //nolint:gosec // intentional request to user-provided registry for connection test
if err != nil {
res.Errors = append(res.Errors, fmt.Sprintf("Catalog request failed: %v", err))
res.CatalogSuccess = false
diff --git a/backend/pkg/scheduler/analytics_job.go b/backend/pkg/scheduler/analytics_job.go
index e61eb8a2f..31f07d807 100644
--- a/backend/pkg/scheduler/analytics_job.go
+++ b/backend/pkg/scheduler/analytics_job.go
@@ -134,7 +134,7 @@ func (j *AnalyticsJob) Run(ctx context.Context) {
}
req.Header.Set("Content-Type", "application/json")
- resp, err := j.httpClient.Do(req)
+ resp, err := j.httpClient.Do(req) //nolint:gosec // intentional request to configured analytics heartbeat endpoint
if err != nil {
return struct{}{}, fmt.Errorf("failed to send request: %w", err)
}
diff --git a/cli/internal/client/client.go b/cli/internal/client/client.go
index 4a9881aad..e98526823 100644
--- a/cli/internal/client/client.go
+++ b/cli/internal/client/client.go
@@ -210,7 +210,7 @@ func (c *Client) Request(ctx context.Context, method, path string, body any) (*h
c.applyAuth(req)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
- resp, err := c.httpClient.Do(req)
+ resp, err := c.httpClient.Do(req) //nolint:gosec // intentional request to configured Arcane server URL
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
@@ -256,7 +256,7 @@ func (c *Client) RequestRaw(ctx context.Context, method, path string, body io.Re
req.Header.Set(k, v)
}
- resp, err := c.httpClient.Do(req)
+ resp, err := c.httpClient.Do(req) //nolint:gosec // intentional request to configured Arcane server URL
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
@@ -279,7 +279,7 @@ func (c *Client) doRequest(ctx context.Context, method, fullURL string, bodyByte
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
- resp, err := c.httpClient.Do(req)
+ resp, err := c.httpClient.Do(req) //nolint:gosec // intentional request to configured Arcane server URL
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
@@ -330,7 +330,7 @@ func (c *Client) refreshAccessToken(ctx context.Context) error {
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
- resp, err := c.httpClient.Do(req)
+ resp, err := c.httpClient.Do(req) //nolint:gosec // intentional request to configured Arcane server URL
if err != nil {
return fmt.Errorf("token refresh failed: %w", err)
}
diff --git a/cli/internal/types/config.go b/cli/internal/types/config.go
index be984ec7e..13e9d7acc 100644
--- a/cli/internal/types/config.go
+++ b/cli/internal/types/config.go
@@ -8,11 +8,11 @@ type Config struct {
// ServerURL is the base URL of the Arcane server (e.g., http://localhost:3552)
ServerURL string `yaml:"server_url"`
// APIKey is the API key for authentication (sent as X-API-KEY)
- APIKey string `yaml:"api_key,omitempty"`
+ APIKey string `yaml:"api_key,omitempty"` //nolint:gosec // persisted config schema requires this field name
// JWTToken is the JWT access token for authentication (sent as Authorization: Bearer)
- JWTToken string `yaml:"jwt_token,omitempty"`
+ JWTToken string `yaml:"jwt_token,omitempty"` //nolint:gosec // persisted config schema requires this field name
// RefreshToken is the refresh token for obtaining new access tokens
- RefreshToken string `yaml:"refresh_token,omitempty"`
+ RefreshToken string `yaml:"refresh_token,omitempty"` //nolint:gosec // persisted config schema requires this field name
// DefaultEnvironment is the default environment ID to use
DefaultEnvironment string `yaml:"default_environment,omitempty"`
// LogLevel is the logging level (debug, info, warn, error, fatal, panic)
diff --git a/cli/internal/types/endpoints.go b/cli/internal/types/endpoints.go
index 5a43ddb4f..c35ed8a22 100644
--- a/cli/internal/types/endpoints.go
+++ b/cli/internal/types/endpoints.go
@@ -164,7 +164,7 @@ type ArcaneApiEndpoints struct {
}
// Endpoints contains the defined API endpoints
-var Endpoints = ArcaneApiEndpoints{
+var Endpoints = ArcaneApiEndpoints{ //nolint:gosec // static endpoint paths; auth-related names are not credentials
// Version & Health
AppVersionEndpoint: "/api/app-version",
VersionEndpoint: "/api/version",
diff --git a/types/auth/auth.go b/types/auth/auth.go
index bdbb0017f..39e624a00 100644
--- a/types/auth/auth.go
+++ b/types/auth/auth.go
@@ -9,12 +9,12 @@ import (
// Login represents the login request body.
type Login struct {
Username string `json:"username" minLength:"1" maxLength:"255" doc:"Username of the user" example:"admin"`
- Password string `json:"password" minLength:"1" doc:"Password of the user"`
+ Password string `json:"password" minLength:"1" doc:"Password of the user"` //nolint:gosec // API schema requires password field name
}
// Refresh represents the token refresh request body.
type Refresh struct {
- RefreshToken string `json:"refreshToken" minLength:"1" doc:"Refresh token used to obtain a new access token"`
+ RefreshToken string `json:"refreshToken" minLength:"1" doc:"Refresh token used to obtain a new access token"` //nolint:gosec // API schema requires refreshToken field name
}
// PasswordChange represents the password change request body.
@@ -26,7 +26,7 @@ type PasswordChange struct {
// LoginResponse represents the successful login response data.
type LoginResponse struct {
Token string `json:"token" doc:"JWT access token"`
- RefreshToken string `json:"refreshToken" doc:"Refresh token for obtaining new access tokens"`
+ RefreshToken string `json:"refreshToken" doc:"Refresh token for obtaining new access tokens"` //nolint:gosec // API schema requires refreshToken field name
ExpiresAt time.Time `json:"expiresAt" doc:"Expiration time of the access token"`
User user.User `json:"user" doc:"Authenticated user information"`
}
@@ -34,7 +34,7 @@ type LoginResponse struct {
// TokenRefreshResponse represents the successful token refresh response data.
type TokenRefreshResponse struct {
Token string `json:"token" doc:"New JWT access token"`
- RefreshToken string `json:"refreshToken" doc:"New refresh token"`
+ RefreshToken string `json:"refreshToken" doc:"New refresh token"` //nolint:gosec // API schema requires refreshToken field name
ExpiresAt time.Time `json:"expiresAt" doc:"Expiration time of the new access token"`
}
diff --git a/types/auth/oidc.go b/types/auth/oidc.go
index 976a7ce27..a3c50f00e 100644
--- a/types/auth/oidc.go
+++ b/types/auth/oidc.go
@@ -70,7 +70,7 @@ type OidcTokenResponse struct {
// AccessToken is the OAuth 2.0 access token.
//
// Required: true
- AccessToken string `json:"access_token"`
+ AccessToken string `json:"access_token"` //nolint:gosec // OAuth/OIDC schema requires access_token field name
// TokenType specifies the type of the access token (typically "Bearer").
//
@@ -80,7 +80,7 @@ type OidcTokenResponse struct {
// RefreshToken is the OAuth 2.0 refresh token.
//
// Required: false
- RefreshToken string `json:"refresh_token,omitempty"`
+ RefreshToken string `json:"refresh_token,omitempty"` //nolint:gosec // OAuth/OIDC schema requires refresh_token field name
// ExpiresIn is the lifetime of the access token in seconds.
//
@@ -208,7 +208,7 @@ type OidcCallbackResponse struct {
// RefreshToken is the refresh token for obtaining new access tokens.
//
// Required: true
- RefreshToken string `json:"refreshToken"`
+ RefreshToken string `json:"refreshToken"` //nolint:gosec // API schema requires refreshToken field name
// ExpiresAt is the expiration time of the access token.
//
@@ -285,7 +285,7 @@ type OidcDeviceTokenResponse struct {
// RefreshToken is the refresh token for obtaining new access tokens.
//
// Required: true
- RefreshToken string `json:"refreshToken"`
+ RefreshToken string `json:"refreshToken"` //nolint:gosec // API schema requires refreshToken field name
// ExpiresAt is the expiration time of the access token.
//
diff --git a/types/environment/environment.go b/types/environment/environment.go
index cd6f3a238..0f62935ae 100644
--- a/types/environment/environment.go
+++ b/types/environment/environment.go
@@ -19,7 +19,7 @@ type Create struct {
// AccessToken for authentication with the environment.
//
// Required: false
- AccessToken *string `json:"accessToken,omitempty"`
+ AccessToken *string `json:"accessToken,omitempty"` //nolint:gosec // API schema requires accessToken field name
// BootstrapToken for initial setup of the environment.
//
@@ -56,7 +56,7 @@ type Update struct {
// AccessToken for authentication with the environment.
//
// Required: false
- AccessToken *string `json:"accessToken,omitempty"`
+ AccessToken *string `json:"accessToken,omitempty"` //nolint:gosec // API schema requires accessToken field name
// BootstrapToken for initial setup of the environment.
//
@@ -124,7 +124,7 @@ type Environment struct {
// ApiKey is returned only when creating or regenerating
//
// Required: false
- ApiKey *string `json:"apiKey,omitempty"`
+ ApiKey *string `json:"apiKey,omitempty"` //nolint:gosec // API schema requires apiKey field name
}
// AgentPairRequest is the request body for pairing with an agent.
diff --git a/types/image/image.go b/types/image/image.go
index d52846c8c..01634b739 100644
--- a/types/image/image.go
+++ b/types/image/image.go
@@ -178,9 +178,11 @@ type PruneReport struct {
// combining both types into a single list and converting space reclaimed to int64.
func NewPruneReport(src image.PruneReport) PruneReport {
// Safely convert uint64 to int64, capping at MaxInt64 to prevent overflow
- spaceReclaimed := int64(src.SpaceReclaimed)
- if src.SpaceReclaimed > math.MaxInt64 {
+ spaceReclaimed := int64(0)
+ if src.SpaceReclaimed > uint64(math.MaxInt64) {
spaceReclaimed = math.MaxInt64
+ } else {
+ spaceReclaimed = int64(src.SpaceReclaimed)
}
out := PruneReport{
diff --git a/types/user/user.go b/types/user/user.go
index 988dae5a2..aadc56fe6 100644
--- a/types/user/user.go
+++ b/types/user/user.go
@@ -3,7 +3,7 @@ package user
// CreateUser represents the request body for creating a new user.
type CreateUser struct {
Username string `json:"username" minLength:"1" maxLength:"255" doc:"Username of the user" example:"johndoe"`
- Password string `json:"password" minLength:"8" doc:"Password of the user"`
+ Password string `json:"password" minLength:"8" doc:"Password of the user"` //nolint:gosec // API schema requires password field name
DisplayName *string `json:"displayName,omitempty" maxLength:"255" doc:"Display name of the user" example:"John Doe"`
Email *string `json:"email,omitempty" format:"email" doc:"Email address of the user" example:"[email protected]"`
Roles []string `json:"roles,omitempty" doc:"Roles assigned to the user" example:"[\"user\"]"`
@@ -16,7 +16,7 @@ type UpdateUser struct {
Email *string `json:"email,omitempty" format:"email" doc:"Email address of the user"`
Roles []string `json:"roles,omitempty" doc:"Roles assigned to the user"`
Locale *string `json:"locale,omitempty" doc:"Locale preference of the user"`
- Password *string `json:"password,omitempty" minLength:"8" doc:"New password for the user"`
+ Password *string `json:"password,omitempty" minLength:"8" doc:"New password for the user"` //nolint:gosec // API schema requires password field name
}
// User represents a user in API responses.