-
Notifications
You must be signed in to change notification settings - Fork 6
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
Test driver crashes if special characters are present #84
Labels
bug
Something isn't working
Comments
Related to #5 to some extent. |
am-on
added a commit
to am-on/nixpkgs
that referenced
this issue
Feb 15, 2025
When running the test-driver on other distros (e.g., via [https://github.com/numtide/nix-vm-test/](nix-vm-test)) executing a command can fail if the driver receives both stdout and stderr. The test-driver’s logic for reading output currently assumes it will only read base64 encoded stdout, so any extra stderr content leads to unexpected failures. This commit fixes the issue by redirecting the stderr to /dev/null, ensuring the driver only sees stdout. The tradeoff is losing stderr messages in the machine logs. Users can work around this by redirecting stderr to stdout in the command they are sending to the machine: ```python machine.execute("some_command 2>&1") ``` Related issues: - numtide/nix-vm-test#84 - numtide/nix-vm-test#5
13 tasks
am-on
added a commit
to am-on/nixpkgs
that referenced
this issue
Feb 15, 2025
When running the test-driver on other distros (e.g., via [https://github.com/numtide/nix-vm-test/](nix-vm-test)) executing a command can fail if the driver receives both stdout and stderr. The test-driver’s logic for reading output currently assumes it will only read base64 encoded stdout, so any extra stderr content leads to unexpected failures. This commit fixes the issue by redirecting the stderr to /dev/null, ensuring the driver only sees stdout. The tradeoff is losing stderr messages in the machine logs. Users can work around this by redirecting stderr to stdout in the command they are sending to the machine: ```python machine.execute("some_command 2>&1") ``` Related issues: - numtide/nix-vm-test#84 - numtide/nix-vm-test#5
am-on
added a commit
to am-on/nixpkgs
that referenced
this issue
Feb 15, 2025
When running the test-driver on other distros (e.g., via [https://github.com/numtide/nix-vm-test/](nix-vm-test)) executing a command can fail if the driver receives both stdout and stderr. The test-driver’s logic for reading output currently assumes it will only read base64 encoded stdout, so any extra stderr content leads to unexpected failures. This commit fixes the issue by redirecting the stderr to /dev/null, ensuring the driver only sees stdout. The tradeoff is losing stderr messages in the machine logs. Users can work around this by redirecting stderr to stdout in the command they are sending to the machine: ```python machine.execute("some_command 2>&1") ``` Related issues: - numtide/nix-vm-test#84 - numtide/nix-vm-test#5
am-on
added a commit
to am-on/nixpkgs
that referenced
this issue
Feb 15, 2025
When running the test-driver on other distros (e.g., via [https://github.com/numtide/nix-vm-test/](nix-vm-test)) executing a command can fail if the driver receives both stdout and stderr. The test-driver’s logic for reading output currently assumes it will only read base64 encoded stdout, so any extra stderr content leads to unexpected failures. This commit fixes the issue by redirecting the stderr to /dev/null, ensuring the driver only sees stdout. The tradeoff is losing stderr messages in the machine logs. Users can work around this by redirecting stderr to stdout in the command they are sending to the machine: ```python machine.execute("some_command 2>&1") ``` Related issues: - numtide/nix-vm-test#84 - numtide/nix-vm-test#5
am-on
added a commit
to am-on/nixpkgs
that referenced
this issue
Feb 15, 2025
When running the test-driver on other distros (e.g., via [https://github.com/numtide/nix-vm-test/](nix-vm-test)) executing a command can fail if the driver receives both stdout and stderr. The test-driver’s logic for reading output currently assumes it will only read base64 encoded stdout, so any extra stderr content leads to unexpected failures. This commit fixes the issue by redirecting the stderr to /dev/null, ensuring the driver only sees stdout. The tradeoff is losing stderr messages in the machine logs. Users can work around this by redirecting stderr to stdout in the command they are sending to the machine: ```python machine.execute("some_command 2>&1") ``` Related issues: - numtide/nix-vm-test#84 - numtide/nix-vm-test#5
am-on
added a commit
to am-on/nixpkgs
that referenced
this issue
Feb 15, 2025
When running the test-driver on other distros (e.g., via [https://github.com/numtide/nix-vm-test/](nix-vm-test)) executing a command can fail if the driver receives both stdout and stderr. The test-driver’s logic for reading output currently assumes it will only read base64 encoded stdout, so any extra stderr content leads to unexpected failures. This commit fixes the issue by redirecting the stderr to /dev/null, ensuring the driver only sees stdout. The tradeoff is losing stderr messages in the machine logs. Users can work around this by redirecting stderr to stdout in the command they are sending to the machine: ```python machine.execute("some_command 2>&1") ``` Related issues: - numtide/nix-vm-test#84 - numtide/nix-vm-test#5
am-on
added a commit
to am-on/nix-vm-test
that referenced
this issue
Feb 18, 2025
When running tests on Ubuntu VMs, the `test-driver` can crash if the executed command calls `sudo` and writes to stderr. For example: ```python vm.execute("sudo bash -c \"echo 'Created foo → bar.\n' >&2 && echo 'foo' \"") ``` `sudo` spawns a new TTY on Ubuntu, merging both `stdout` and `stderr` into a single stream. However, the `test-driver` only expects base64-encoded `stdout` and fails when stderr data appears. - Normal command (note `1` and `2` are different consoles) ``` > bash -c 'echo $$; ls -l /proc/$$/fd' lr-x------ 1 root root 64 Feb 18 06:10 0 -> /dev/hvc0 l-wx------ 1 root root 64 Feb 18 06:10 1 -> pipe:[20942] l-wx------ 1 root root 64 Feb 18 06:10 2 -> /dev/ttyS0 lr-x------ 1 root root 64 Feb 18 06:10 3 -> /proc/664/fd ``` - Using `sudo` (note both `1` and `2` use the same console `/dev/pts/0`) ``` > sudo bash -c 'echo $$; ls -l /proc/$$/fd lrwx------ 1 root root 64 Feb 18 06:10 0 -> /dev/pts/0 l-wx------ 1 root root 64 Feb 18 06:10 1 -> pipe:[20943] lrwx------ 1 root root 64 Feb 18 06:10 2 -> /dev/pts/0 lr-x------ 1 root root 64 Feb 18 06:10 3 -> /proc/670/fd ``` Because `stderr` is now mixed with `stdout` on `/dev/pts/0`, the `test-driver`'s base64 decoding code crashes on unexpected data: ([encoding step](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L578), [decoding step](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L588)). A minimal reproducible example is provided in [am-on/nix-test-driver-ubuntu-bug](https://github.com/am-on/nix-test-driver-ubuntu-bug). Related issues: - numtide#84 - numtide#5
am-on
added a commit
to am-on/nix-vm-test
that referenced
this issue
Feb 18, 2025
When running tests on Ubuntu VMs, the `test-driver` can crash if the executed command calls `sudo` and writes to `stderr`. For example: ```python vm.execute("sudo bash -c \"echo 'Created foo → bar.\n' >&2 && echo 'foo' \"") ``` `sudo` spawns a new TTY for `stderr` on Ubuntu that gets read by the `test-driver`'s output parsing. However, the `test-driver` only expects base64-encoded `stdout` and fails when `stderr` data is read. - Normal command (note `stderr` usees `/dev/ttyS0`) ``` > bash -c 'echo $$; ls -l /proc/$$/fd' lr-x------ 1 root root 64 Feb 18 06:10 0 -> /dev/hvc0 l-wx------ 1 root root 64 Feb 18 06:10 1 -> pipe:[20942] l-wx------ 1 root root 64 Feb 18 06:10 2 -> /dev/ttyS0 lr-x------ 1 root root 64 Feb 18 06:10 3 -> /proc/664/fd ``` - Using `sudo` (note `stderr` uses `/dev/pts/0`) ``` > sudo bash -c 'echo $$; ls -l /proc/$$/fd lrwx------ 1 root root 64 Feb 18 06:10 0 -> /dev/pts/0 l-wx------ 1 root root 64 Feb 18 06:10 1 -> pipe:[20943] lrwx------ 1 root root 64 Feb 18 06:10 2 -> /dev/pts/0 lr-x------ 1 root root 64 Feb 18 06:10 3 -> /proc/670/fd ``` Because `stderr` is now read along with the `stdout`, the `test-driver`'s base64 decoding code crashes on unexpected data: - [encoding step](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L578), - [receiving the data](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L515), - [decoding step](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L588). A minimal reproducible example is provided in [am-on/nix-test-driver-ubuntu-bug](https://github.com/am-on/nix-test-driver-ubuntu-bug). Related issues: - numtide#84 - numtide#5
picnoir
pushed a commit
that referenced
this issue
Feb 19, 2025
When running tests on Ubuntu VMs, the `test-driver` can crash if the executed command calls `sudo` and writes to `stderr`. For example: ```python vm.execute("sudo bash -c \"echo 'Created foo → bar.\n' >&2 && echo 'foo' \"") ``` `sudo` spawns a new TTY for `stderr` on Ubuntu that gets read by the `test-driver`'s output parsing. However, the `test-driver` only expects base64-encoded `stdout` and fails when `stderr` data is read. - Normal command (note `stderr` usees `/dev/ttyS0`) ``` > bash -c 'echo $$; ls -l /proc/$$/fd' lr-x------ 1 root root 64 Feb 18 06:10 0 -> /dev/hvc0 l-wx------ 1 root root 64 Feb 18 06:10 1 -> pipe:[20942] l-wx------ 1 root root 64 Feb 18 06:10 2 -> /dev/ttyS0 lr-x------ 1 root root 64 Feb 18 06:10 3 -> /proc/664/fd ``` - Using `sudo` (note `stderr` uses `/dev/pts/0`) ``` > sudo bash -c 'echo $$; ls -l /proc/$$/fd lrwx------ 1 root root 64 Feb 18 06:10 0 -> /dev/pts/0 l-wx------ 1 root root 64 Feb 18 06:10 1 -> pipe:[20943] lrwx------ 1 root root 64 Feb 18 06:10 2 -> /dev/pts/0 lr-x------ 1 root root 64 Feb 18 06:10 3 -> /proc/670/fd ``` Because `stderr` is now read along with the `stdout`, the `test-driver`'s base64 decoding code crashes on unexpected data: - [encoding step](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L578), - [receiving the data](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L515), - [decoding step](https://github.com/NixOS/nixpkgs/blob/8a24fbd0f3b4f47f01c897a95b1b65d6a5576c01/nixos/lib/test-driver/src/test_driver/machine.py#L588). A minimal reproducible example is provided in [am-on/nix-test-driver-ubuntu-bug](https://github.com/am-on/nix-test-driver-ubuntu-bug). Related issues: - #84 - #5
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
A simple
→
character in the output crashes the driver.To Reproduce
Activate systemd unit under Ubuntu VM.
Expected behavior
Should be able to parse and pass any string via test driver.
System information
Operating System: Linux
Machine Type: 4x16
Architecture: amd64
Additional context
https://github.com/ParetoSecurity/pareto-core/actions/runs/13114941839/job/36586854338?pr=77#step:5:1636
The text was updated successfully, but these errors were encountered: