knotserver: filter by known dids in processPublicKey #478

closed
opened by anirudh.fi targeting master from push-wzlvlnywrxrs
Changed files
+17 -4
knotserver
+17 -4
knotserver/ingester.go
···
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,
···
// 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)
···
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)