Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@tap-format/parser
Advanced tools
A highly verbose parser for the Test Anything Protocol that exposes an observable and streaming interface
A highly verbose parser for the Test Anything Protocol that exposes an observable and streaming interface.
This is the parser used to create the following beautiful TAP formatters:
= 4.x
npm install @tap-format/parser --save
The parser exposes an interface that lets you deal with the parsed TAP with Reactive Extensions. See the API section for a full list of exposed Observables.
var parse = require('@tap-format/parser')
var stream = process.stdin
var tap$ = parser.observeStream(stream)
tap$.tests$
.forEach(function (test) {
console.log(test.title)
})
tap$.asserions$
.forEach(function (assertion) {
console.log(assertion.title)
})
The parser will parse streaming data for any source.
var parser = require('@tap-format/parser')
var H = require('highland')
var tapStream = H(process.stdin.pipe(parser.stream()))
var tests = tapStream.filter(function (line) {
return line.type === 'test'
})
var assertions = tapStream.filter(function (line) {
return line.type === 'assertion'
})
tests.each(function (test) {
console.log(test.title)
})
assertions.each(function (assertion) {
console.log(assertion.title)
})
$ something-that-produces-tap | tap-format-parser
{
// Parsed TAP output as JSON here
}
Given a streaming input, the parser will expose and RXjs Observable chunked by new lines. In addition, the parser exposes the following properties as Observables as convenience methods for the parsed TAP.
var parser = requrie('@tap-format/parser')
var stream = process.stdin
var tap$ = parser.observeStream(stream)
An Observable of all parsed output for the given input TAP stream
// This will console.log every assertion title
tap$
.filter(function (line) {
return line.type === 'assertion'
})
.forEach(function (assertion) {
console.log(assertion.title)
})
An Observable of all parsed tests.
// This will console.log all test titles
tap$.tests$
.map(function (test) {
return 'TEST: ' + test.title
})
.forEach(console.log.bind(console))
The shape of the test object is as follows:
# My Test
)test
# My Test
becomes My Test
An Observable of all parsed assertions.
// This will console.log all assertion titles
tap$.assertions$
.map(function (assertion) {
return (assertion.ok ? 'OK: ' : 'NOT OK: ') + assertion
})
.forEach(console.log.bind(console))
The shape of the assertion object is as follows:
assertion
true/false
- indicates whether the assertion passed or failednot ok
, this will be information about the expected and actual values, etc. The TAP input will be YAML, but this value will always be an objectAn Observable of all output that is not tap. The parser assumes these are from console.log()
and treats them as comments.
// This will console.log all the comment titles
tap$.comments$
.map(function (comment) {
return 'COMMENT: ' + comment.title
})
.forEach(console.log.bind(console))
The shape of the comment object is as follows:
comment
An Observable of the parsed TAP results. This will only ever be of type tests
, pass
, or fail
.
// This will console.log the names and counts of the results
tap$.results$
.forEach(function (result) {
console.log(result.name + ' ' + result.count)
})
The shape of the result object is as follows:
# pass 3
)result
An Observable of all parsed plans given from TAP output. This is usually only one item.
// This will console.log the 'from' and 'to' from the plan
tap$.plans$
.forEach(function (plan) {
console.log('FROM: ' + plan.from')
console.log('TO: ' + plan.to')
})
The shape of the plan object is as follows:
1..7
)plan
1
An Observable of the parsed TAP version
// This will console.log the TAP version
tap$.versions$
.forEach(function (version) {
console.log(version.raw)
})
The shape of the version object is as follows:
TAP version 13
)version
Using require('@tap-format/parser').stream()
returns a new-line-chunked stream of parsed TAP. It is a normal stream, and therefore exposes the very useful pipe()
method.
git clone git@github.com:scottcorgan/tap-out.git .
npm install
npm test
FAQs
A highly verbose parser for the Test Anything Protocol that exposes an observable and streaming interface
The npm package @tap-format/parser receives a total of 146 weekly downloads. As such, @tap-format/parser popularity was classified as not popular.
We found that @tap-format/parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.