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

feat: Remove original file stem from filenames in the blobstorage (#4309) #4583

Commits on Apr 26, 2024

  1. feat: Use random filename suffixes for blobstorage (#4309)

    Recently there was an accident with a chatbot that replaced its avatar set from the command line
    with an unrelated avatar of a contact. Both the `selfavatar` setting and the contact avatar `i`
    param pointed to `$BLOBDIR/avatar.png` at the time it was detected. How this happened is unclear,
    but it is possible that `avatar.png` was removed, unmounted or otherwise not detected by the core,
    and the core stored avatar received from the contact as `avatar.png`, while `selfavatar` config
    still pointed to `$BLOBDIR/avatar.png`.
    
    Such bugs are unavoidable even if the core itself has no bugs as we cannot rely on blobdir not
    reside on the faulty network filesystem, being incorrectly backed up and restored etc., so we should
    assume that files may be randomly removed. Then there may be dangling `$BLOBDIR/...` references in
    the database which may accidentally point to unrelated files, could even be an `avatar.png` file
    sent to the bot in private.
    
    To prevent such bugs, we add random filename suffixes for the blobdir objects. Thanks to the added
    Param::Filename these random suffixes aren't sent over the network.
    iequidoo committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    ed33f30 View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2024

  1. Configuration menu
    Copy the full SHA
    7391c8d View commit details
    Browse the repository at this point in the history
  2. feat: Remove original file stem from filenames in the blobstorage (#4309

    )
    
    This way filenames in the blobstorage are just random hex numbers. This also allows us to get rid of
    the `sanitize-filename` dependency.
    
    This also requires `Param::Filename` to be set to "debug_logging*.xdc" for messages containing
    logging webxdc-s, otherwise they are not detected properly. This is done in "fix:
    Message::set_file_from_bytes(): Set Param::Filename", so don't forget to update senders as well.
    iequidoo committed Apr 27, 2024
    Configuration menu
    Copy the full SHA
    204f747 View commit details
    Browse the repository at this point in the history
  3. fix: Assume file extensions are 32 chars max and don't contain whites…

    …pace (#5338)
    
    Before file extensions were also limited to 32 chars, but extra chars in the beginning were just cut
    off, e.g. "file.with_lots_of_characters_behind_point_and_double_ending.tar.gz" was considered to
    have an extension "d_point_and_double_ending.tar.gz". Better to take only "tar.gz" then.
    
    Also don't include whitespace-containing parts in extensions. File extensions generally don't
    contain whitespaces.
    iequidoo committed Apr 27, 2024
    Configuration menu
    Copy the full SHA
    562c4f8 View commit details
    Browse the repository at this point in the history