Skip to content

Pointers to mutable containers escape the package boundary #533

Open

Description

@David-Noble-at-work

Two accessors hand out a pointer to a container the caller can then mutate wholesale — a different leak
from slice aliasing, because the container's own API is the attack surface:

func (g *Graph) ResourceCatalog() *ResourceCatalog { return g.resourceCatalog }  // graph.go:598
func (g *Graph) Signature() *Signature             { return g.signature }        // graph.go:616

ResourceCatalog is mutable by design — the executor interns into one during a run. The graph's copy
is supposed to stay pristine, and the doc comment says GraphExecutor.Run Clones it "so the graph's
planning catalog stays pristine across plan-once-run-many reuse."
That is one caller's discipline, not a
property of the type
: any other holder can intern straight into the graph's catalog.

Signature returns a pointer to a mutable struct, so a caller can rewrite the publisher signature in
place on a graph they merely read.

Fix: return a reader view or a copy. Signature is cheap — return the value. ResourceCatalog is the
judgment call: a read-only interface, or clone-on-access with the cost measured, since the executor clones
it every run anyway.

Exit: neither accessor exposes a mutable path into the graph; the Run-clones-it comment becomes a
statement about behavior rather than a warning the caller must heed.

Activity

  1. David-Noble-at-work commented on Nov 9, 2026

    @David-Noble-at-work
    ContributorAuthor

    star github triage sweep added this issue to Triage: devlore, for the rule it breaks:

    • no-evidence: no Evidence of completion section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions