Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a better way to name persistent storage directories #24

Open
phenaproxima opened this issue Apr 22, 2021 · 3 comments
Open

Find a better way to name persistent storage directories #24

phenaproxima opened this issue Apr 22, 2021 · 3 comments
Assignees
Labels
question Further information is requested
Milestone

Comments

@phenaproxima
Copy link
Collaborator

Right now, when the plugin sets up the persistent storage location for TUF metadata in the context of a particular repository, it uses this line of code to name the directory:

preg_replace('/[^[:alnum:]\.]/', '-', $repoUrl)

This can be problematic because URLs like site.coop.info/packages and site.coop/info/packages will collide. This is probably something of an edge case, but it's enough of a concern that it should block a 1.0.0 release of this plugin. We need to find a better way to name these directories.

One option is to use a SHA-256 hash of the URL, but that could be quite obscure. Other thoughts welcome...

@phenaproxima
Copy link
Collaborator Author

Assigning to @davidstrauss, since I think his opinion might be useful here.

@phenaproxima phenaproxima added this to the 1.0.0 milestone Jan 17, 2023
@davidstrauss
Copy link

I see a couple options to balance these needs:

  • Use a true escaping method that doesn't create collisions. For example, I think URL encoding may provide a conservative subset of what a filename is allowed to contain.
  • Combine the current naming with a hash, eliminating collision risk while preserving readability for most purposes. I would put the hash later in the name to improve sorting and tab completion experiences.

I slightly prefer the latter, as the readable part remains more readable/tab-completable. The common case won't be collision, anyway.

@phenaproxima
Copy link
Collaborator Author

Combine the current naming with a hash, eliminating collision risk while preserving readability for most purposes. I would put the hash later in the name to improve sorting and tab completion experiences.

I think that's a pretty good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants