621e8895c9
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.2 KiB
3.2 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wg_peer_revoke | function | go | infra | 1.0.0 | impure | func WGPeerRevoke(deviceID, operator, reason string, configPath, auditDBPath string) (WGPeerRevokeAudit, error) | Kill switch: revoca peer permanentemente. Anade a blacklist + audit log hash-chained inviolable (SHA256 chain). Para dispositivos perdidos/comprometidos. |
|
|
false | error_go_core |
|
WGPeerRevokeAudit con DeviceID, PublicKey, RevokedAt (unix), RevokedBy, Reason, PrevHash y ThisHash. ThisHash = SHA256(PrevHash|DeviceID|PublicKey|RevokedAt|Operator|Reason). | true |
|
functions/infra/wg_peer_revoke_test.go | functions/infra/wg_peer_revoke.go |
Ejemplo
audit, err := infra.WGPeerRevoke(
"device-laptop-alice",
"operator-bob",
"dispositivo perdido en viaje",
"/etc/wireguard/wg0.conf",
"/var/lib/wg-hub/revoked.db",
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("revoked: device=%s pubkey=%s hash=%s\n",
audit.DeviceID, audit.PublicKey, audit.ThisHash)
Cuando usarla
Cuando un dispositivo esta perdido, robado o comprometido y NO debe poder volver a conectarse nunca. Deja registro inmutable en audit DB con hash chain SHA256 y escribe la PublicKey en /etc/wireguard/wg_revoked.list. Para baja temporal (rotar claves, reconfigurar) usa wg_peer_remove_go_infra.
Gotchas
- Reason obligatorio: reason vacio devuelve error antes de tocar nada.
- Idempotencia: revocar el mismo deviceID dos veces devuelve
already revoked. La comprobacion es sobre la audit DB, no sobre el config. - Audit DB borrada: si auditDBPath se borra, la chain se reinicia desde genesis (prev_hash vacio). El break de integridad es visible (primer registro sin prev_hash). El sistema lo acepta pero queda evidencia del gap.
- Blacklist
/etc/wireguard/wg_revoked.list: requiere permisos de escritura en/etc/wireguard/. Si falla, el audit DB ya tiene el registro (no se revierte) pero la funcion devuelve error indicando el gap. - Reason no debe contener PII: se guarda en texto plano en SQLite y en la blacklist. Usar referencias internas en vez de nombres reales.
- syncconf: hereda el requisito de privilegios de WGPeerRemove. Ver gotchas de
wg_peer_remove_go_infra.