Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eavesdocker

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eavesdocker - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

7

CHANGELOG.md

@@ -8,2 +8,8 @@ # Eavesdocker Changelog

## [v0.1.1] - 2021-03-30
### Fixed
- api logs stream demultiplexing mishandling frame headers
- message trailing new line being preserved for non-json log entry
## [v0.1.0] - 2021-03-29

@@ -28,1 +34,2 @@

[v0.1.0]: https://gitlab.com/GCSBOSS/eavesdocker/-/tags/v0.1.0
[v0.1.1]: https://gitlab.com/GCSBOSS/eavesdocker/-/tags/v0.1.1

35

lib/docker.js
const http = require('http');
const { Transform } = require('stream');
const Cleanser = require('./cleanser');
const HEADER_LENGTH = 8;
class Demuxer extends Transform {
_transform (chunk, enc, cb) {
this.buffer = this.buffer
? Buffer.concat(this.buffer, chunk)
: Buffer.from(chunk);
if(this.buffer.length < HEADER_LENGTH)
return setTimeout(cb, 0);
let eol = HEADER_LENGTH + this.buffer.slice(0, HEADER_LENGTH).readUInt32BE(4);
if(this.buffer.length < eol)
return setTimeout(cb, 0);
const line = this.buffer.slice(HEADER_LENGTH, eol);
this.push(line, enc);
this.buffer = this.buffer.slice(eol);
return setTimeout(cb, 0);
}
}
module.exports = conf => ({

@@ -40,7 +63,7 @@

let cleanser = new Cleanser();
res.pipe(cleanser);
resolve(cleanser);
res.on('data', chunk => cb(chunk.toString('utf8')));
let demuxer = new Demuxer();
demuxer.setEncoding('utf8');
demuxer.on('data', cb);
res.pipe(demuxer);
resolve(demuxer);
});

@@ -47,0 +70,0 @@ req.on('error', reject);

2

lib/transport.js

@@ -70,3 +70,3 @@

catch(err){
json = { message: entry, time: new Date() };
json = { message: String(entry).replace(/\r?\n$/, ''), time: new Date() };
}

@@ -73,0 +73,0 @@

{
"name": "eavesdocker",
"version": "0.1.0",
"version": "0.1.1",
"main": "lib/main.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -50,3 +50,3 @@ const Docker = require('dockerode');

Image: 'mhart/alpine-node:slim-13',
Tty: true,
Tty: false,
Init: true,

@@ -63,6 +63,6 @@ Labels: debugLabels,

Image: 'mhart/alpine-node:slim-13',
Tty: true,
Tty: false,
Init: true,
Labels: debugLabels,
Cmd: [ 'node', '-e', 'setTimeout(() => process.stdout.write(Buffer.from(\'2834768\\r\\n\')), 2000);' +
Cmd: [ 'node', '-e', 'setTimeout(() => console.log(\'28234768\'), 2000);' +
'setTimeout(Function.prototype, 10000)']

@@ -305,3 +305,3 @@ });

let r = await db.collection('Log_Entries').find({});
assert.strictEqual((await r.toArray())[0].message, '2834768\r\r\n');
assert.strictEqual((await r.toArray())[0].message, '28234768');
await db.dropDatabase();

@@ -321,3 +321,3 @@ client.close();

let client = await redis(REDIS_CONF, 'roorar', async function(channel, data){
assert.strictEqual(JSON.parse(data).message, '2834768\r\r\n');
assert.strictEqual(JSON.parse(data).message, '28234768');
await sleep(5000);

@@ -324,0 +324,0 @@ await c.kill();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc