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

Handle forbidden characters in asset path #1201

Merged
merged 6 commits into from
Jul 27, 2022
Merged

Conversation

DeepikaGhodki
Copy link
Contributor

@DeepikaGhodki DeepikaGhodki commented Jul 19, 2022

Fixes 1111

Current path validations for an asset are as follows:

  1. Must not be empty or null
  2. Must not be an absolute path (start with /)
  3. Must not be a directory path (./ or ../)
  4. Must not contain only . in sub paths
  5. Must not contain \0
  6. Must not contain repeating /

This PR contains validations for checking the above using regular expressions for character matching.

TODO

  • Fix affected test cases using absolute asset path

@DeepikaGhodki DeepikaGhodki marked this pull request as ready for review July 19, 2022 22:25
dandiapi/api/tests/test_asset.py Outdated Show resolved Hide resolved
dandiapi/api/views/asset.py Show resolved Hide resolved
dandiapi/api/views/asset.py Outdated Show resolved Hide resolved
dandiapi/api/views/asset.py Show resolved Hide resolved
dandiapi/api/views/asset.py Outdated Show resolved Hide resolved
dandiapi/api/views/asset.py Outdated Show resolved Hide resolved
Copy link
Member

@mvandenburgh mvandenburgh left a comment

Choose a reason for hiding this comment

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

LGTM

@DeepikaGhodki DeepikaGhodki merged commit 739aa6b into master Jul 27, 2022
@DeepikaGhodki DeepikaGhodki deleted the invalid-asset-paths branch July 27, 2022 15:08
@dandibot
Copy link
Member

🚀 PR was released in v0.2.41 🚀

@dandibot dandibot added the released This issue/pull request has been released. label Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Archive allows asset paths that are empty, non-normalized, or absolute
4 participants