Skip to content

TBD: Don't throw 404 in /core/preview.png?file= if no preview exists #24216

Closed

Description

Steps to reproduce

  1. Having https://ossec.github.io/ installed
  2. Open folder with ~20 files for which oC can't create previews
  3. Get blocked with rule "Rule: 31151 (level 10) -> 'Multiple web server 400 error codes from same source ip.'"

The rule can be easily updated to not jump in if 404s are happening on /core/preview.png but still it might be better to not throw that much 404s.

Expected behaviour

https://demo.owncloud.org/core/preview.png?file=/foo should return a placeholder preview

Actual behaviour

https://demo.owncloud.org/core/preview.png?file=/foo is returning a 404 causing a HIDS to jump in

Server configuration

ownCloud version: 9.0.1

Activity

  1. RobinMcCorkell commented on Apr 23, 2016

    @RobinMcCorkell
    Contributor

    It makes sense to return 404s here though, since the client asked for a resource and it was not found? Perhaps you need to tweak your OSSEC rules to exclude that path?

  2. PVince81 commented on Apr 25, 2016

    @PVince81
    Contributor

    Similar topic: #17557

  3. kernins commented on May 9, 2016

    @kernins

    Previews for unsupported file types just shouldn't be requested in the first place. Most nice and future-proof way to do so would be to export "previewable" (supported by backend) filetypes into frontend context at runtime and then request preview only for matching (so supported) files.

    Admin setting would also be great

    In other words, only supported files should have

    background-image: url("/index.php/core/preview.png?file=...");
    

    and all others should use statics like

    background-image:url(/core/img/filetypes/application-pdf.svg)
    
  4. added this to the backlog milestone on May 9, 2016
  5. PaulAnnekov commented on May 14, 2016

    @PaulAnnekov

    I don't see any problems to return some placeholder image from server if preview can't be generated. Why not?
    It can be fixed very fast, no need to write 100+ lines of code to implement some complex algorithm. Just return a placeholder like Windows does.
    In future, you can make it more complex if it will be required.

  6. kernins commented on May 14, 2016

    @kernins

    Why not?

    At least 'coz this would be masking/working around the issue, not actually fixing it.

    Also this would probably break file-type dependent fallback icons until you reimplement them at the server side by returning different placeholders based on file type. Which would be sort of code duplication.

    some complex algorithm

    Nothing complex there really

  7. PaulAnnekov commented on May 14, 2016

    @PaulAnnekov

    At least 'coz this would be masking/working around the issue, not actually fixing it.

    It's a question of what fix is the TRUE one :). Sometimes there is no single TRUE solution.

    Also this would probably break file-type dependent fallback icons until you reimplement them at the server side by returning different placeholders based on file type. Which would be sort of code duplication.

    I'm not very acknowledged with OC. If it's true then you're right, we can't use placeholder images.

    Nothing complex there really

    Between placeholders instead of 404 and determining "previewable" on server-side, getting "previewable" filetypes, determining if this file is previewable on client side? Of course the 2nd option is complex.

  8. PaulAnnekov commented on May 14, 2016

    @PaulAnnekov

    I think we can make more simple solution. We get an xml list of files with some properties on navigation using request to https://example.com/remote.php/webdav/folder. We can try to add "previewable" flag there for each file. If it's true - request preview.png.

  9. kernins commented on May 15, 2016

    @kernins

    It's a question of what fix is the TRUE one :). Sometimes there is no single TRUE solution.

    And I'm in no way claimimng that my is the only one) I just telling that making requests for non-previewable types is meaningless runtime work, so that route is [probably] suboptimal and so not true.

    "Probably" is because I'm too not really familiar with OC code, my suggestion is based on assumption that there must be some sort of ThumbBuilder programmatic entity which by definition knows what is previewable and what is not, and that that knowlegde may be "exported" in declarative form (so no runtime checks for each file).

    If runtime checks would be required for each file, things wouldn't be so obvious anymore, but I'm "pretty sure" "declarative export" should be possible

    We can try to add "previewable" flag there for each file. If it's true - request preview.png

    This is actually one of possible implementations of what I'm talking about)

  10. jknockaert commented on May 15, 2016

    @jknockaert
    Contributor

    Even when disabling previews altogether (in config.php) the clients continue to be served 404s. That's pointless. This one should definitely be fixed.

  11. RobinMcCorkell commented on May 15, 2016

    @RobinMcCorkell
    Contributor

    Logically, the current behaviour makes sense. The client asks the server for a preview of a file, the server reports there isn't one. A 404 isn't necessarily an error condition. The problem is that we don't allow the client to cache the 404s, which is bad for performance.

  12. jknockaert commented on May 15, 2016

    @jknockaert
    Contributor

    Logically, the current behaviour makes sense.

    No it doesn't. As per RFC7231:

    The 4xx (Client Error) class of status code indicates that the client seems to have erred.

    So there should be by definition an error condition.

  13. 6 remaining items

  14. dercorn commented on Mar 30, 2017

    @dercorn
    Contributor

    @DeepDiver1975 @PVince81 could we come to a conclusion here? I have gotten complaints about this behaviour from other places as well.
    IMHO, 404 is not the correct reply, because for the majority out there it means that something is missing which SHOULD be there. This is clearly contradicting to the actual intentions of anyone configuring previews in their config.php.
    If I go through the process of actually configuring previews, I absolutely expect to see such for the configured mime types and do not want to be bothered with anything else.

  15. PVince81 commented on Mar 31, 2017

    @PVince81
    Contributor

    Properly behaving servers SHOULD NOT throw 4xx around

    This requirement cannot be fulfilled, especially with APIs like Webdav.
    Because file conflicts are expected situations and will return a 409 conflict error code.
    In some situations 4xx are expected to be checked against, not something an admin needs to worry about.
    The mobile client usually does a HEAD call to the server to check if a file exists before uploading and expects to receive a 404. So 4xx errors cannot be completely avoided.

    That said, for the previews I guess what bothers people is mostly that these 404 appear too often instead of being rare cases. The quickest solution then is probably to return a 204 - No content or something similar and have the JS code check against that and fallback to mime type icons.

    @VicDeo can you take care of this ?

  16. modified the milestones: 10.0, backlog on Mar 31, 2017
  17. VicDeo commented on Mar 31, 2017

    @VicDeo
    Contributor

    Just another IMHO: for webservers that I maintain I always exclude static assets locations from error log. :)
    It helps to track other [potentially harmful] activities a lot.

  18. jknockaert commented on Feb 14, 2018

    @jknockaert
    Contributor

    Back in OC 13. Seems like we have a regression here.

  19. jknockaert commented on Feb 14, 2018

    @jknockaert
    Contributor

    Sorry, I meant NC. Wrong repo. Closed again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions