@contrast/agent 4.5.1 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/VERSION +1 -1
- package/bin/linux/contrast-service +0 -0
- package/bin/mac/contrast-service +0 -0
- package/bin/windows/contrast-service.exe +0 -0
- package/lib/assess/membrane/deserialization-membrane.js +4 -5
- package/lib/assess/membrane/source-membrane.js +16 -33
- package/lib/assess/models/call-context.js +1 -1
- package/lib/assess/policy/propagators.json +19 -21
- package/lib/assess/policy/rules.json +7 -2
- package/lib/assess/policy/signatures.json +42 -0
- package/lib/assess/policy/util.js +2 -1
- package/lib/assess/propagators/JSON/parse.js +1 -1
- package/lib/assess/propagators/JSON/stringify.js +3 -3
- package/lib/assess/propagators/array-prototype-join.js +7 -8
- package/lib/assess/propagators/common.js +7 -5
- package/lib/assess/propagators/dustjs/escape-html.js +22 -0
- package/lib/assess/propagators/dustjs/escape-js.js +22 -0
- package/lib/assess/propagators/encode-uri/encode-uri-component.js +22 -0
- package/lib/assess/propagators/encode-uri/encode-uri.js +22 -0
- package/lib/assess/propagators/handlebars-escape-expresssion.js +1 -1
- package/lib/assess/propagators/index.js +0 -2
- package/lib/assess/propagators/joi/boolean.js +1 -1
- package/lib/assess/propagators/joi/expression.js +1 -1
- package/lib/assess/propagators/joi/number.js +1 -1
- package/lib/assess/propagators/joi/string-base.js +1 -1
- package/lib/assess/propagators/joi/string-schema.js +12 -13
- package/lib/assess/propagators/joi/values.js +37 -22
- package/lib/assess/propagators/manager.js +12 -10
- package/lib/assess/propagators/mongoose/helpers.js +20 -0
- package/lib/assess/propagators/mongoose/index.js +18 -0
- package/lib/assess/propagators/mongoose/map.js +74 -0
- package/lib/assess/propagators/mongoose/string.js +104 -0
- package/lib/assess/propagators/mustache/escape.js +22 -0
- package/lib/assess/propagators/number.js +54 -0
- package/lib/assess/propagators/object.js +6 -7
- package/lib/assess/propagators/path/basename.js +14 -13
- package/lib/assess/propagators/path/common.js +156 -47
- package/lib/assess/propagators/path/dirname.js +14 -13
- package/lib/assess/propagators/path/extname.js +14 -13
- package/lib/assess/propagators/path/join.js +5 -1
- package/lib/assess/propagators/path/normalize.js +1 -2
- package/lib/assess/propagators/path/parse.js +1 -1
- package/lib/assess/propagators/path/relative.js +7 -5
- package/lib/assess/propagators/path/resolve.js +11 -2
- package/lib/assess/propagators/querystring/escape.js +20 -18
- package/lib/assess/propagators/querystring/parse.js +7 -5
- package/lib/assess/propagators/querystring/stringify.js +25 -24
- package/lib/assess/propagators/querystring/unescape.js +20 -18
- package/lib/assess/propagators/sequelize/sql-string-escape.js +1 -1
- package/lib/assess/propagators/sequelize/sql-string-format-named-parameters.js +1 -1
- package/lib/assess/propagators/sequelize/sql-string-format.js +3 -3
- package/lib/assess/propagators/sequelize/utils.js +2 -2
- package/lib/assess/propagators/string-prototype-replace.js +30 -28
- package/lib/assess/propagators/string-prototype-split.js +36 -36
- package/lib/assess/propagators/string-prototype-trim.js +15 -17
- package/lib/assess/propagators/string.js +12 -16
- package/lib/assess/propagators/template-escape.js +87 -0
- package/lib/assess/propagators/templates.js +10 -11
- package/lib/assess/propagators/url/url-prototype-parse.js +5 -6
- package/lib/assess/propagators/url/url-url.js +51 -43
- package/lib/assess/propagators/util/format.js +1 -1
- package/lib/assess/propagators/v8/init-hooks.js +3 -3
- package/lib/assess/propagators/validator/init-hooks.js +22 -22
- package/lib/assess/sinks/common.js +10 -5
- package/lib/assess/sinks/dustjs-linkedin-xss.js +131 -0
- package/lib/assess/sinks/libxmljs-xxe.js +1 -1
- package/lib/assess/sinks/mongodb.js +2 -1
- package/lib/assess/sinks/ssrf-url.js +1 -1
- package/lib/constants.js +4 -1
- package/lib/core/arch-components/dynamodb.js +1 -2
- package/lib/core/arch-components/dynamodbv3.js +44 -0
- package/lib/core/arch-components/index.js +1 -0
- package/lib/core/arch-components/rethinkdb.js +53 -0
- package/lib/core/config/options.js +3 -2
- package/lib/core/rewrite/injections.js +8 -0
- package/lib/core/stacktrace.js +2 -1
- package/lib/feature-set.js +1 -1
- package/lib/hooks/frameworks/base.js +8 -2
- package/lib/hooks/frameworks/http.js +23 -16
- package/lib/hooks/frameworks/http2.js +73 -0
- package/lib/hooks/frameworks/index.js +8 -3
- package/lib/hooks/http.js +112 -128
- package/lib/hooks/object-to-primitive.js +6 -7
- package/lib/hooks/patcher.js +75 -44
- package/lib/hooks/require.js +16 -22
- package/lib/instrumentation.js +0 -3
- package/lib/protect/rules/nosqli/nosql-injection-rule.js +228 -0
- package/lib/protect/rules/rule-factory.js +2 -2
- package/lib/protect/service.js +23 -11
- package/lib/protect/sinks/mongodb.js +56 -55
- package/lib/reporter/translations/to-protobuf/dtm/index.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/ip-denylist-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/rasp-rule-sample.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/defend-features.js +8 -6
- package/lib/reporter/translations/to-protobuf/settings/exclusions.js +5 -4
- package/lib/tracker.js +13 -65
- package/lib/util/some.js +27 -0
- package/lib/util/source-map.js +1 -1
- package/package.json +15 -16
- package/lib/hooks/frameworks/https.js +0 -42
- package/lib/protect/rules/nosqli/no-sql-injection-rule.js +0 -109
- package/node_modules/bindings/LICENSE.md +0 -22
- package/node_modules/bindings/README.md +0 -98
- package/node_modules/bindings/bindings.js +0 -221
- package/node_modules/bindings/package.json +0 -32
- package/node_modules/file-uri-to-path/.npmignore +0 -1
- package/node_modules/file-uri-to-path/.travis.yml +0 -30
- package/node_modules/file-uri-to-path/History.md +0 -21
- package/node_modules/file-uri-to-path/LICENSE +0 -20
- package/node_modules/file-uri-to-path/README.md +0 -74
- package/node_modules/file-uri-to-path/index.d.ts +0 -2
- package/node_modules/file-uri-to-path/index.js +0 -66
- package/node_modules/file-uri-to-path/package.json +0 -36
- package/node_modules/file-uri-to-path/test/test.js +0 -24
- package/node_modules/file-uri-to-path/test/tests.json +0 -13
- package/node_modules/glossy/LICENSE +0 -19
- package/node_modules/glossy/README.md +0 -129
- package/node_modules/glossy/index.js +0 -12
- package/node_modules/glossy/lib/glossy/parse.js +0 -520
- package/node_modules/glossy/lib/glossy/produce.js +0 -459
- package/node_modules/glossy/package.json +0 -47
- package/node_modules/glossy/test/decide.js +0 -7
- package/node_modules/glossy/test/decode_pri.js +0 -24
- package/node_modules/glossy/test/parse_3164.js +0 -104
- package/node_modules/glossy/test/parse_5424.js +0 -106
- package/node_modules/glossy/test/parse_5848.js +0 -40
- package/node_modules/glossy/test/parse_8601.js +0 -14
- package/node_modules/glossy/test/parse_rfc3339.js +0 -9
- package/node_modules/glossy/test/produce.js +0 -162
- package/node_modules/glossy/test/runner.js +0 -40
- package/node_modules/glossy/test/structure_data.js +0 -24
- package/node_modules/nan/CHANGELOG.md +0 -537
- package/node_modules/nan/LICENSE.md +0 -13
- package/node_modules/nan/README.md +0 -455
- package/node_modules/nan/doc/asyncworker.md +0 -146
- package/node_modules/nan/doc/buffers.md +0 -54
- package/node_modules/nan/doc/callback.md +0 -76
- package/node_modules/nan/doc/converters.md +0 -41
- package/node_modules/nan/doc/errors.md +0 -226
- package/node_modules/nan/doc/json.md +0 -62
- package/node_modules/nan/doc/maybe_types.md +0 -583
- package/node_modules/nan/doc/methods.md +0 -664
- package/node_modules/nan/doc/new.md +0 -147
- package/node_modules/nan/doc/node_misc.md +0 -123
- package/node_modules/nan/doc/object_wrappers.md +0 -263
- package/node_modules/nan/doc/persistent.md +0 -296
- package/node_modules/nan/doc/scopes.md +0 -73
- package/node_modules/nan/doc/script.md +0 -38
- package/node_modules/nan/doc/string_bytes.md +0 -62
- package/node_modules/nan/doc/v8_internals.md +0 -199
- package/node_modules/nan/doc/v8_misc.md +0 -85
- package/node_modules/nan/include_dirs.js +0 -1
- package/node_modules/nan/nan.h +0 -2898
- package/node_modules/nan/nan_callbacks.h +0 -88
- package/node_modules/nan/nan_callbacks_12_inl.h +0 -514
- package/node_modules/nan/nan_callbacks_pre_12_inl.h +0 -520
- package/node_modules/nan/nan_converters.h +0 -72
- package/node_modules/nan/nan_converters_43_inl.h +0 -68
- package/node_modules/nan/nan_converters_pre_43_inl.h +0 -42
- package/node_modules/nan/nan_define_own_property_helper.h +0 -29
- package/node_modules/nan/nan_implementation_12_inl.h +0 -430
- package/node_modules/nan/nan_implementation_pre_12_inl.h +0 -263
- package/node_modules/nan/nan_json.h +0 -166
- package/node_modules/nan/nan_maybe_43_inl.h +0 -356
- package/node_modules/nan/nan_maybe_pre_43_inl.h +0 -268
- package/node_modules/nan/nan_new.h +0 -340
- package/node_modules/nan/nan_object_wrap.h +0 -156
- package/node_modules/nan/nan_persistent_12_inl.h +0 -132
- package/node_modules/nan/nan_persistent_pre_12_inl.h +0 -242
- package/node_modules/nan/nan_private.h +0 -73
- package/node_modules/nan/nan_string_bytes.h +0 -305
- package/node_modules/nan/nan_typedarray_contents.h +0 -96
- package/node_modules/nan/nan_weak.h +0 -437
- package/node_modules/nan/package.json +0 -41
- package/node_modules/nan/tools/1to2.js +0 -412
- package/node_modules/nan/tools/README.md +0 -14
- package/node_modules/nan/tools/package.json +0 -19
- package/node_modules/unix-dgram/LICENSE +0 -13
- package/node_modules/unix-dgram/README.md +0 -107
- package/node_modules/unix-dgram/binding.gyp +0 -20
- package/node_modules/unix-dgram/build/Makefile +0 -324
- package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram/src/unix_dgram.o.d +0 -58
- package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram.node.d +0 -1
- package/node_modules/unix-dgram/build/Release/.deps/Release/unix_dgram.node.d +0 -1
- package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram/src/unix_dgram.o +0 -0
- package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram.node +0 -0
- package/node_modules/unix-dgram/build/Release/unix_dgram.node +0 -0
- package/node_modules/unix-dgram/build/binding.Makefile +0 -6
- package/node_modules/unix-dgram/build/config.gypi +0 -213
- package/node_modules/unix-dgram/build/unix_dgram.target.mk +0 -159
- package/node_modules/unix-dgram/lib/unix_dgram.js +0 -168
- package/node_modules/unix-dgram/package.json +0 -36
- package/node_modules/unix-dgram/src/unix_dgram.cc +0 -404
- package/node_modules/unix-dgram/src/win_dummy.cc +0 -7
- package/node_modules/unix-dgram/test/test-connect-callback.js +0 -68
- package/node_modules/unix-dgram/test/test-connect.js +0 -53
- package/node_modules/unix-dgram/test/test-dgram-unix.js +0 -58
- package/node_modules/unix-dgram/test/test-send-error.js +0 -26
- package/node_modules/winston-syslog/.eslintrc +0 -7
- package/node_modules/winston-syslog/.travis.yml +0 -14
- package/node_modules/winston-syslog/CHANGELOG.md +0 -9
- package/node_modules/winston-syslog/LICENSE +0 -20
- package/node_modules/winston-syslog/README.md +0 -135
- package/node_modules/winston-syslog/lib/utils.js +0 -26
- package/node_modules/winston-syslog/lib/winston-syslog.js +0 -385
- package/node_modules/winston-syslog/package.json +0 -56
- package/node_modules/winston-syslog/test/format-test.js +0 -122
- package/node_modules/winston-syslog/test/syslog-test.js +0 -95
- package/node_modules/winston-syslog/test/unix-connect-test.js +0 -133
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const vows = require('vows');
|
|
4
|
-
const assert = require('assert');
|
|
5
|
-
const winston = require('winston');
|
|
6
|
-
const dgram = require('dgram');
|
|
7
|
-
const parser = require('glossy').Parse;
|
|
8
|
-
|
|
9
|
-
const PORT = 11229;
|
|
10
|
-
let server;
|
|
11
|
-
let transport;
|
|
12
|
-
|
|
13
|
-
const { MESSAGE, LEVEL } = require('triple-beam');
|
|
14
|
-
|
|
15
|
-
vows.describe('syslog messages').addBatch({
|
|
16
|
-
'opening fake syslog server': {
|
|
17
|
-
'topic': function () {
|
|
18
|
-
const self = this;
|
|
19
|
-
server = dgram.createSocket('udp4');
|
|
20
|
-
server.on('listening', function () {
|
|
21
|
-
self.callback();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
server.bind(PORT);
|
|
25
|
-
},
|
|
26
|
-
'default format': {
|
|
27
|
-
'topic': function () {
|
|
28
|
-
const self = this;
|
|
29
|
-
server.once('message', function (msg) {
|
|
30
|
-
parser.parse(msg, function (d) {
|
|
31
|
-
self.callback(null, d);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
transport = new winston.transports.Syslog({
|
|
36
|
-
port: PORT
|
|
37
|
-
});
|
|
38
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: 'ping' }, function (err) {
|
|
39
|
-
assert.ifError(err);
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
'should have host field set to localhost': function (msg) {
|
|
43
|
-
assert.equal(msg.host, 'localhost');
|
|
44
|
-
transport.close();
|
|
45
|
-
},
|
|
46
|
-
'setting locahost option to a different falsy value (null)': {
|
|
47
|
-
'topic': function () {
|
|
48
|
-
const self = this;
|
|
49
|
-
server.once('message', function (msg) {
|
|
50
|
-
parser.parse(msg, function (d) {
|
|
51
|
-
self.callback(null, d);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
transport = new winston.transports.Syslog({
|
|
56
|
-
port: PORT,
|
|
57
|
-
localhost: null
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: 'ping2' }, function (err) {
|
|
61
|
-
assert.ifError(err);
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
'should have host different from localhost': function (msg) {
|
|
65
|
-
assert.notEqual(msg.host, 'localhost');
|
|
66
|
-
transport.close();
|
|
67
|
-
},
|
|
68
|
-
'setting appName option to hello': {
|
|
69
|
-
'topic': function () {
|
|
70
|
-
const self = this;
|
|
71
|
-
server.once('message', function (msg) {
|
|
72
|
-
parser.parse(msg, function (d) {
|
|
73
|
-
self.callback(null, d);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
transport = new winston.transports.Syslog({
|
|
78
|
-
port: PORT,
|
|
79
|
-
type: '5424',
|
|
80
|
-
appName: 'hello'
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: 'app name test' }, function (err) {
|
|
84
|
-
assert.ifError(err);
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
'should have appName field set to hello': function (msg) {
|
|
88
|
-
assert.equal(msg.appName, 'hello');
|
|
89
|
-
transport.close();
|
|
90
|
-
},
|
|
91
|
-
'setting app_name option to hello': {
|
|
92
|
-
'topic': function () {
|
|
93
|
-
const self = this;
|
|
94
|
-
server.once('message', function (msg) {
|
|
95
|
-
parser.parse(msg, function (d) {
|
|
96
|
-
self.callback(null, d);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
transport = new winston.transports.Syslog({
|
|
101
|
-
port: PORT,
|
|
102
|
-
type: '5424',
|
|
103
|
-
app_name: 'hello'
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: 'app name test' }, function (err) {
|
|
107
|
-
assert.ifError(err);
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
'should have appName field set to hello': function (msg) {
|
|
111
|
-
assert.equal(msg.appName, 'hello');
|
|
112
|
-
transport.close();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
'teardown': function () {
|
|
119
|
-
server.close();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}).export(module);
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/* eslint new-cap: ["error", { "newIsCapExceptions": ["createLogger"] }] */
|
|
2
|
-
/*
|
|
3
|
-
* syslog-test.js: Tests for instances of the Syslog transport
|
|
4
|
-
*
|
|
5
|
-
* (C) 2010 Charlie Robbins
|
|
6
|
-
* MIT LICENSE
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const vows = require('vows');
|
|
11
|
-
const assert = require('assert');
|
|
12
|
-
const winston = require('winston');
|
|
13
|
-
const Syslog = require('../lib/winston-syslog').Syslog;
|
|
14
|
-
|
|
15
|
-
function assertSyslog(transport) {
|
|
16
|
-
assert.instanceOf(transport, Syslog);
|
|
17
|
-
assert.isFunction(transport.log);
|
|
18
|
-
assert.isFunction(transport.connect);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function closeTopicInfo() {
|
|
22
|
-
const transport = new winston.transports.Syslog();
|
|
23
|
-
const logger = new winston.createLogger({ transports: [transport] });
|
|
24
|
-
|
|
25
|
-
logger.log('info', 'Test message to actually use socket');
|
|
26
|
-
logger.remove(transport);
|
|
27
|
-
|
|
28
|
-
return transport;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function closeTopicDebug() {
|
|
32
|
-
const transport = new winston.transports.Syslog();
|
|
33
|
-
const logger = new winston.createLogger({ transports: [transport] });
|
|
34
|
-
|
|
35
|
-
logger.log('debug', 'Test message to actually use socket');
|
|
36
|
-
logger.remove(transport);
|
|
37
|
-
|
|
38
|
-
return transport;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const transport = new Syslog();
|
|
42
|
-
|
|
43
|
-
vows.describe('winston-syslog').addBatch({
|
|
44
|
-
'An instance of the Syslog Transport': {
|
|
45
|
-
'should have the proper methods defined': function () {
|
|
46
|
-
assertSyslog(transport);
|
|
47
|
-
},
|
|
48
|
-
'teardown': function () {
|
|
49
|
-
transport.close();
|
|
50
|
-
},
|
|
51
|
-
'on close after not really writing': {
|
|
52
|
-
topic: closeTopicDebug,
|
|
53
|
-
on: {
|
|
54
|
-
closed: {
|
|
55
|
-
'closes the socket': function (socket) {
|
|
56
|
-
assert.isNull(socket);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
'on close after really writing': {
|
|
62
|
-
topic: closeTopicInfo,
|
|
63
|
-
on: {
|
|
64
|
-
closed: {
|
|
65
|
-
'closes the socket': function (socket) {
|
|
66
|
-
assert.isNull(socket._handle);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
'localhost option': {
|
|
72
|
-
'should default to localhost': function () {
|
|
73
|
-
const transportLocal = new winston.transports.Syslog();
|
|
74
|
-
assert.equal(transportLocal.localhost, 'localhost');
|
|
75
|
-
transportLocal.close();
|
|
76
|
-
},
|
|
77
|
-
'should accept other falsy entries as valid': function () {
|
|
78
|
-
let transportNotLocal = new winston.transports.Syslog({ localhost: null });
|
|
79
|
-
assert.isNull(transportNotLocal.localhost);
|
|
80
|
-
transportNotLocal.close();
|
|
81
|
-
transportNotLocal = new winston.transports.Syslog({ localhost: false });
|
|
82
|
-
assert.equal(transportNotLocal.localhost, false);
|
|
83
|
-
transportNotLocal.close();
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
'adding / removing transport to syslog': {
|
|
87
|
-
'should just work': function () {
|
|
88
|
-
winston.add(new winston.transports.Syslog());
|
|
89
|
-
winston.remove(new winston.transports.Syslog());
|
|
90
|
-
winston.add(new winston.transports.Syslog());
|
|
91
|
-
winston.remove(new winston.transports.Syslog());
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}).export(module);
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/* eslint no-sync: "off" */
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const vows = require('vows');
|
|
5
|
-
const assert = require('assert');
|
|
6
|
-
const unix = require('unix-dgram');
|
|
7
|
-
const parser = require('glossy').Parse;
|
|
8
|
-
const Syslog = require('../lib/winston-syslog').Syslog;
|
|
9
|
-
|
|
10
|
-
const { MESSAGE, LEVEL } = require('triple-beam');
|
|
11
|
-
|
|
12
|
-
const SOCKNAME = '/tmp/unix_dgram.sock';
|
|
13
|
-
|
|
14
|
-
const transport = new Syslog({
|
|
15
|
-
protocol: 'unix-connect',
|
|
16
|
-
path: SOCKNAME
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
fs.unlinkSync(SOCKNAME);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
/* swallow */
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let times = 0;
|
|
26
|
-
let server;
|
|
27
|
-
|
|
28
|
-
vows.describe('unix-connect').addBatch({
|
|
29
|
-
'Trying to log to a non-existant log server': {
|
|
30
|
-
'topic': function () {
|
|
31
|
-
const self = this;
|
|
32
|
-
transport.once('error', function (err) {
|
|
33
|
-
self.callback(null, err);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: `data${++times}` }, function (err) {
|
|
37
|
-
assert(err);
|
|
38
|
-
assert.equal(err.syscall, 'connect');
|
|
39
|
-
assert.equal(transport.queue.length, 1);
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
'should enqueue the log message': function (err) {
|
|
43
|
-
assert(err);
|
|
44
|
-
assert.equal(err.syscall, 'connect');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}).addBatch({
|
|
48
|
-
'Logging when log server is up': {
|
|
49
|
-
'topic': function () {
|
|
50
|
-
const self = this;
|
|
51
|
-
let n = 0;
|
|
52
|
-
server = unix.createSocket('unix_dgram', function (buf) {
|
|
53
|
-
parser.parse(buf, function (d) {
|
|
54
|
-
++n;
|
|
55
|
-
assert(n <= 2);
|
|
56
|
-
assert.equal(d.message, 'node[' + process.pid + ']: data' + n);
|
|
57
|
-
assert.equal(d.severity, 'debug');
|
|
58
|
-
if (n === 2) {
|
|
59
|
-
self.callback();
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
server.bind(SOCKNAME);
|
|
65
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: `data${++times}` }, function (err) {
|
|
66
|
-
assert.ifError(err);
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
'should print both the enqueed and the new msg': function (err) {
|
|
70
|
-
assert.ifError(err);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}).addBatch({
|
|
74
|
-
'Logging if server goes down again': {
|
|
75
|
-
'topic': function () {
|
|
76
|
-
const self = this;
|
|
77
|
-
transport.once('error', function (err) {
|
|
78
|
-
self.callback(null, err);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
server.close();
|
|
82
|
-
|
|
83
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: `data${++times}` }, function (err) {
|
|
84
|
-
assert.ifError(err);
|
|
85
|
-
assert.equal(transport.queue.length, 1);
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
'should enqueue the log message': function (err) {
|
|
89
|
-
assert(err);
|
|
90
|
-
assert.equal(err.syscall, 'send');
|
|
91
|
-
transport.close();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}).addBatch({
|
|
95
|
-
'Logging works if server comes up again': {
|
|
96
|
-
'topic': function () {
|
|
97
|
-
const self = this;
|
|
98
|
-
transport.once('error', function (err) {
|
|
99
|
-
// Ignore error -- server hasn't come up yet, that's fine/expected
|
|
100
|
-
assert(err);
|
|
101
|
-
assert.equal(err.syscall, 'send');
|
|
102
|
-
});
|
|
103
|
-
let n = 2;
|
|
104
|
-
try {
|
|
105
|
-
fs.unlinkSync(SOCKNAME);
|
|
106
|
-
} catch (e) {
|
|
107
|
-
/* swallow */
|
|
108
|
-
}
|
|
109
|
-
server = unix.createSocket('unix_dgram', function (buf) {
|
|
110
|
-
parser.parse(buf, function (d) {
|
|
111
|
-
++n;
|
|
112
|
-
assert(n <= 4);
|
|
113
|
-
assert.equal(d.message, 'node[' + process.pid + ']: data' + n);
|
|
114
|
-
if (n === 4) {
|
|
115
|
-
self.callback();
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
server.bind(SOCKNAME);
|
|
121
|
-
transport.log({ [LEVEL]: 'debug', [MESSAGE]: `data${++times}` }, function (err) {
|
|
122
|
-
assert.ifError(err);
|
|
123
|
-
});
|
|
124
|
-
return null;
|
|
125
|
-
},
|
|
126
|
-
'should print both the enqueed and the new msg': function (err) {
|
|
127
|
-
assert.ifError(err);
|
|
128
|
-
server.close();
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
}).export(module);
|