Skip to content

helper: Add a helper to compute path of narInfo and nar - #7

Merged
kalbasit merged 1 commit into
mainfrom
helper
Dec 1, 2024
Merged

kalbasit merged 1 commit into
mainfrom
helper

Conversation

@kalbasit

@kalbasit kalbasit commented Dec 1, 2024

Copy link
Copy Markdown
Owner

I use these a lot and so it's important to have them tested and shared.

@kalbasit
kalbasit merged commit f48164c into main Dec 1, 2024
@kalbasit
kalbasit deleted the helper branch December 1, 2024 07:17
kalbasit added a commit that referenced this pull request Dec 1, 2024
* main:
  helper: Add a helper to compute path of narInfo and nar (#7)
kalbasit added a commit that referenced this pull request Dec 1, 2024
* main:
  cache: Implement GetNar() and GetNarInfo() (#8)
  helper: Add a helper to compute path of narInfo and nar (#7)
  cache: take in upstream caches and sort them by priority (#6)
kalbasit added a commit that referenced this pull request Feb 3, 2026
This change addresses a path injection vulnerability (alert #7) where unvalidated
hashes could be used to construct file paths, potentially allowing access to
arbitrary files.

Hash validation has been added to `pkg/helper/filepath.go` using a regex
that ensures hashes only contain alphanumeric characters.

The return signatures of `NarInfoFilePath` and `NarFilePath` have been updated
to return an error if the hash is invalid. All call sites in `pkg/storage/local`,
`pkg/storage/s3`, and `pkg/nar` have been updated to handle these errors.

A validation helper `ValidateHash` and a new error `ErrInvalidHash` were introduced
in `pkg/helper/filepath.go` to support these checks.
kalbasit added a commit that referenced this pull request Feb 4, 2026
This change addresses a path injection vulnerability (alert #7) where unvalidated
hashes could be used to construct file paths, potentially allowing access to
arbitrary files.

Hash validation has been added to `pkg/helper/filepath.go` using a regex
that ensures hashes only contain alphanumeric characters.

The return signatures of `NarInfoFilePath` and `NarFilePath` have been updated
to return an error if the hash is invalid. All call sites in `pkg/storage/local`,
`pkg/storage/s3`, and `pkg/nar` have been updated to handle these errors.

A validation helper `ValidateHash` and a new error `ErrInvalidHash` were introduced
in `pkg/helper/filepath.go` to support these checks.
kalbasit added a commit that referenced this pull request Feb 4, 2026
This change addresses a path injection vulnerability (alert #7) where unvalidated
hashes could be used to construct file paths, potentially allowing access to
arbitrary files.

Hash validation has been added to `pkg/helper/filepath.go` using a regex
that ensures hashes only contain alphanumeric characters.

The return signatures of `NarInfoFilePath` and `NarFilePath` have been updated
to return an error if the hash is invalid. All call sites in `pkg/storage/local`,
`pkg/storage/s3`, and `pkg/nar` have been updated to handle these errors.

A validation helper `ValidateHash` and a new error `ErrInvalidHash` were introduced
in `pkg/helper/filepath.go` to support these checks.

(cherry picked from commit 2eb0a8c)
kalbasit added a commit that referenced this pull request Feb 4, 2026
…backport #722] (#725)

This change addresses a path injection vulnerability (alert #7) where
unvalidated hashes could be used to construct file paths, potentially
allowing access to arbitrary files.

Hash validation has been added to `pkg/helper/filepath.go` using a regex
that ensures hashes only contain alphanumeric characters.

The return signatures of `NarInfoFilePath` and `NarFilePath` have been
updated to return an error if the hash is invalid. All call sites in
`pkg/storage/local`, `pkg/storage/s3`, and `pkg/nar` have been updated
to handle these errors.

A validation helper `ValidateHash` and a new error `ErrInvalidHash` were
introduced in `pkg/helper/filepath.go` to support these checks.

(cherry picked from commit 2eb0a8c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant