Documentation
¶
Overview ¶
Package sourcerepo gates which source repositories the source_diff investigation tool may clone. The allowlist match is the security boundary: the model names a repo, but only operator-listed patterns ever reach the network — no SSRF / arbitrary-clone, regardless of what the model writes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allowlist ¶
type Allowlist struct {
// contains filtered or unexported fields
}
Allowlist holds the operator's source-repo allow patterns, pre-validated. Patterns are host/org/repo shaped and matched with path.Match, so '*' never crosses a '/': "github.com/acme/*" allows every repo directly under acme but not "github.com/acme/x/y". A local filesystem pattern (leading '/') is supported for tests/dev and matched the same way.
func New ¶
New validates and compiles allow patterns. Rejected at load time (config validation calls this): an empty list, an empty pattern, a scheme, "..", whitespace, or a glob path.Match itself rejects. Patterns are stored with the host segment lowercased (DNS names are case-insensitive).
func (*Allowlist) Match ¶
Match normalizes a model-supplied repo reference and reports whether it is allowed, returning the canonical clone URL. It accepts the shapes a model plausibly emits — "github.com/acme/x", "https://github.com/acme/x.git", "git@github.com:acme/x.git", "ssh://git@github.com/acme/x" — all reduced to host/org/repo BEFORE matching, so a scheme or userinfo can never smuggle a non-allowed host past the gate. The returned clone URL is built from the NORMALIZED form ("https://" + host/org/repo, or the path itself for a local pattern), never from the raw input.