Compare commits
7 Commits
08377058c2
...
bfea5be063
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfea5be063 | ||
|
|
214b5f83ba | ||
|
|
b4b2a33089 | ||
| 3a4e999382 | |||
|
|
728b29ef16 | ||
| f61d4d0f91 | |||
|
|
8ec04fdadb |
@ -51,7 +51,7 @@ type Config struct {
|
|||||||
MaintenanceMode bool
|
MaintenanceMode bool
|
||||||
MetricsUsername string
|
MetricsUsername string
|
||||||
MetricsPassword string
|
MetricsPassword string
|
||||||
SessionSecret string
|
SessionSecret string //nolint:gosec // not a hardcoded credential, loaded from env/file
|
||||||
CORSOrigins string
|
CORSOrigins string
|
||||||
params *Params
|
params *Params
|
||||||
log *slog.Logger
|
log *slog.Logger
|
||||||
|
|||||||
@ -480,6 +480,20 @@ func (c *Client) CloneRepo(
|
|||||||
return c.performClone(ctx, cfg)
|
return c.performClone(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveImage removes a Docker image by ID or tag.
|
||||||
|
// It returns nil if the image was successfully removed or does not exist.
|
||||||
|
func (c *Client) RemoveImage(ctx context.Context, imageID string) error {
|
||||||
|
_, err := c.docker.ImageRemove(ctx, imageID, image.RemoveOptions{
|
||||||
|
Force: true,
|
||||||
|
PruneChildren: true,
|
||||||
|
})
|
||||||
|
if err != nil && !client.IsErrNotFound(err) {
|
||||||
|
return fmt.Errorf("failed to remove image %s: %w", imageID, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) performBuild(
|
func (c *Client) performBuild(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
opts BuildImageOptions,
|
opts BuildImageOptions,
|
||||||
@ -740,20 +754,6 @@ func (c *Client) connect(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveImage removes a Docker image by ID or tag.
|
|
||||||
// It returns nil if the image was successfully removed or does not exist.
|
|
||||||
func (c *Client) RemoveImage(ctx context.Context, imageID string) error {
|
|
||||||
_, err := c.docker.ImageRemove(ctx, imageID, image.RemoveOptions{
|
|
||||||
Force: true,
|
|
||||||
PruneChildren: true,
|
|
||||||
})
|
|
||||||
if err != nil && !client.IsErrNotFound(err) {
|
|
||||||
return fmt.Errorf("failed to remove image %s: %w", imageID, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) close() error {
|
func (c *Client) close() error {
|
||||||
if c.docker != nil {
|
if c.docker != nil {
|
||||||
err := c.docker.Close()
|
err := c.docker.Close()
|
||||||
|
|||||||
@ -76,7 +76,7 @@ func deploymentToAPI(d *models.Deployment) apiDeploymentResponse {
|
|||||||
func (h *Handlers) HandleAPILoginPOST() http.HandlerFunc {
|
func (h *Handlers) HandleAPILoginPOST() http.HandlerFunc {
|
||||||
type loginRequest struct {
|
type loginRequest struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"` //nolint:gosec // request field, not a hardcoded credential
|
||||||
}
|
}
|
||||||
|
|
||||||
type loginResponse struct {
|
type loginResponse struct {
|
||||||
@ -178,6 +178,27 @@ func (h *Handlers) HandleAPIGetApp() http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HandleAPICreateApp returns a handler that creates a new app.
|
// HandleAPICreateApp returns a handler that creates a new app.
|
||||||
|
// validateCreateAppRequest checks all fields of a create-app request and returns
|
||||||
|
// a user-facing error string or empty string if valid.
|
||||||
|
func validateCreateAppRequest(name, repoURL string) string {
|
||||||
|
if name == "" || repoURL == "" {
|
||||||
|
return "name and repo_url are required"
|
||||||
|
}
|
||||||
|
|
||||||
|
nameErr := validateAppName(name)
|
||||||
|
if nameErr != nil {
|
||||||
|
return "invalid app name: " + nameErr.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
repoURLErr := ValidateRepoURL(repoURL)
|
||||||
|
if repoURLErr != nil {
|
||||||
|
return "invalid repository URL: " + repoURLErr.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleAPICreateApp returns a handler that creates a new app via the API.
|
||||||
func (h *Handlers) HandleAPICreateApp() http.HandlerFunc {
|
func (h *Handlers) HandleAPICreateApp() http.HandlerFunc {
|
||||||
type createRequest struct {
|
type createRequest struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@ -201,18 +222,9 @@ func (h *Handlers) HandleAPICreateApp() http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Name == "" || req.RepoURL == "" {
|
if validationErr := validateCreateAppRequest(req.Name, req.RepoURL); validationErr != "" {
|
||||||
h.respondJSON(writer, request,
|
h.respondJSON(writer, request,
|
||||||
map[string]string{"error": "name and repo_url are required"},
|
map[string]string{"error": validationErr},
|
||||||
http.StatusBadRequest)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
nameErr := validateAppName(req.Name)
|
|
||||||
if nameErr != nil {
|
|
||||||
h.respondJSON(writer, request,
|
|
||||||
map[string]string{"error": "invalid app name: " + nameErr.Error()},
|
|
||||||
http.StatusBadRequest)
|
http.StatusBadRequest)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@ -77,6 +77,14 @@ func (h *Handlers) HandleAppCreate() http.HandlerFunc { //nolint:funlen // valid
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repoURLErr := ValidateRepoURL(repoURL)
|
||||||
|
if repoURLErr != nil {
|
||||||
|
data["Error"] = "Invalid repository URL: " + repoURLErr.Error()
|
||||||
|
h.renderTemplate(writer, tmpl, "app_new.html", data)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if branch == "" {
|
if branch == "" {
|
||||||
branch = "main"
|
branch = "main"
|
||||||
}
|
}
|
||||||
@ -225,6 +233,17 @@ func (h *Handlers) HandleAppUpdate() http.HandlerFunc { //nolint:funlen // valid
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repoURLErr := ValidateRepoURL(request.FormValue("repo_url"))
|
||||||
|
if repoURLErr != nil {
|
||||||
|
data := h.addGlobals(map[string]any{
|
||||||
|
"App": application,
|
||||||
|
"Error": "Invalid repository URL: " + repoURLErr.Error(),
|
||||||
|
}, request)
|
||||||
|
_ = tmpl.ExecuteTemplate(writer, "app_edit.html", data)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
application.Name = newName
|
application.Name = newName
|
||||||
application.RepoURL = request.FormValue("repo_url")
|
application.RepoURL = request.FormValue("repo_url")
|
||||||
application.Branch = request.FormValue("branch")
|
application.Branch = request.FormValue("branch")
|
||||||
@ -499,7 +518,8 @@ func (h *Handlers) HandleAppLogs() http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = writer.Write([]byte(logs))
|
//nolint:gosec // logs sanitized: ANSI escapes and control chars stripped
|
||||||
|
_, _ = writer.Write([]byte(SanitizeLogs(logs)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,11 +554,11 @@ func (h *Handlers) HandleDeploymentLogsAPI() http.HandlerFunc {
|
|||||||
|
|
||||||
logs := ""
|
logs := ""
|
||||||
if deployment.Logs.Valid {
|
if deployment.Logs.Valid {
|
||||||
logs = deployment.Logs.String
|
logs = SanitizeLogs(deployment.Logs.String)
|
||||||
}
|
}
|
||||||
|
|
||||||
response := map[string]any{
|
response := map[string]any{
|
||||||
"logs": logs,
|
"logs": SanitizeLogs(logs),
|
||||||
"status": deployment.Status,
|
"status": deployment.Status,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,7 +602,7 @@ func (h *Handlers) HandleDeploymentLogDownload() http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
_, err := os.Stat(logPath)
|
_, err := os.Stat(logPath) //nolint:gosec // logPath is constructed by deploy service, not from user input
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
http.NotFound(writer, request)
|
http.NotFound(writer, request)
|
||||||
|
|
||||||
@ -661,7 +681,7 @@ func (h *Handlers) HandleContainerLogsAPI() http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
response := map[string]any{
|
response := map[string]any{
|
||||||
"logs": logs,
|
"logs": SanitizeLogs(logs),
|
||||||
"status": status,
|
"status": status,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
70
internal/handlers/repo_url_validation.go
Normal file
70
internal/handlers/repo_url_validation.go
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/url"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Repo URL validation errors.
|
||||||
|
var (
|
||||||
|
errRepoURLEmpty = errors.New("repository URL must not be empty")
|
||||||
|
errRepoURLScheme = errors.New("file:// URLs are not allowed for security reasons")
|
||||||
|
errRepoURLInvalid = errors.New("repository URL must use https://, http://, ssh://, git://, or git@host:path format")
|
||||||
|
errRepoURLNoHost = errors.New("repository URL must include a host")
|
||||||
|
errRepoURLNoPath = errors.New("repository URL must include a path")
|
||||||
|
)
|
||||||
|
|
||||||
|
// scpLikeRepoRe matches SCP-like git URLs: git@host:path (e.g. git@github.com:user/repo.git).
|
||||||
|
// Only the "git" user is allowed, as that is the standard for SSH deploy keys.
|
||||||
|
var scpLikeRepoRe = regexp.MustCompile(`^git@[a-zA-Z0-9._-]+:.+$`)
|
||||||
|
|
||||||
|
// ValidateRepoURL checks that the given repository URL is valid and uses an allowed scheme.
|
||||||
|
func ValidateRepoURL(repoURL string) error {
|
||||||
|
if strings.TrimSpace(repoURL) == "" {
|
||||||
|
return errRepoURLEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject path traversal in any URL format
|
||||||
|
if strings.Contains(repoURL, "..") {
|
||||||
|
return errRepoURLInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for SCP-like git URLs first (git@host:path)
|
||||||
|
if scpLikeRepoRe.MatchString(repoURL) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject file:// explicitly
|
||||||
|
if strings.HasPrefix(strings.ToLower(repoURL), "file://") {
|
||||||
|
return errRepoURLScheme
|
||||||
|
}
|
||||||
|
|
||||||
|
return validateParsedURL(repoURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
// validateParsedURL validates a standard URL format repository URL.
|
||||||
|
func validateParsedURL(repoURL string) error {
|
||||||
|
parsed, err := url.Parse(repoURL)
|
||||||
|
if err != nil {
|
||||||
|
return errRepoURLInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
switch strings.ToLower(parsed.Scheme) {
|
||||||
|
case "https", "http", "ssh", "git":
|
||||||
|
// allowed
|
||||||
|
default:
|
||||||
|
return errRepoURLInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
if parsed.Host == "" {
|
||||||
|
return errRepoURLNoHost
|
||||||
|
}
|
||||||
|
|
||||||
|
if parsed.Path == "" || parsed.Path == "/" {
|
||||||
|
return errRepoURLNoPath
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
60
internal/handlers/repo_url_validation_test.go
Normal file
60
internal/handlers/repo_url_validation_test.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package handlers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.eeqj.de/sneak/upaas/internal/handlers"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValidateRepoURL(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
url string
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
// Valid URLs
|
||||||
|
{name: "https URL", url: "https://github.com/user/repo.git", wantErr: false},
|
||||||
|
{name: "http URL", url: "http://github.com/user/repo.git", wantErr: false},
|
||||||
|
{name: "ssh URL", url: "ssh://git@github.com/user/repo.git", wantErr: false},
|
||||||
|
{name: "git URL", url: "git://github.com/user/repo.git", wantErr: false},
|
||||||
|
{name: "SCP-like URL", url: "git@github.com:user/repo.git", wantErr: false},
|
||||||
|
{name: "SCP-like with dots", url: "git@git.example.com:org/repo.git", wantErr: false},
|
||||||
|
{name: "https without .git", url: "https://github.com/user/repo", wantErr: false},
|
||||||
|
{name: "https with port", url: "https://git.example.com:8443/user/repo.git", wantErr: false},
|
||||||
|
|
||||||
|
// Invalid URLs
|
||||||
|
{name: "empty string", url: "", wantErr: true},
|
||||||
|
{name: "whitespace only", url: " ", wantErr: true},
|
||||||
|
{name: "file URL", url: "file:///etc/passwd", wantErr: true},
|
||||||
|
{name: "file URL uppercase", url: "FILE:///etc/passwd", wantErr: true},
|
||||||
|
{name: "bare path", url: "/some/local/path", wantErr: true},
|
||||||
|
{name: "relative path", url: "../repo", wantErr: true},
|
||||||
|
{name: "just a word", url: "notaurl", wantErr: true},
|
||||||
|
{name: "ftp URL", url: "ftp://example.com/repo.git", wantErr: true},
|
||||||
|
{name: "no host https", url: "https:///path", wantErr: true},
|
||||||
|
{name: "no path https", url: "https://github.com", wantErr: true},
|
||||||
|
{name: "no path https trailing slash", url: "https://github.com/", wantErr: true},
|
||||||
|
{name: "SCP-like non-git user", url: "root@github.com:user/repo.git", wantErr: true},
|
||||||
|
{name: "SCP-like arbitrary user", url: "admin@github.com:user/repo.git", wantErr: true},
|
||||||
|
{name: "path traversal SCP", url: "git@github.com:../../etc/passwd", wantErr: true},
|
||||||
|
{name: "path traversal https", url: "https://github.com/user/../../../etc/passwd", wantErr: true},
|
||||||
|
{name: "path traversal in middle", url: "https://github.com/user/repo/../secret", wantErr: true},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
err := handlers.ValidateRepoURL(tc.url)
|
||||||
|
if tc.wantErr && err == nil {
|
||||||
|
t.Errorf("handlers.ValidateRepoURL(%q) = nil, want error", tc.url)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !tc.wantErr && err != nil {
|
||||||
|
t.Errorf("handlers.ValidateRepoURL(%q) = %v, want nil", tc.url, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
30
internal/handlers/sanitize.go
Normal file
30
internal/handlers/sanitize.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ansiEscapePattern matches ANSI escape sequences (CSI, OSC, and single-character escapes).
|
||||||
|
var ansiEscapePattern = regexp.MustCompile(`(\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\x1b[^[\]])`)
|
||||||
|
|
||||||
|
// SanitizeLogs strips ANSI escape sequences and non-printable control characters
|
||||||
|
// from container log output. Newlines (\n), carriage returns (\r), and tabs (\t)
|
||||||
|
// are preserved. This ensures that attacker-controlled container output cannot
|
||||||
|
// inject terminal escape sequences or other dangerous control characters.
|
||||||
|
func SanitizeLogs(input string) string {
|
||||||
|
// Strip ANSI escape sequences
|
||||||
|
result := ansiEscapePattern.ReplaceAllString(input, "")
|
||||||
|
|
||||||
|
// Strip remaining non-printable characters (keep \n, \r, \t)
|
||||||
|
var b strings.Builder
|
||||||
|
b.Grow(len(result))
|
||||||
|
|
||||||
|
for _, r := range result {
|
||||||
|
if r == '\n' || r == '\r' || r == '\t' || r >= ' ' {
|
||||||
|
b.WriteRune(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
84
internal/handlers/sanitize_test.go
Normal file
84
internal/handlers/sanitize_test.go
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package handlers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.eeqj.de/sneak/upaas/internal/handlers"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSanitizeLogs(t *testing.T) { //nolint:funlen // table-driven tests
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "plain text unchanged",
|
||||||
|
input: "hello world\n",
|
||||||
|
expected: "hello world\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "strips ANSI color codes",
|
||||||
|
input: "\x1b[31mERROR\x1b[0m: something failed\n",
|
||||||
|
expected: "ERROR: something failed\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "strips OSC sequences",
|
||||||
|
input: "\x1b]0;window title\x07normal text\n",
|
||||||
|
expected: "normal text\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "strips null bytes",
|
||||||
|
input: "hello\x00world\n",
|
||||||
|
expected: "helloworld\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "strips bell characters",
|
||||||
|
input: "alert\x07here\n",
|
||||||
|
expected: "alerthere\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "preserves tabs",
|
||||||
|
input: "field1\tfield2\tfield3\n",
|
||||||
|
expected: "field1\tfield2\tfield3\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "preserves carriage returns",
|
||||||
|
input: "line1\r\nline2\r\n",
|
||||||
|
expected: "line1\r\nline2\r\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "strips mixed escape sequences",
|
||||||
|
input: "\x1b[32m2024-01-01\x1b[0m \x1b[1mINFO\x1b[0m starting\x00\n",
|
||||||
|
expected: "2024-01-01 INFO starting\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty string",
|
||||||
|
input: "",
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "only control characters",
|
||||||
|
input: "\x00\x01\x02\x03",
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "cursor movement sequences stripped",
|
||||||
|
input: "\x1b[2J\x1b[H\x1b[3Atext\n",
|
||||||
|
expected: "text\n",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
got := handlers.SanitizeLogs(tt.input)
|
||||||
|
if got != tt.expected {
|
||||||
|
t.Errorf("SanitizeLogs(%q) = %q, want %q", tt.input, got, tt.expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -726,6 +726,7 @@ func (svc *Service) cleanupCancelledDeploy(
|
|||||||
} else {
|
} else {
|
||||||
svc.log.Info("cleaned up build dir from cancelled deploy",
|
svc.log.Info("cleaned up build dir from cancelled deploy",
|
||||||
"app", app.Name, "path", dirPath)
|
"app", app.Name, "path", dirPath)
|
||||||
|
|
||||||
_ = deployment.AppendLog(ctx, "Cleaned up build directory")
|
_ = deployment.AppendLog(ctx, "Cleaned up build directory")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ func TestCleanupCancelledDeploy_RemovesBuildDir(t *testing.T) {
|
|||||||
require.NoError(t, os.MkdirAll(deployDir, 0o750))
|
require.NoError(t, os.MkdirAll(deployDir, 0o750))
|
||||||
|
|
||||||
// Create a file inside to verify full removal
|
// Create a file inside to verify full removal
|
||||||
require.NoError(t, os.WriteFile(filepath.Join(deployDir, "work"), []byte("test"), 0o640))
|
require.NoError(t, os.WriteFile(filepath.Join(deployDir, "work"), []byte("test"), 0o600))
|
||||||
|
|
||||||
// Also create a dir for a different deployment (should NOT be removed)
|
// Also create a dir for a different deployment (should NOT be removed)
|
||||||
otherDir := filepath.Join(buildDir, "99-xyz789")
|
otherDir := filepath.Join(buildDir, "99-xyz789")
|
||||||
|
|||||||
@ -52,10 +52,10 @@ func NewTestServiceWithConfig(log *slog.Logger, cfg *config.Config, dockerClient
|
|||||||
// cleanupCancelledDeploy for testing. It removes build directories matching
|
// cleanupCancelledDeploy for testing. It removes build directories matching
|
||||||
// the deployment ID prefix.
|
// the deployment ID prefix.
|
||||||
func (svc *Service) CleanupCancelledDeploy(
|
func (svc *Service) CleanupCancelledDeploy(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
appName string,
|
appName string,
|
||||||
deploymentID int64,
|
deploymentID int64,
|
||||||
imageID string,
|
_ string,
|
||||||
) {
|
) {
|
||||||
// We can't create real models.App/Deployment in tests easily,
|
// We can't create real models.App/Deployment in tests easily,
|
||||||
// so we test the build dir cleanup portion directly.
|
// so we test the build dir cleanup portion directly.
|
||||||
|
|||||||
@ -260,7 +260,7 @@ func (svc *Service) sendNtfy(
|
|||||||
request.Header.Set("Title", title)
|
request.Header.Set("Title", title)
|
||||||
request.Header.Set("Priority", svc.ntfyPriority(priority))
|
request.Header.Set("Priority", svc.ntfyPriority(priority))
|
||||||
|
|
||||||
resp, err := svc.client.Do(request)
|
resp, err := svc.client.Do(request) //nolint:gosec // URL constructed from trusted config, not user input
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to send ntfy request: %w", err)
|
return fmt.Errorf("failed to send ntfy request: %w", err)
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ func (svc *Service) sendSlack(
|
|||||||
|
|
||||||
request.Header.Set("Content-Type", "application/json")
|
request.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
resp, err := svc.client.Do(request)
|
resp, err := svc.client.Do(request) //nolint:gosec // URL from trusted webhook config
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to send slack request: %w", err)
|
return fmt.Errorf("failed to send slack request: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
// KeyPair contains an SSH key pair.
|
// KeyPair contains an SSH key pair.
|
||||||
type KeyPair struct {
|
type KeyPair struct {
|
||||||
PrivateKey string
|
PrivateKey string //nolint:gosec // field name describes SSH key material, not a hardcoded secret
|
||||||
PublicKey string
|
PublicKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user