@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,66 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Module dependencies.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
var sep = require('path').sep || '/';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Module exports.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
module.exports = fileUriToPath;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* File URI to Path function.
|
|
16
|
-
*
|
|
17
|
-
* @param {String} uri
|
|
18
|
-
* @return {String} path
|
|
19
|
-
* @api public
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
function fileUriToPath (uri) {
|
|
23
|
-
if ('string' != typeof uri ||
|
|
24
|
-
uri.length <= 7 ||
|
|
25
|
-
'file://' != uri.substring(0, 7)) {
|
|
26
|
-
throw new TypeError('must pass in a file:// URI to convert to a file path');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var rest = decodeURI(uri.substring(7));
|
|
30
|
-
var firstSlash = rest.indexOf('/');
|
|
31
|
-
var host = rest.substring(0, firstSlash);
|
|
32
|
-
var path = rest.substring(firstSlash + 1);
|
|
33
|
-
|
|
34
|
-
// 2. Scheme Definition
|
|
35
|
-
// As a special case, <host> can be the string "localhost" or the empty
|
|
36
|
-
// string; this is interpreted as "the machine from which the URL is
|
|
37
|
-
// being interpreted".
|
|
38
|
-
if ('localhost' == host) host = '';
|
|
39
|
-
|
|
40
|
-
if (host) {
|
|
41
|
-
host = sep + sep + host;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 3.2 Drives, drive letters, mount points, file system root
|
|
45
|
-
// Drive letters are mapped into the top of a file URI in various ways,
|
|
46
|
-
// depending on the implementation; some applications substitute
|
|
47
|
-
// vertical bar ("|") for the colon after the drive letter, yielding
|
|
48
|
-
// "file:///c|/tmp/test.txt". In some cases, the colon is left
|
|
49
|
-
// unchanged, as in "file:///c:/tmp/test.txt". In other cases, the
|
|
50
|
-
// colon is simply omitted, as in "file:///c/tmp/test.txt".
|
|
51
|
-
path = path.replace(/^(.+)\|/, '$1:');
|
|
52
|
-
|
|
53
|
-
// for Windows, we need to invert the path separators from what a URI uses
|
|
54
|
-
if (sep == '\\') {
|
|
55
|
-
path = path.replace(/\//g, '\\');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (/^.+\:/.test(path)) {
|
|
59
|
-
// has Windows drive at beginning of path
|
|
60
|
-
} else {
|
|
61
|
-
// unix path…
|
|
62
|
-
path = sep + path;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return host + path;
|
|
66
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "file-uri-to-path",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Convert a file: URI to a file path",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"directories": {
|
|
8
|
-
"test": "test"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"test": "mocha --reporter spec"
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git://github.com/TooTallNate/file-uri-to-path.git"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [
|
|
18
|
-
"file",
|
|
19
|
-
"uri",
|
|
20
|
-
"convert",
|
|
21
|
-
"path"
|
|
22
|
-
],
|
|
23
|
-
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/TooTallNate/file-uri-to-path/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/TooTallNate/file-uri-to-path",
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"mocha": "3"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
,"_resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz"
|
|
34
|
-
,"_integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
|
35
|
-
,"_from": "file-uri-to-path@1.0.0"
|
|
36
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var sep = require('path').sep || '/';
|
|
3
|
-
var assert = require('assert');
|
|
4
|
-
var uri2path = require('../');
|
|
5
|
-
var tests = require('./tests.json');
|
|
6
|
-
|
|
7
|
-
describe('file-uri-to-path', function () {
|
|
8
|
-
|
|
9
|
-
Object.keys(tests).forEach(function (uri) {
|
|
10
|
-
|
|
11
|
-
// the test cases were generated from Windows' PathCreateFromUrlA() function.
|
|
12
|
-
// On Unix, we have to replace the path separator with the Unix one instead of
|
|
13
|
-
// the Windows one.
|
|
14
|
-
var expected = tests[uri].replace(/\\/g, sep);
|
|
15
|
-
|
|
16
|
-
it('should convert ' + JSON.stringify(uri) + ' to ' + JSON.stringify(expected),
|
|
17
|
-
function () {
|
|
18
|
-
var actual = uri2path(uri);
|
|
19
|
-
assert.equal(actual, expected);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"file://host/path": "\\\\host\\path",
|
|
3
|
-
"file://localhost/etc/fstab": "\\etc\\fstab",
|
|
4
|
-
"file:///etc/fstab": "\\etc\\fstab",
|
|
5
|
-
"file:///c:/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
|
6
|
-
"file://localhost/c|/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
|
7
|
-
"file:///c|/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
|
8
|
-
"file://localhost/c:/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
|
9
|
-
"file://hostname/path/to/the%20file.txt": "\\\\hostname\\path\\to\\the file.txt",
|
|
10
|
-
"file:///c:/path/to/the%20file.txt": "c:\\path\\to\\the file.txt",
|
|
11
|
-
"file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc": "C:\\Documents and Settings\\davris\\FileSchemeURIs.doc",
|
|
12
|
-
"file:///C:/caf%C3%A9/%C3%A5r/d%C3%BCnn/%E7%89%9B%E9%93%83/Ph%E1%BB%9F/%F0%9F%98%B5.exe": "C:\\café\\år\\dünn\\牛铃\\Phở\\😵.exe"
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2010, Squeeks.
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
in the Software without restriction, including without limitation the rights
|
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
|
11
|
-
all copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
THE SOFTWARE.
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
glossy
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-
glossy aims to be a very generic yet powerful library for both producing and
|
|
5
|
-
also parsing raw syslog messages. The library aims to be capable of adhearing to
|
|
6
|
-
RFC 3164, RFC 5424 and RFC 5848 and by itself does no network interactions, it's
|
|
7
|
-
up to you to use this library as a syslog producer, a consumer, relay or
|
|
8
|
-
something else entirely. In addition, glossy has no dependencies and can be
|
|
9
|
-
bootstrapped to operate in browser or other non-node.js environments.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Parsing
|
|
13
|
-
-------
|
|
14
|
-
|
|
15
|
-
var syslogParser = require('glossy').Parse; // or wherever your glossy libs are
|
|
16
|
-
|
|
17
|
-
parsedMessage = syslogParser.parse(message);
|
|
18
|
-
|
|
19
|
-
parsedMessage will return an object containing as many parsed values as
|
|
20
|
-
possible, as well as the original message. The date value will be a Date object.
|
|
21
|
-
Structured data will return as an object. Alternatively, you can give it a
|
|
22
|
-
callback as your second argument:
|
|
23
|
-
|
|
24
|
-
syslogParser.parse(message, function(parsedMessage){
|
|
25
|
-
console.log(parsedMessage);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Producing
|
|
30
|
-
-------
|
|
31
|
-
Unless you stipulate for BSD/RFC 3164 style messages, it will default to
|
|
32
|
-
generating all messages as newer, RFC 5424 format. This might break consumers or
|
|
33
|
-
relays not expecting it.
|
|
34
|
-
|
|
35
|
-
var syslogProducer = require('glossy').Produce; // or wherever glossy lives
|
|
36
|
-
|
|
37
|
-
var msg = syslogProducer.produce({
|
|
38
|
-
facility: 'local4', // these can either be a valid integer,
|
|
39
|
-
severity: 'error', // or a relevant string
|
|
40
|
-
host: 'localhost',
|
|
41
|
-
appName: 'sudo',
|
|
42
|
-
pid: '123',
|
|
43
|
-
date: new Date(Date()),
|
|
44
|
-
message: 'Nice, Neat, New, Oh Wow'
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
Again, you can specify a callback for the second argument.
|
|
48
|
-
|
|
49
|
-
var msg = syslogProducer.produce({
|
|
50
|
-
facility: 'ntp',
|
|
51
|
-
severity: 'info',
|
|
52
|
-
host: 'localhost',
|
|
53
|
-
date: new Date(Date()),
|
|
54
|
-
message: 'Lunch Time!'
|
|
55
|
-
}, function(syslogMsg){
|
|
56
|
-
console.log(syslogMsg);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
In addition, you can also predefined most of the values when you create the
|
|
60
|
-
object, to save having to repeat yourself:
|
|
61
|
-
|
|
62
|
-
var syslogProducer = new require('glossy').Produce({
|
|
63
|
-
type: 'BSD',
|
|
64
|
-
facility: 'ftp',
|
|
65
|
-
pid: 42,
|
|
66
|
-
host: '::1'
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
For RFC5424 messages, you can also include structured data. Keys should comply
|
|
70
|
-
with the definition in [Section 7, RFC5424](http://tools.ietf.org/html/rfc5424#section-7)
|
|
71
|
-
regarding names - keep them unique and your own custom keys should have at least
|
|
72
|
-
an @ sign.
|
|
73
|
-
|
|
74
|
-
var msg = syslogProducer.produce({
|
|
75
|
-
facility: 'local4',
|
|
76
|
-
severity: 'error',
|
|
77
|
-
host: 'localhost',
|
|
78
|
-
appName: 'starman',
|
|
79
|
-
pid: '123',
|
|
80
|
-
date: new Date(Date()),
|
|
81
|
-
message: 'ACHTUNG!',
|
|
82
|
-
structuredData: {
|
|
83
|
-
'plack@host': {
|
|
84
|
-
status: 'broken',
|
|
85
|
-
hasTried: 'not really'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
Finally, we expose all the severities as functions themselves:
|
|
91
|
-
|
|
92
|
-
var infoMsg = glossy.info({
|
|
93
|
-
message: 'Info Message',
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
Function names facilitating this are named debug, info, notice, warn, crit,
|
|
97
|
-
alert and emergency.
|
|
98
|
-
|
|
99
|
-
Parsing Example
|
|
100
|
-
-------
|
|
101
|
-
Handle incoming syslog messages coming in on UDP port 514:
|
|
102
|
-
|
|
103
|
-
var syslogParser = require('glossy').Parse; // or wherever your glossy libs are
|
|
104
|
-
var dgram = require("dgram");
|
|
105
|
-
var server = dgram.createSocket("udp4");
|
|
106
|
-
|
|
107
|
-
server.on("message", function(rawMessage) {
|
|
108
|
-
syslogParser.parse(rawMessage.toString('utf8', 0), function(parsedMessage){
|
|
109
|
-
console.log(parsedMessage.host + ' - ' + parsedMessage.message);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
server.on("listening", function() {
|
|
114
|
-
var address = server.address();
|
|
115
|
-
console.log("Server now listening at " +
|
|
116
|
-
address.address + ":" + address.port);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
server.bind(514); // Remember ports < 1024 need suid
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
Author
|
|
123
|
-
-------
|
|
124
|
-
Squeeks - privacymyass@gmail.com
|
|
125
|
-
|
|
126
|
-
License
|
|
127
|
-
-------
|
|
128
|
-
This is free software licensed under the MIT License - see the LICENSE file that
|
|
129
|
-
should be included with this package.
|