paths

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Copyright 2025 Chainguard, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdvertiseCachedFile added in v0.25.2

func AdvertiseCachedFile(src, dst string) error

AdvertisedCachedFile will create a symlink at `dst` pointing to `src`.

In the case that `dst` already exists, another process had already created the symlink and we can safely move on. We will also perform a best-effort attempt to clean up the unadvertised file at `src`.

func ReplaceCachedFile added in v1.4.3

func ReplaceCachedFile(src, dst string) error

ReplaceCachedFile points `dst` at `src`, replacing whatever was there.

It differs from AdvertiseCachedFile in who wins a collision. AdvertiseCachedFile defers to an existing entry, on the assumption that another process advertised equivalent content first. That assumption does not hold for a cache directory an attacker can write to: a planted entry would be adopted and the caller's own file discarded. Callers that hold content they have just verified use this instead, so the verified copy wins.

The replacement goes through a uniquely named temporary symlink and a rename, so `dst` is never observed missing or half-written by a concurrent reader.

Winning the collision means the entry that lost has to be disposed of, or the cache grows without bound. AdvertiseCachedFile removed the loser's `src` because it was the loser; here the loser is whatever `dst` already pointed at, and the rename replaces only the symlink, not its target. See orphanedTarget for why that removal is deliberately narrow.

That disposal makes one demand of callers: advertise a given `src` at most once. Once a file has lost a collision it has been deleted, so re-advertising it points `dst` at something that no longer exists. Each caller advertising files it just created — which is what holding freshly verified content means — satisfies this without having to think about it.

func ResolvePath

func ResolvePath(p string, includePaths []string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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