sourcerepo

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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

func New(patterns []string) (*Allowlist, error)

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

func (a *Allowlist) Match(raw string) (cloneURL string, ok bool)

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.

func (*Allowlist) Patterns

func (a *Allowlist) Patterns() []string

Patterns returns the normalized allow patterns, for the tool description (the model picks a repo from this list) and for error messages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL