Documentation
¶
Index ¶
- func MakeEmptyTar() io.ReadCloser
- func MakeFilteredTar(dir string, includePatterns []string, onlyPaths map[string]bool, ...) (io.ReadCloser, error)
- func MakeTar(dir string, includePatterns []string, uncompressedBytes *atomic.Int64) (io.ReadCloser, error)
- func SafePath(root, name string) (string, error)
- func SafeWritePath(root, name string) (string, error)
- func TarFS(r io.Reader, dir string) (fsutil.FS, error)
- func TarToMap(r io.Reader) (map[string][]byte, error)
- func ValidatePattern(pattern string) error
- type FileManifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeEmptyTar ¶ added in v0.6.0
func MakeEmptyTar() io.ReadCloser
MakeEmptyTar returns a valid empty gzipped tar archive.
func MakeFilteredTar ¶ added in v0.6.0
func MakeFilteredTar(dir string, includePatterns []string, onlyPaths map[string]bool, uncompressedBytes *atomic.Int64) (io.ReadCloser, error)
MakeFilteredTar creates a gzipped tar like MakeTar but only includes files whose relative paths are in the onlyPaths set. Directory entries are included as needed to contain the requested files. If uncompressedBytes is non-nil, each file's uncompressed size is atomically added after it is written.
func SafePath ¶ added in v0.13.0
SafePath joins an untrusted archive path to root after verifying that the result remains within root.
The containment check runs on the entry name rather than on the joined result. filepath.IsLocal rejects absolute paths and anything that climbs out via "..", and checking the name up front is the one shape CodeQL's zip-slip sanitizer model recognizes, so callers that extract through this helper stop tripping go/zipslip.
func SafeWritePath ¶ added in v0.13.0
SafeWritePath validates an archive path and rejects existing symlinks in the destination path so extraction cannot write through them.
func ValidatePattern ¶
ValidatePattern checks that a user-supplied gitignore-style pattern parses successfully.
Types ¶
type FileManifest ¶ added in v0.6.0
FileManifest represents a file's metadata for delta upload comparison.
func ComputeManifest ¶ added in v0.6.0
func ComputeManifest(dir string, includePatterns []string) ([]FileManifest, error)
ComputeManifest walks a directory using the same gitignore/include logic as MakeTar and returns a manifest of all regular files with their SHA-256 hashes.