Skip to content

Use gunzip instead of zless#2509

Open
muffato wants to merge 4 commits intosamtools:developfrom
muffato:zcat_roh_viz
Open

Use gunzip instead of zless#2509
muffato wants to merge 4 commits intosamtools:developfrom
muffato:zcat_roh_viz

Conversation

@muffato
Copy link

@muffato muffato commented Mar 7, 2026

Hi.

Reading the code, I think you don't need the "less" capability of zless in roh-viz. I think the script just needs a plain-text stream of a potentially-compressed input file. Since less is an extra dependency that is not necessarily installed, especially in containers, and is just a wrapper around gzip, I propose to invoke gunzip directly.
Importantly, it needs the -f and -q option zless uses to transparently handle uncompressed files.

I also address two issues Copilot found during its review:

  • open the command without shell interpretation
  • reference the right variable in the error message

Best regards,
Matthieu

Copilot AI review requested due to automatic review settings March 7, 2026 12:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the roh-viz helper script to stream bcftools roh output via zcat instead of zless, aiming to remove the dependency on less in minimal/container environments.

Changes:

  • Replace zless pipe with zcat when reading the RoH input file.
  • Update the corresponding close error message (though it currently references the wrong option key).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

muffato and others added 3 commits March 8, 2026 13:18
The close error message references `$$opts{in_file}`, but this function opens `$$opts{roh_file}` and there is no `in_file` option in this script. This will produce a misleading/empty error message if the pipe fails; update it to refer to the RoH input and ideally include the underlying failure info (e.g., `$!` and/or `$?`).

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Using one-arg open with a piped string command (`open(my $in, "zcat $$opts{roh_file} |")`) invokes a shell and lets it interpret `$$opts{roh_file}`, enabling OS command injection if that value is attacker-controlled. Here `roh_file` comes directly from CLI arguments, so a crafted filename containing shell metacharacters could execute arbitrary commands with this script’s privileges. Replace this with a shell-free invocation (e.g., multi-arg `open` or a decompression module that takes the filename as a separate argument) and/or strictly validate the allowed pathname characters.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Still need to enable all flags zless uses, especially -f and -q
to transparently handle uncompressed files.
@muffato muffato requested a review from Copilot March 8, 2026 13:24
@muffato muffato changed the title Use zcat instead of zless Use gunzip instead of zless Mar 8, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants