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

Reading file from stdin does not work #6704

Open
jaywor1 opened this issue Mar 3, 2024 · 3 comments
Open

Reading file from stdin does not work #6704

jaywor1 opened this issue Mar 3, 2024 · 3 comments
Labels
area/core help wanted kind/feature New features / enhancements

Comments

@jaywor1
Copy link
Contributor

jaywor1 commented Mar 3, 2024

Problem Description

In option rfile - is an invalid input

mitmweb

root@mitmweb-01:~# tail -f /var/log/mitmproxy/dump-merged.har | mitmweb --rfile - -n
tail: /var/log/mitmproxy/dump-merged.har: file truncated
[21:00:07.316] Web server listening at http://127.0.0.1:8081/
[21:00:07.414] No web browser found. Please open a browser and point it to http://127.0.0.1:8081/
[21:00:07.414] Cannot load flows: [Errno 2] No such file or directory: '-'
[21:00:07.414] Failed to read -: [Errno 2] No such file or directory: '-'
Traceback (most recent call last):
  File "mitmproxy/addons/readfile.py", line 63, in load_flows_from_path
FileNotFoundError: [Errno 2] No such file or directory: '-'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "mitmproxy/addons/readfile.py", line 71, in doread
  File "mitmproxy/addons/readfile.py", line 67, in load_flows_from_path
mitmproxy.exceptions.FlowReadException: [Errno 2] No such file or directory: '-'
Errors logged during startup, exiting...
root@mitmweb-01:~# 

mitmproxy

Really mess-ups terminal and i get this error

Invalid filter expression: 'on": "1.1"'

I tested the file running it with a -r option and it normally loads the file.

Steps to reproduce the behavior:

  1. tail -f /var/log/mitmproxy/dump-merged.har | mitmweb --rfile - -n

System Information

Mitmproxy: 10.2.1 binary
Python:    3.12.1
OpenSSL:   OpenSSL 3.1.4 24 Oct 2023
Platform:  Linux-6.1.0-18-amd64-x86_64-with-glibc2.36
@jaywor1 jaywor1 added the kind/triage Unclassified issues label Mar 3, 2024
@mhils
Copy link
Member

mhils commented Mar 4, 2024

We're currently using the ReadFileStdin addon for mitmdump only, but I think we can enable it for mitmweb as well. For mitmproxy it won't work because we need stdin for user input.

Contributions welcome!

@mhils mhils added kind/feature New features / enhancements help wanted area/core and removed kind/triage Unclassified issues labels Mar 4, 2024
@jaywor1
Copy link
Contributor Author

jaywor1 commented Mar 4, 2024

We're currently using the ReadFileStdin addon for mitmdump only, but I think we can enable it for mitmweb as well....

Could you enable it please 🙏 I don't really know how and where (in the source code).

For mitmproxy it won't work because we need stdin for user input.

That makes sense :D, fortunately I just need mitmweb

@jaywor1
Copy link
Contributor Author

jaywor1 commented Mar 11, 2024

Could you enable it please 🙏 I don't really know how and where (in the source code).

After some grep stuff I created PR: #6732

@mhils mhils mentioned this issue Mar 11, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core help wanted kind/feature New features / enhancements
Projects
None yet
Development

No branches or pull requests

2 participants