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

Make flatfs robust #64

Merged
merged 8 commits into from
Feb 14, 2020
Merged

Make flatfs robust #64

merged 8 commits into from
Feb 14, 2020

Conversation

Stebalien
Copy link
Member

  1. Improve query logic to finally support all features. Offsets, limits, filters, and sorting are all supported through naive queries.
  2. Fetch files from disk when asked. Not exactly fast but the user is allowed to dig their own grave.
  3. Explicitly restrict keys instead of randomly doing bad things at runtime.

Importantly, this change only allows keys of the form /[0-9A-Z+-_=]. That is, upper-case alphanumeric keys in the root namespace (plus some special characters).

Why? We don't encode keys before writing them to the filesystem. This change ensures that:

  1. Case sensitivity doesn't matter because we only allow upper-case keys.
  2. Path separators and special characters doesn't matter.

For context, go-ipfs only uses flatfs for storing blocks. Every block CID is encoded as uppercase alphanumeric text (specifically, uppercase base32).

We could be less restrictive, but this is safer and easier to understand. Unfortunately, we can't allow mixed case (Windows) and can't allow lowercase because we're already using uppercase keys.


fixes #32, #61, #40, #22

tests with the query test suite

Copy link

@dirkmc dirkmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM 👍

I don't have the context to know if this is a good idea, but it seems like a good idea :)

flatfs.go Outdated Show resolved Hide resolved
Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpicks.

Any relevant context/request that makes this a necessary change or is it just general maintenance?

key_test.go Show resolved Hide resolved
flatfs.go Outdated Show resolved Hide resolved
flatfs.go Outdated Show resolved Hide resolved
flatfs.go Show resolved Hide resolved
While this datastore is still quite limited, we might as well support everything
we easily can.
That way, we're finally implementing everything.
Only allow keys of the form `/[0-9A-Z+-_=]`. That is, upper-case alphanumeric
keys in the root namespace (plus some special characters).

Why? We don't encode keys before writing them to the filesystem. This change
ensures that:

1. Case sensitivity doesn't matter because we only allow upper-case keys.
2. Path separators and special characters doesn't matter.

For context, go-ipfs only uses flatfs for storing blocks. Every block CID is
encoded as uppercase alphanumeric text (specifically, uppercase base32).

We could be less restrictive, but this is safer and easier to understand.
Unfortunately, we _can't_ allow mixed case (Windows) and can't allow lowercase
because we're already using uppercase keys.

fixes #23
@Stebalien
Copy link
Member Author

Any relevant context/request that makes this a necessary change or is it just general maintenance?

General maintenance. I needed to pull through a fix for prefix handling in the query logic.

@hsanjuan
Copy link
Contributor

Errors in tests, seems circle is building with old Go ?

@Stebalien
Copy link
Member Author

Errors in tests, seems circle is building with old Go ?

Updated go-log.

@Stebalien
Copy link
Member Author

Oh, and probably old go.

@Stebalien Stebalien merged commit a348e6e into master Feb 14, 2020
@Stebalien Stebalien deleted the feat/improve-flatfs branch February 14, 2020 17:05
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.

3 participants