oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package release
2
3import (
4 "crypto/sha256"
5 "fmt"
6 "os"
7 "path/filepath"
8 "testing"
9)
10
11func TestGitleaksDigestGuard(t *testing.T) {
12 p := filepath.Join(t.TempDir(), "gitleaks")
13 raw := []byte("trusted executable")
14 if err := os.WriteFile(p, raw, 0700); err != nil {
15 t.Fatal(err)
16 }
17 pin := fmt.Sprintf("%x", sha256.Sum256(raw))
18 if !VerifyGitleaks(p, pin) {
19 t.Fatal("verified binary refused")
20 }
21 if VerifyGitleaks(p, "") {
22 t.Fatal("unrecorded binary accepted")
23 }
24 if err := os.WriteFile(p, []byte("replaced"), 0700); err != nil {
25 t.Fatal(err)
26 }
27 if VerifyGitleaks(p, pin) {
28 t.Fatal("changed binary accepted")
29 }
30 link := filepath.Join(t.TempDir(), "scanner")
31 if err := os.Symlink(p, link); err != nil {
32 t.Fatal(err)
33 }
34 if VerifyGitleaks(link, fmt.Sprintf("%x", sha256.Sum256([]byte("replaced")))) {
35 t.Fatal("symlink scanner accepted")
36 }
37}
38