Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing (ignore) #392

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,6 @@ jobs:
- name: Unit tests
run: make check-unit

system-tests:
env:
DEBUG: "1"
SKIP_VM_LAUNCH: "1"
SNAPSHOT_RESTORE: "1"
name: System
runs-on: GitHubMicrocloud
strategy:
fail-fast: false
matrix:
go: ["1.22.x"]
suite:
- "add"
- "instances"
- "basic"
- "recover"
- "interactive"
- "mismatch"
- "preseed"

steps:
- name: Performance tuning
Expand Down
22 changes: 22 additions & 0 deletions api/services_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"

"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/rest"
Expand All @@ -26,6 +29,19 @@ var ServiceTokensCmd = func(sh *service.Handler) rest.Endpoint {
}
}

func IsSafeVarPath(path string) error {
if strings.Contains(path, "/") || strings.Contains(path, "\\") || strings.Contains(path, "..") {
return fmt.Errorf("test err")
}

_, err := filepath.Abs(path)
if err != nil {
return err
}

return nil
}

// serviceTokensPost issues a token for service using the MicroCloud proxy.
// Normally a token request to a service would be restricted to trusted systems,
// so this endpoint validates the mDNS auth token and then proxies the request to the local unix socket of the remote system.
Expand All @@ -43,6 +59,12 @@ func serviceTokensPost(s *state.State, r *http.Request) response.Response {
return response.BadRequest(err)
}

if strings.Contains(req.JoinerName, "/") || strings.Contains(req.JoinerName, "\\") || strings.Contains(req.JoinerName, "..") {
return response.SmartError(fmt.Errorf("test"))
}

_ = os.MkdirAll(req.JoinerName, 0700)
Fixed Show fixed Hide fixed

sh, err := service.NewHandler(s.Name(), req.ClusterAddress, s.OS.StateDir, false, false, types.ServiceType(serviceType))
if err != nil {
return response.SmartError(err)
Expand Down
Loading