Files
zooqueenandHanzo Dev 06e267f0ca DigitalOcean, the direct mode and every stored provider key are gone: compute never has or stores a naked key (red round 3, H2).
Every cloud whose SDK would authenticate from a key held in this process is removed: Aliyun, Azure, GCP, VMware, KVM, PVE, Lightsail, direct AWS and DigitalOcean with its Kubernetes clusters and node pools, volumes, VPCs and load balancers, the BYOC cost readers and their fee, and the chain providers that committed records with a stored key. What remains, Hetzner and hosted EC2, is reached only through egress; with no carrier every cloud call refuses. A provider row names accounts by their egress label and holds no key: the ClientId, ClientSecret and key-secret fields are gone, a write carrying one is refused, and each database drops the old columns, rewrites rotation keys without their secrets and vacuums when its engine opens. The routes of the removed features are dropped with no successor.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-24 11:29:41 -07:00

77 lines
2.5 KiB
Go

// Copyright 2026 Hanzo Industries Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package object
import (
"fmt"
"github.com/hanzoai/orm/relational"
"github.com/hanzoai/orm/relational/schemas"
)
// keyColumns are the provider columns that held a cloud key: the account's key
// id and its secret. Provider has neither field; forgetProviderKeys drops the
// columns wherever an older schema left them.
var keyColumns = []string{"client_secret", "client_id"}
// forgetProviderKeys removes every cloud key an engine's provider table holds:
// it drops the key columns, rewrites each row's rotation keys through a
// ProviderKey that has no secret, and — on SQLite — vacuums, so the dropped
// values are gone from the file and not left in its free pages. It runs each
// time an engine is opened, and does nothing once the table is clean.
func forgetProviderKeys(engine *relational.Engine) error {
table := engine.TableName(&Provider{})
metas, err := engine.DBMetas()
if err != nil {
return fmt.Errorf("visor: read the %s schema: %w", table, err)
}
var dropped bool
for _, t := range metas {
if t.Name != table {
continue
}
for _, col := range keyColumns {
if t.GetColumn(col) == nil {
continue
}
if _, err := engine.Exec(fmt.Sprintf("ALTER TABLE %s DROP COLUMN %s", engine.Quote(table), engine.Quote(col))); err != nil {
return fmt.Errorf("visor: drop %s.%s: %w", table, col, err)
}
dropped = true
}
}
var rows []*Provider
if err := engine.Find(&rows); err != nil {
return fmt.Errorf("visor: read %s: %w", table, err)
}
for _, p := range rows {
if len(p.Keys) == 0 {
continue
}
if _, err := engine.ID(schemas.PK{p.Owner, p.Name}).Cols("keys").Update(p); err != nil {
return fmt.Errorf("visor: rewrite the keys of %s/%s: %w", p.Owner, p.Name, err)
}
dropped = true
}
if dropped && engine.DriverName() == "sqlite" {
if _, err := engine.Exec("VACUUM"); err != nil {
return fmt.Errorf("visor: vacuum after dropping keys: %w", err)
}
}
return nil
}