Files
ghaymah_dev2 ea900387de
ci / test (push) Canceled after 0s
ci / cross-build (amd64, darwin) (push) Canceled after 0s
ci / cross-build (amd64, linux) (push) Canceled after 0s
ci / cross-build (amd64, windows) (push) Canceled after 0s
ci / cross-build (arm64, darwin) (push) Canceled after 0s
ci / cross-build (arm64, linux) (push) Canceled after 0s
ci / cross-build (arm64, windows) (push) Canceled after 0s
Security hardening: dockerignore engine, upload limits, client-side encryption, cross-platform builds
- archive: use Docker's own patternmatcher for .dockerignore/.gitignore/.gyignore + hard secret/VCS/build-output exclusions
- crypto: AES-256-CTR encrypt the source archive before upload (key/IV to gateway via HTTPS)
- deploy: --max-upload / GY_MAX_UPLOAD (default 500 MB)
- Makefile + CI matrix: cross-compile linux/darwin/windows x amd64/arm64
- tests: crypto round-trip + ignore rules
2026-10-24 10:02:34 -04:00

57 lines
1.5 KiB
Go

package source
import (
"os"
"path/filepath"
"testing"
)
func TestAlwaysExcluded(t *testing.T) {
// alwaysExcluded matches on basename — the walk prunes directories before
// their children are visited, so this is exactly what it sees.
excluded := []string{
".git", ".gy", ".hg", ".svn",
".env", ".env.local", ".env.production",
"node_modules", "target", "dist", "build", "out",
"foo.log", "app.log.1", "server.key", "cert.pem", "id_rsa", "id_rsa.pub", "store.p12",
}
for _, p := range excluded {
if !alwaysExcluded(p) {
t.Errorf("expected %q to be always excluded", p)
}
}
kept := []string{"src", "main.go", "package.json", "README.md", "app.py", "config.toml", "Dockerfile"}
for _, p := range kept {
if alwaysExcluded(p) {
t.Errorf("expected %q NOT to be excluded", p)
}
}
}
func TestDockerignore(t *testing.T) {
dir := t.TempDir()
// Docker semantics: "coverage/" prunes the dir, "*.tmp" matches root-level
// files only, "**/*.secret" matches at any depth.
patterns := "coverage/\n*.tmp\n**/*.secret\n"
if err := os.WriteFile(filepath.Join(dir, ".dockerignore"), []byte(patterns), 0o644); err != nil {
t.Fatal(err)
}
ig, err := newIgnore(dir)
if err != nil {
t.Fatal(err)
}
for _, p := range []string{"coverage/lcov.info", "scratch.tmp", "src/x.secret"} {
if !ig.ignored(p, false) {
t.Errorf("expected %q to be ignored by .dockerignore", p)
}
}
for _, p := range []string{"src/main.go", "package.json", "README.md"} {
if ig.ignored(p, false) {
t.Errorf("expected %q NOT to be ignored", p)
}
}
}