From 784ac6ebadcb45b4e0fcd625501556c8ec30d5fc Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Tue, 12 Aug 2025 21:59:44 +0300 Subject: [PATCH] knotserver: filter by known dids in processPublicKey Change-Id: wzlvlnywrxrsovvktzzqmtowkvkrmkzp Must've been removed by accident. Switch to debug logging for record rejection messages. Signed-off-by: Anirudh Oppiliappan --- knotserver/ingester.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/knotserver/ingester.go b/knotserver/ingester.go index 1f1cc218..88190170 100644 --- a/knotserver/ingester.go +++ b/knotserver/ingester.go @@ -27,6 +27,19 @@ import ( func (h *Handle) processPublicKey(ctx context.Context, did string, record tangled.PublicKey) error { l := log.FromContext(ctx) + + allDids, err := h.db.GetAllDids() + if err != nil { + return err + } + + // only process public keys from known DIDs + if !slices.Contains(allDids, did) { + reason := "not a known did" + l.Debug("rejecting public key record", "reason", reason, "did", did) + return nil + } + pk := db.PublicKey{ Did: did, PublicKey: record, @@ -99,8 +112,8 @@ func (h *Handle) processPull(ctx context.Context, did string, record tangled.Rep // presently: we only process PRs from collaborators for pipelines if !slices.Contains(allDids, did) { reason := "not a known did" - l.Info("rejecting pull record", "reason", reason) - return fmt.Errorf("rejected pull record: %s, %s", reason, did) + l.Debug("rejecting pull record", "reason", reason) + return nil } repoAt, err := syntax.ParseATURI(record.TargetRepo) @@ -128,8 +141,8 @@ func (h *Handle) processPull(ctx context.Context, did string, record tangled.Rep if repo.Knot != h.c.Server.Hostname { reason := "not this knot" - l.Info("rejecting pull record", "reason", reason) - return fmt.Errorf("rejected pull record: %s", reason) + l.Debug("rejecting pull record", "reason", reason) + return nil } didSlashRepo, err := securejoin.SecureJoin(repo.Owner, repo.Name) -- 2.43.0