build(android): upgrade toolchain and migrate Room to KSP
Lint / Lint (push) Successful in 1m29s
Security / Secrets (gitleaks) (push) Successful in 1m11s
Security / Dependencies (Trivy) (push) Successful in 1m59s
Tests / Dashboard checks (push) Successful in 1m49s
Security / Code (Semgrep) (push) Successful in 3m8s
Tests / Go backend (push) Successful in 2m50s
Docker / Docker Build & Push (push) Successful in 8m42s

- Target API 37 and use build-tools 37 for release signature checks
- Adjust list pagination spacing and clarify shared backend docs
This commit is contained in:
Gabriel20xx committed 2026-11-01 21:48:05 +01:00
1 parent 7150ebd13e
commit 0fd1805502
40 files changed
+912 -690

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
package files
import (
"errors"
"os"
"path/filepath"
"testing"
)
func TestSafeRelativeRejectsTraversalAndAbsolutePaths(t *testing.T) {
for _, value := range []string{"", ".", "..", "../x", "a/../../x", "sub/../a.mp4x", "/etc/passwd", `\etc\passwd`, `C:\x`, "a\x00b"} {
if SafeRelative(value) {
t.Errorf("SafeRelative(%q) = true, want false", value)
}
}
for _, value := range []string{"a.mp4", "sub/b.mp4", "v1..2/clip.mp4"} {
if !SafeRelative(value) {
t.Errorf("SafeRelative(%q) = false, want true", value)
}
}
}
func TestResolveUnderRootsStaysInsideTheRoots(t *testing.T) {
root := t.TempDir()
if err := os.MkdirAll(filepath.Join(root, "sub"), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(root, "a.mp4"), []byte("a"), 0o600); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(root, "sub", "b.mp4"), []byte("b"), 0o600); err != nil {
t.Fatal(err)
}
outside := filepath.Join(t.TempDir(), "secret.txt")
if err := os.WriteFile(outside, []byte("s"), 0o600); err != nil {
t.Fatal(err)
}
_ = os.Symlink(outside, filepath.Join(root, "link.txt"))
for value, want := range map[string]string{
"a.mp4": filepath.Join(root, "a.mp4"),
"/media/a.mp4": filepath.Join(root, "a.mp4"),
"sub/b.mp4": filepath.Join(root, "sub", "b.mp4"),
"/media/sub/b.mp4": filepath.Join(root, "sub", "b.mp4"),
} {
got, err := ResolveUnderRoots(value, []string{root})
if err != nil || got != want {
t.Errorf("ResolveUnderRoots(%q) = %q, %v; want %q", value, got, err, want)
}
}
for _, value := range []string{"../secret.txt", "sub", "missing.mp4", "link.txt", "", "a\x00b"} {
if _, err := ResolveUnderRoots(value, []string{root}); err == nil {
t.Errorf("ResolveUnderRoots(%q) resolved, want an error", value)
}
}
if _, err := ResolveUnderRoots("missing.mp4", []string{root}); !errors.Is(err, os.ErrNotExist) {
t.Errorf("missing file error = %v, want os.ErrNotExist", err)
}
}