carlos / platform Public

route53zones: Host keeps no keys and never formats them (review M1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 77170b5df4a8257067d44f7dd9b1b4f65ff23c74 parent 1e22481
2 files changed, +25 −0
  • internal/zonehost/route53zones/route53.go +6 −0
  • internal/zonehost/route53zones/route53_test.go +19 −0

CI failed — run details

diff --git a/internal/zonehost/route53zones/route53.go b/internal/zonehost/route53zones/route53.go
index a7e672da6..941d7ee60 100644
--- a/internal/zonehost/route53zones/route53.go
+++ b/internal/zonehost/route53zones/route53.go
@@ -33,6 +33,9 @@ type Host struct {
config Config
}
+func (h *Host) String() string { return "route53zones.Host" }
+func (h *Host) GoString() string { return h.String() }
+
var _ zonehost.Host = (*Host)(nil)
type route53API interface {
@@ -98,6 +101,9 @@ func New(ctx context.Context, c Config) (*Host, error) {
return nil, fmt.Errorf("route53zones: load AWS config: %w", err)
}
client := route53.NewFromConfig(cfg)
+ // The client holds the keys now; the stored config keeps none, so no
+ // formatting of a Host can print them.
+ c.AccessKeyID, c.SecretAccessKey = "", ""
return &Host{config: c, client: route53Methods{create: client.CreateHostedZone, listZones: client.ListHostedZones, delete: client.DeleteHostedZone, listRecords: client.ListResourceRecordSets, change: client.ChangeResourceRecordSets}}, nil
}
func (h *Host) Nameservers() []string {
diff --git a/internal/zonehost/route53zones/route53_test.go b/internal/zonehost/route53zones/route53_test.go
index 9f17b6f73..4b92fbc4d 100644
--- a/internal/zonehost/route53zones/route53_test.go
+++ b/internal/zonehost/route53zones/route53_test.go
@@ -570,3 +570,22 @@ func TestNewUsesStaticCredentialsForZonesAndSteering(t *testing.T) {
t.Fatalf("steering path: %q", got)
}
}
+
+func TestHostFormattingNeverPrintsKeys(t *testing.T) {
+ h, err := New(context.Background(), Config{
+ DelegationSetID: "NSET", Nameservers: []string{"ns1.example.net", "ns2.example.net", "ns3.example.net", "ns4.example.net"},
+ AccessKeyID: "AKIAEXAMPLEKEYID", SecretAccessKey: "very-secret-value",
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, f := range []string{"%v", "%+v", "%#v", "%s"} {
+ out := fmt.Sprintf(f, h)
+ if strings.Contains(out, "very-secret-value") || strings.Contains(out, "AKIAEXAMPLEKEYID") {
+ t.Fatalf("%s printed a key: %q", f, out)
+ }
+ }
+ if h.config.SecretAccessKey != "" || h.config.AccessKeyID != "" {
+ t.Fatal("Host kept the keys after building its client")
+ }
+}