
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
handlebars-stream-render
Advanced tools
Plugin to stream out render blocks from handlebars
npm install handlebars-stream-render
We will use here a stream wrapper in order to simplify explanation
class HandlebarsStream extends Transform {
constructor(partials) {
super()
this.hbs = handlebars.create(this)
if (partials && partials.length) {
partials.forEach(p => this.hbs.registerPartial(p.name, p.content))
}
}
registerHelper(name, fn) {
return this.hbs.registerHelper(name, fn)
}
compile(content, data) {
this.result = this.hbs.compile(content)(data)
return this
}
_transform(chunk, enc, cb) {
this.push(chunk)
cb()
}
_final(cb) {
cb()
}
}
const hbs = new HandlebarsStream(),
expected = `<div class="names">
<ul>
<li>John, Q</li>
<li>John, McKlein</li>
<li>Susan, Morrison</li>
<li>Mick, Jagger</li>
</ul>
</div>`
hbs.compile(`
<div class="names">
<ul>
{{#each person}}
<li>{{firstName}}, {{lastName}}</li>
{{/each}}
</ul>
</div>
`, {
person: [
{ firstName: 'John', lastName: 'Q' },
{ firstName: 'John', lastName: 'McKlein' },
{ firstName: 'Susan', lastName: 'Morrison' },
{ firstName: 'Mick', lastName: 'Jagger' }
]
})
let result = ''
hbs.on('data', (block) => {
result += block.toString()
}).on('error', (e) => {
console.log('Error!!!', e)
done(e)
}).on('end', () => {
assert(result.trim() === expected.trim(), 'Templates are not the same')
done()
})
const timeout = ms => new Promise(res => setTimeout(res, ms))
const hbs = new HandlebarsStream()
hbs.registerHelper('delay', async function() {
await timeout(1000)
return 1000
})
hbs.compile('Delay {{#delay}}{{/delay}}', {})
let result = ''
hbs.on('data', (block) => {
result += block.toString()
}).on('error', (e) => {
console.log('Error!!!', e)
done(e)
}).on('end', () => {
assert(result.trim() === 'Delay 1000')
done()
})
const hbs = handlebars.create(),
tpl = hbs.compile('{{#each names}}<p>{{name}}</p>{{/each}}'),
result = await tpl({ names: [{ name: 'gaston' }, { name: 'pedro' }] })
assert(result, '<p>gaston</p><p>pedro</p>')
const hbs = handlebars.create()
hbs.registerHelper('delay', delay)
// eslint-disable-next-line one-var
const tpl = hbs.compile('Delay {{#delay}}{{/delay}}'),
result = await tpl()
assert(result, 'Delay 1000')
FAQs
Handlebars modification to work with stream outputs
The npm package handlebars-stream-render receives a total of 0 weekly downloads. As such, handlebars-stream-render popularity was classified as not popular.
We found that handlebars-stream-render 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.