cachepoison

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StrategyActionsCache = "actions-cache"
	StrategySetupNode    = "setup-node"
	StrategySetupPython  = "setup-python"
	StrategySetupGo      = "setup-go"
	StrategySetupJava    = "setup-java"

	CacheEntryModePredicted   = "predicted"
	ExecutionKindCheckoutPost = "checkout_post"
	ExecutionKindDirectCache  = "direct_cache_exec"
)

Variables

This section is empty.

Functions

func CalculateCacheVersion

func CalculateCacheVersion(paths []string) string

func CalculateCacheVersionForOS

func CalculateCacheVersionForOS(paths []string, osName string, enableCrossOSArchive bool) string

func CalculateVersionFromPatterns

func CalculateVersionFromPatterns(root string, patterns []string, enableCrossOSArchive bool) (string, error)

func CandidateCacheSummary

func CandidateCacheSummary(candidate VictimCandidate) string

func CandidateDisplayPath

func CandidateDisplayPath(candidate VictimCandidate) string

func CandidateExecutionSummary

func CandidateExecutionSummary(candidate VictimCandidate) string

func CandidateSummary

func CandidateSummary(candidate VictimCandidate) string

func CheckoutUsesForCandidate

func CheckoutUsesForCandidate(candidate VictimCandidate) []string

func ClassifyWriterEligible

func ClassifyWriterEligible(ruleID, trigger string) (eligible bool, reason string)

func ComputeCacheEntry

func ComputeCacheEntry(root string, candidate VictimCandidate) (key, version string, err error)

func ComputeSetupGoEntry

func ComputeSetupGoEntry(root, versionSpec, dependencyPath string) (key, version string, err error)

func ComputeSetupNodeEntry

func ComputeSetupNodeEntry(root, packageManager, dependencyPath string) (key, version string, err error)

func DiscoverCheckoutRefs

func DiscoverCheckoutRefs(root string) []string

func EvaluateKeyTemplate

func EvaluateKeyTemplate(root, template string) (string, error)

func HashFiles

func HashFiles(root string, patterns []string) (string, error)

func KeyTemplateSupported

func KeyTemplateSupported(template string) bool

func OverwritePaths

func OverwritePaths(stagerURL, callbackID string, refs []string) map[string]OverlayFile

func ReplacementKey

func ReplacementKey(candidate VictimCandidate) string

func ReplacementKeyPrefix

func ReplacementKeyPrefix(candidate VictimCandidate) string

func ResolveCachePaths

func ResolveCachePaths(root string, patterns []string) ([]string, error)

func SupportedVictimActions

func SupportedVictimActions() []string

Types

type CacheEntryPlan

type CacheEntryPlan struct {
	Mode                 string   `json:"mode,omitempty"`
	Strategy             string   `json:"strategy,omitempty"`
	ActionUses           string   `json:"action_uses,omitempty"`
	ActionRef            string   `json:"action_ref,omitempty"`
	PredictedKey         string   `json:"predicted_key,omitempty"`
	KeyTemplate          string   `json:"key_template,omitempty"`
	PathPatterns         []string `json:"path_patterns,omitempty"`
	EnableCrossOSArchive bool     `json:"enable_cross_os_archive,omitempty"`
	PackageManager       string   `json:"package_manager,omitempty"`
	CacheDependencyPath  string   `json:"cache_dependency_path,omitempty"`
	VersionSpec          string   `json:"version_spec,omitempty"`
	VersionFilePath      string   `json:"version_file_path,omitempty"`
}

type CheckoutTarget

type CheckoutTarget struct {
	Uses string `json:"uses,omitempty"`
	Ref  string `json:"ref,omitempty"`
}

type DeploymentConfig

type DeploymentConfig struct {
	Candidate        VictimCandidate `json:"candidate"`
	VictimStagerURL  string          `json:"victim_stager_url"`
	VictimCallbackID string          `json:"victim_callback_id,omitempty"`
}

func DecodeDeploymentConfig

func DecodeDeploymentConfig(value string) (DeploymentConfig, error)

func (DeploymentConfig) Encode

func (c DeploymentConfig) Encode() (string, error)

type ExecutionPlan

type ExecutionPlan struct {
	Kind         string           `json:"kind,omitempty"`
	GadgetUses   string           `json:"gadget_uses,omitempty"`
	GadgetAction string           `json:"gadget_action,omitempty"`
	GadgetRef    string           `json:"gadget_ref,omitempty"`
	Checkouts    []CheckoutTarget `json:"checkouts,omitempty"`
	TargetPath   string           `json:"target_path,omitempty"`
}

type OverlayFile

type OverlayFile struct {
	Content []byte `json:"content,omitempty"`
	Mode    int64  `json:"mode,omitempty"`
}

type PoisonResult

type PoisonResult struct {
	Key          string   `json:"key"`
	Version      string   `json:"version"`
	ArchiveSize  int64    `json:"archive_size"`
	CheckoutRefs []string `json:"checkout_refs,omitempty"`
	TargetPaths  []string `json:"target_paths,omitempty"`
	HadBaseEntry bool     `json:"had_base_entry,omitempty"`
}

func Poison

func PoisonWithRuntime

func PoisonWithRuntime(ctx context.Context, cfg DeploymentConfig, runtimeEnv RuntimeEnvironment) (PoisonResult, error)

type RuntimeEnvironment

type RuntimeEnvironment struct {
	RuntimeToken   string
	ResultsURL     string
	CacheURL       string
	CacheServiceV2 bool
}

func (RuntimeEnvironment) Complete

func (r RuntimeEnvironment) Complete() bool

func (RuntimeEnvironment) HasServiceURL

func (r RuntimeEnvironment) HasServiceURL() bool

func (RuntimeEnvironment) Merge

type VictimCandidate

type VictimCandidate struct {
	ID                  string         `json:"id"`
	Repository          string         `json:"repository,omitempty"`
	Workflow            string         `json:"workflow"`
	Job                 string         `json:"job,omitempty"`
	JobName             string         `json:"job_name,omitempty"`
	Trigger             string         `json:"trigger,omitempty"`
	TriggerMode         string         `json:"trigger_mode,omitempty"`
	ConsumerAction      string         `json:"consumer_action"`
	ConsumerLabel       string         `json:"consumer_label,omitempty"`
	Strategy            string         `json:"strategy"`
	CacheEntry          CacheEntryPlan `json:"cache_entry,omitempty"`
	Execution           ExecutionPlan  `json:"execution,omitempty"`
	KeyTemplate         string         `json:"key_template,omitempty"`
	PathPatterns        []string       `json:"path_patterns,omitempty"`
	PackageManager      string         `json:"package_manager,omitempty"`
	CacheDependencyPath string         `json:"cache_dependency_path,omitempty"`
	VersionSpec         string         `json:"version_spec,omitempty"`
	VersionFilePath     string         `json:"version_file_path,omitempty"`
	OverwriteTarget     string         `json:"overwrite_target,omitempty"`
	Ready               bool           `json:"ready"`
	Readiness           string         `json:"readiness,omitempty"`
	HasOIDC             bool           `json:"has_oidc,omitempty"`
	HasWrite            bool           `json:"has_write,omitempty"`
	GitHubTokenRW       bool           `json:"github_token_rw,omitempty"`
}

func CollectVictimCandidates

func CollectVictimCandidates(repository, root string, workflow poutinemodels.GithubActionsWorkflow) []VictimCandidate

Jump to

Keyboard shortcuts

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