🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

docker-stream-cleanser

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docker-stream-cleanser - npm Package Compare versions

Comparing version

to
0.3.0

20

index.js

@@ -13,5 +13,7 @@ 'use strict';

* @param {string} encoding stream data encoding
* @param {string} ignoreErrors true if errors should just be streamed through
* @param {string} logErrors true if errors should be logged to the console
* @return {DuplexStream} pipe docker stream data through this duplex stream to remove headers
*/
function createCleanserStream (encoding) {
function createCleanserStream (encoding, ignoreErrors, logErrors) {
encoding = encoding || 'utf8'; // utf8 is buffer default

@@ -22,2 +24,3 @@ var buffer = new Buffer('', encoding);

var errored;
var allowErrors = !ignoreErrors;

@@ -44,4 +47,11 @@ function write (data) {

if (currentType > 2) {
errored = true;
return self.emit('error', new Error('Recieved unexpected type in header: '+currentType));
errored = allowErrors;
buffer = Buffer.concat([header, buffer]);
bytesLeft = buffer.length;
if (logErrors) {
console.log('ERROR IN DSC:', buffer.toString());
}
if (allowErrors) {
self.emit('error', new Error('received unexpected type in header: ' + currentType));
}
}

@@ -76,4 +86,4 @@ if (bytesLeft === 0) { // this reset is not necessary, but it is more explicit

if (errored) { return; }
if (buffer.length) {
this.emit('error', new Error('End event recieved but buffer still has data'));
if (buffer.length && allowErrors) {
this.emit('error', new Error('End event received but buffer still has data'));
}

@@ -80,0 +90,0 @@ else {

{
"name": "docker-stream-cleanser",
"version": "0.2.0",
"version": "0.3.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "description": "This module cleans the docker headers from the log stream from a container. I never found them very useful, so I wrote this to clean them up either in bulk, or in between a piping. It's not as simple as just removing the first 8 bytes on every message",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet