question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mitmdump: temporarily running out of diskspace corrupts dumpfile

See original GitHub issue

Problem Description

ofcourse the world would be a better place if everybody always responsibly managed their filesystem space, but we have to face that fact that mitmdump, as a non-interactive dumping tool, is often going to be the program that fills up the last available block on a filesystem.

currently it deals with that situation very badly:

  • it keeps running, and keeps trying to write to the file
    • which in part is good, because it will resume saving data when space becomes available again
  • the last flow it tried to write is left in the file half-written and truncated, which due to the length-prefixed data format leads to the file being corrupt and not loadable with the provided tools.

due to this situation i already learned more about the file format than i ever wanted to 😉 the key to recovering data in such a corrupted file is:

grep -oE --binary-files=text --byte-offset '[0-9]+:7:version;'

(and i wrote a script that automates the process)

but it would be better to fix this in mitmdump itself. suggestions:

  • on a failed write, truncate the file back to it’s previous length
  • on a failed write, exit with an error
  • maybe provide a tool to recover data from corrupted files

Steps to reproduce the behavior:

log more data than is good for you

System Information

any version i ever used

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mhilscommented, Apr 6, 2022

mitmproxy now at least exits on a full disk. Truncating the file back to its previous length isn’t trivial unfortunately, calling f.truncate(pos) on a full disk just raises another disk full error. Not sure what’s the best way to approach this as we can’t easily reopen from within FlowWriter. 🙃

0reactions
r00t-commented, Nov 13, 2021

the baseline should be to not ignore the error, and exit. creating a warning in advance could be nice to have on top, as also pointed out by mhils:

Optionally we can also consider checking shutil.disk_usage on top and exit at 99% disk usage already

Read more comments on GitHub >

github_iconTop Results From Across the Web

mitmdump memory usage is always constantly growing #4456
i use mitmdump for interactive browsing a lot. that is, i run an mitmdump instance continuously, and use it from multiple browsers on...
Read more >
Examples - mitmproxy docs
shutdown.py — A simple way of shutting down the mitmproxy instance to stop everything. http-stream-modify.py — Modify a streamed response. io-write-flow-file.py ...
Read more >
Source - GitHub
02 November 2022: mitmproxy 9.0.1 * The precompiled binaries now ship with ... @pauloromeira) * Add example addon to dump contents to files...
Read more >
2.5 PDF - Scrapy Documentation
which demands significantly more disk space than Anaconda. 1. Download and execute ... --output or -o: dump scraped items to a file.
Read more >
Cuckoo Sandbox Book - Read the Docs
With the new Cuckoo structure in-place all storage is now, by default, ... Double-check your configuration files with an eye out for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found