Modify regex for Releases API filepath
What does this MR do?
Resolving tech debt from #208289 (closed)
We are exposing
filepath_url
but I couldn't find the code where we're exposingfilepath
🔍 🤔
No, and it since was renamed to direct_asset_url
, and we've forgotten to remove filepath
from the schema. So removing it
> * Prefer `%r{}` if the regexp contains slashes so we don't have to escape them
> * Add `(?: ... )` if we don't need to capture groups which is here the case I believe
>
>
> ```suggestion:-0+0
> FILEPATH_REGEX = %r{\A/(?:[\-\.\w]+/?)*[\da-zA-Z]+\z}.freeze
> ```
> * Do we want to prevent directory traversal by disallowing `/../../../../../etc/passwd`? :thinking:
This path won't be used to locate files on disc, it will be resolved as part of the URL, so there nothing to traverse right now.
> * Do we allow unicode in file path? If not, why not?
We can add it later if we realize that we need to.
> * Do we have access to these filepath? If so, could we just check its existence instead of checking via regex? :thinking:
No, it's not a filepath on FS, is just something in /group/project/releases/my-release/assets/{filepath}
and GitLab will redirect to Link.url
.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team