lockdown

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStats added in v0.22.0

type CacheStats struct {
	Hits      int64
	Misses    int64
	Evictions int64
}

CacheStats summarizes cache activity counters.

type RepoAccessCache added in v0.22.0

type RepoAccessCache struct {
	// contains filtered or unexported fields
}

RepoAccessCache caches repository metadata related to lockdown checks so that multiple tools can reuse the same access information safely across goroutines. In HTTP mode each request must construct its own instance so viewer-scoped lookups run under the requesting user's credentials.

func NewRepoAccessCache added in v1.0.3

func NewRepoAccessCache(client *githubv4.Client, restClient *github.Client, opts ...RepoAccessOption) *RepoAccessCache

NewRepoAccessCache creates a RepoAccessCache bound to the supplied clients.

func (*RepoAccessCache) IsSafeContent added in v0.22.0

func (c *RepoAccessCache) IsSafeContent(ctx context.Context, username, owner, repo string) (bool, error)

IsSafeContent determines if the specified user can safely access the requested repository content. Safe access applies when any of the following is true: - the content was created by a trusted bot; - the author currently has push access to the repository; - the repository is private; - the content was created by the viewer.

type RepoAccessInfo added in v0.22.0

type RepoAccessInfo struct {
	IsPrivate     bool
	HasPushAccess bool
}

RepoAccessInfo captures repository metadata needed for lockdown decisions.

type RepoAccessOption added in v0.22.0

type RepoAccessOption func(*RepoAccessCache)

RepoAccessOption configures RepoAccessCache at construction time.

func WithCacheName added in v0.22.0

func WithCacheName(name string) RepoAccessOption

WithCacheName overrides the cache table name used for storing entries. Use this to isolate cache entries between tenants or in tests.

cache2go never reclaims a named table, so names must come from a bounded, known set; never derive one from request data. Use WithIdentity instead to isolate per request identity.

func WithIdentity added in v1.10.0

func WithIdentity(identity string) RepoAccessOption

WithIdentity scopes cache entries to a single request identity, typically an auth token, so a decision computed under one caller's credentials is never served to another. Equal identities share a warm cache; an empty one is a no-op.

Scoping lives in the entry key rather than the table so per-identity state stays bounded and is reclaimed by ordinary idle-TTL cleanup. The identity is hashed so it never appears verbatim in a key.

func WithLogger added in v0.22.0

func WithLogger(logger *slog.Logger) RepoAccessOption

WithLogger sets the logger used for cache diagnostics.

func WithTTL added in v0.22.0

func WithTTL(ttl time.Duration) RepoAccessOption

WithTTL overrides the default TTL applied to cache entries. A non-positive duration disables expiration.

Jump to

Keyboard shortcuts

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