RexOps / RexOps/Rex

Bad parsing of `ps` output if command field is not the last one

Open
#646 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
737
Forks
214
PR merge metrics
No merged PRs in 30d

Description

Originally reported by Matthias Teege on google groups

Rex uses the ps command to gather the process information by splitting the output lines on whitespaces (/\s+/) to extract the different fields, while keeping the maximum number of extracted fields to the number of expected fields.

Since the command field of the output itself can contain spaces (e.g. /usr/bin/perl /usr/bin/perldoc Rex::Commands::Process), this method only can work if ps is asked to output the command field as the last one on the line (so it is prevented from being split on whitespaces as the maximum allowed number of splits already happened).

Rex either needs to somehow gather the process information in a machine-parsable format, or at least try to ensure that if command field is requested, then it is being used as last.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the code that invokes ps and parses its process-information output, then inspect how requested fields are ordered and split. Done means commands containing spaces are parsed correctly when command is not last, using a machine-parsable format or ensuring that field is last.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.