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

Carrierwave download of external url #2695

Closed
janz93 opened this issue Aug 30, 2023 · 1 comment · Fixed by #2696
Closed

Carrierwave download of external url #2695

janz93 opened this issue Aug 30, 2023 · 1 comment · Fixed by #2696

Comments

@janz93
Copy link

janz93 commented Aug 30, 2023

Problem

Hello everyone 👋

I am facing errors from Webmock and VCR where specs fail with an unhandled web request error. e.g. UnhandledHTTPRequestError or NetConnectNotAllowedError.
During my investigation I noticed that those unhandled web requests are caused by the download! method. This method gets called if an external_url is present. Which is here the case.

Question

My goal is to have an offline test suite, therefore, I was a bit surprised about this behavior, since I set enable_processing to false.
I solved the offline approach by mocking all requests:

  1. Prevent IP resolving -> Overwrite the SsrfFilter::DEFAULT_RESOLVER Add way to globally disable filter arkadiyt/ssrf_filter#33 (comment)
  2. Mock the external_url URI request -> webmock/vcr

Currently, I am unsure if this is the best approach or if carrierwave should handle this automatically depending on the enable_processing setting. Especially since setting enable_processing to false causes an early exit anyway.

@rajyan
Copy link
Contributor

rajyan commented Aug 31, 2023

I'm not sure with the best practices of testing carrierwave too, but I'm currently
disabling ssrf_filter by configuring skip_ssrf_protection? with a custom downloader only for test

def skip_ssrf_protection?(uri)

and stubbing the external_url

Maybe some kind of configuration like
https://github.com/carrierwaveuploader/carrierwave/pull/2575/files seems reasonable?

Do you have any opinions? @mshibuya

These are related issues

arkadiyt/ssrf_filter#33
arkadiyt/ssrf_filter#59
#2573

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 a pull request may close this issue.

2 participants