Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
generic-stdout-parser
Advanced tools
Parse any type of stdout into JSON or XML[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[Dcommand line/shell stdout into JSON or XML
Unable to find a parser for results of command 'v4l2-ctl --list-ctrls', I had to create it myself. Soooo fed up of manually creating parsers for cmd/sh/bash command line output logs , I created this NPM package to centralize all my homemade parsers at the same place, and possibly avoid to have to specify the input format
When there are useless lines added to a stdout json or xml shell output, the parser manages to detect and ignore them.
To avoid duplication with linux tables parsing of package node-shell-parser, it is possible to use 'node-shell-parser' as inputFormat
Available input formats are
Available output formats are
npm install generic-stdout-parser
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = [' some useless output line',' <lelama>NUL</lelama> ',' another useless output line']
const parseRes = new StdOutParser(stdoutlog).parse()
console.log(parseRes.result.lelama === "NUL")
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ['{ "lelama": "NUL" }']
const parseRes = new StdOutParser(stdoutlog).parse()
assert(parseRes.result.lelama === "NUL",'lelama property not found in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ['blablablabla',' { "lelama": "NUL" }']
const parseRes = new StdOutParser(stdoutlog).parse()
assert(parseRes.result.lelama === "NUL",'lelama property not found in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = '<lelama>NUL</lelama>'
const parseRes = new StdOutParser(stdoutlog).parse()
assert(parseRes.result.lelama === "NUL",'lelama property not found in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ['{ "lelama": "NUL" }']
const parseRes = new StdOutParser(stdoutlog,{'resultFormat': 'xml'}).parse()
console.log(parseRes)
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = `User Controls
brightness (int) : min=0 max=100 step=1 default=50 value=50 flags=slider
contrast (int) : min=-100 max=100 step=1 default=0 value=-10 flags=slider
saturation (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
red_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
blue_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
horizontal_flip (bool) : default=0 value=0
Codec Controls
video_bitrate_mode (menu) : min=0 max=1 default=0 value=0 flags=update
video_bitrate (int) : min=25000 max=25000000 step=25000 default=10000000 value=10000000
repeat_sequence_header (bool) : default=0 value=0
h264_i_frame_period (int) : min=0 max=2147483647 step=1 default=60 value=60
h264_level (menu) : min=0 max=11 default=11 value=11
h264_profile (menu) : min=0 max=4 default=4 value=4` ;
const parseRes = new StdOutParser(stdoutlog,{inputFormat: 'raw_structure_datatype_props'}).parse()
assert(parseRes.result.find(x => x.name === 'User Controls').properties
.find(x => x.name === 'brightness').properties
.find(x => x.name === 'value')
.value === '50',
'Unable to find Camera Controls auto_exposure.max with value 3 in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ` PID TTY TIME CMD
23856 pts/1 00:00:00 ps
31475 pts/1 00:00:00 bash
` ;
const parseRes = new StdOutParser(stdoutlog,{'inputFormat': 'shell'}).parse()
assert(parseRes.result[0]['TTY'] === '23856 pts/1','Unable to find TTY = N23856 pts/1 in '+parseRes)
Don't hesitate to contribute with GitHub pull requests !
FAQs
Parse any type of command line/cmd/shell stdout into Javascrpt Object, JSON or XML
The npm package generic-stdout-parser receives a total of 2 weekly downloads. As such, generic-stdout-parser popularity was classified as not popular.
We found that generic-stdout-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.