Help us shape the future of Go! Take the 2026 Go Developer Survey

reposelector

package
v0.4.37 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package reposelector is the single source of truth for validating GitHub owner and repository selectors used by security-relevant call sites (guard policies, enclave policies, and delegated identities).

Two grammars are defined, and they differ only in the owner segment:

  • The canonical grammar (IsCanonicalOwner, IsCanonicalRepositorySelector) matches github/gh-aw-firewall ADR 0001 ("Agent enclave repository admission") exactly: an owner is 1-39 characters of lowercase alphanumerics and hyphens, starting with an alphanumeric.
  • The legacy grammar (IsLegacyOwner, IsLegacyRepositorySelector) additionally permits '_' in the owner segment for backward compatibility with previously accepted guard-policy and enclave-policy inputs. New call sites should prefer the canonical grammar.

Both grammars share the same repository-name rule (IsCanonicalRepoName): 1-100 characters of lowercase alphanumerics, '.', '_', and '-', excluding the traversal-like names "." and ".." and any name containing "..".

None of these functions trim, case fold, Unicode-normalize, or URL-decode their input. Static allow-only and write-sink policy ingestion may trim and ASCII-lowercase scopes before validation and matching. Other callers, especially those validating dynamic or delegated selectors, must reject invalid input rather than normalize it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCanonicalOwner

func IsCanonicalOwner(owner string) bool

IsCanonicalOwner reports whether owner is the exact canonical ASCII byte sequence required for a repository owner: ^[a-z0-9](?:[a-z0-9-]{0,38})$.

func IsCanonicalRepoName

func IsCanonicalRepoName(name string) bool

IsCanonicalRepoName reports whether name is a valid repository-name segment: ^(?!\.\.?$)(?!.*\.\.)[a-z0-9._-]{1,100}$.

func IsCanonicalRepositorySelector

func IsCanonicalRepositorySelector(selector string) bool

IsCanonicalRepositorySelector reports whether selector is an exact canonical "owner/repo" selector, combining IsCanonicalOwner and IsCanonicalRepoName.

func IsLegacyOwner

func IsLegacyOwner(owner string) bool

IsLegacyOwner reports whether owner matches the canonical owner grammar extended to allow '_', which some historically accepted policy inputs use.

func IsLegacyRepositorySelector

func IsLegacyRepositorySelector(selector string) bool

IsLegacyRepositorySelector reports whether selector is an "owner/repo" selector whose owner matches the legacy grammar (canonical plus '_') and whose repository name matches IsCanonicalRepoName.

func IsTraversalRepoName

func IsTraversalRepoName(name string) bool

IsTraversalRepoName reports whether name is one of the traversal-like repository names IsCanonicalRepoName rejects: "." or any name containing "..", which also covers "..".

Types

This section is empty.

Jump to

Keyboard shortcuts

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