oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package provider
2
3import (
4 "crypto/sha256"
5 "encoding/hex"
6 "path/filepath"
7 "strings"
8)
9
10// IsolationTarget describes a synthetic marker verified on the host. It never
11// carries marker bytes or a credential-file digest.
12type IsolationTarget struct {
13 Name string `json:"name"`
14 HostPath string `json:"host_path"`
15 Path string `json:"path"`
16 SHA256 string `json:"sha256"`
17}
18
19type IsolationResult struct {
20 Status string `json:"status,omitempty"`
21 Name string `json:"name"`
22 Operations map[string]string `json:"operations"`
23 Safe bool `json:"safe"`
24}
25
26type IsolationReport struct {
27 ProbeNamespaceManifest string `json:"probe_namespace_manifest"`
28 Layer string `json:"layer"`
29 PolicyHash string `json:"policy_hash"`
30 NamespaceManifest string `json:"namespace_manifest"`
31 UID int `json:"uid"`
32 Targets []IsolationResult `json:"targets"`
33 SideDoors map[string]string `json:"side_doors"`
34 Safe bool `json:"safe"`
35}
36
37// ProviderHomeTarget names the staged marker and its fixed aliases, never a source home.
38func ProviderHomeTarget(name, path string) bool {
39 marker := filepath.Base(path)
40 random, err := hex.DecodeString(strings.TrimPrefix(marker, "equipo-read-"))
41 if err != nil || len(random) != 16 || marker != "equipo-read-"+hex.EncodeToString(random) {
42 return false
43 }
44 return map[string]string{
45 "selected-home": "/home/runner/" + marker,
46 "proc-root": "/proc/1/root/home/runner/" + marker,
47 "self-root": "/proc/self/root/home/runner/" + marker,
48 "symlink": "/workspace/equipo-direct-sentinel-alias/" + marker,
49 }[name] == path
50}
51
52// ManifestDigest is the lower-case hex SHA-256 the runner records for a
53// policy manifest, a namespace manifest or a probe marker.
54func ManifestDigest(raw []byte) string {
55 s := sha256.Sum256(raw)
56 return hex.EncodeToString(s[:])
57}
58