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

nsyslog-parser

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nsyslog-parser - npm Package Compare versions

Comparing version 0.8.3 to 0.8.4

32

dist/nsyslog-parser.js
"use strict";
(function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
var a = typeof require == "function" && require;if (!u && a) return a(o, !0);if (i) return i(o, !0);var f = new Error("Cannot find module '" + o + "'");throw f.code = "MODULE_NOT_FOUND", f;
}var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) {
var n = t[o][1][e];return s(n ? n : e);
}, l, l.exports, e, t, n, r);
}return n[o].exports;
}var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) {
s(r[o]);
}return s;
})({ 1: [function (require, module, exports) {
(function () {
function r(e, n, t) {
function o(i, f) {
if (!n[i]) {
if (!e[i]) {
var c = "function" == typeof require && require;if (!f && c) return c(i, !0);if (u) return u(i, !0);var a = new Error("Cannot find module '" + i + "'");throw a.code = "MODULE_NOT_FOUND", a;
}var p = n[i] = { exports: {} };e[i][0].call(p.exports, function (r) {
var n = e[i][1][r];return o(n || r);
}, p, p.exports, r, e, n, t);
}return n[i].exports;
}for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
o(t[i]);
}return o;
}return r;
})()({ 1: [function (require, module, exports) {
"use strict";

@@ -116,7 +118,7 @@

"prival": /<(\d+)>/,
"month": /^[a-zA-Z]{3} /,
"month": /^[A-Z][a-z]{2} /,
"day": /^\d{1,2} /,
"time": /^\d+:\d+:\d+ /,
"ts": /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\S+ /,
"invalid": /[^a-zA-Z0-9\.\$\-_#%\/\[\]]/,
"invalid": /[^a-zA-Z0-9\.\$\-_#%\/\[\]\(\)]/,
"sdata": /\[(\S+)( [^\=]+\=\"[^\"]+\")+\]/g,

@@ -123,0 +125,0 @@ "cef": /^CEF:\d+/

@@ -1,3 +0,3 @@

/*! nsyslog-parser 2018-08-06 */
/*! nsyslog-parser 2018-08-27 */
"use strict";!function e(i,t,l){function a(s,n){if(!t[s]){if(!i[s]){var o="function"==typeof require&&require;if(!n&&o)return o(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=t[s]={exports:{}};i[s][0].call(d.exports,function(e){var t=i[s][1][e];return a(t||e)},d,d.exports,e,i,t,l)}return t[s].exports}for(var r="function"==typeof require&&require,s=0;s<l.length;s++)a(l[s]);return a}({1:[function(e,i,t){!function(i){var t=e("./parser.js");i.NSyslog=i.NSyslog||{},i.NSyslog.parse=t}(window)},{"./parser.js":3}],2:[function(e,i,t){function l(e){var i=[],t={},l=!1,a=7,r="";return e.split("").forEach(function(e){a?"|"==e?l?(l=!1,r+=e):(i.push(r),r="",a--):"\\"==e?(r+=e,l=!l):(l=!1,r+=e):r+=e}),r.length&&i.push(r),s.forEach(function(e,l){return t[e]=i[l]}),t}function a(e){var i=[],t={},l=null;do{if(l=r.exec(e)){var a=l[0],s=l.index;i.length&&(i[i.length-1]+=e.substring(0,s)),i.push(a),e=e.substring(s+a.length)}else e.length&&i.length&&(i[i.length-1]+=e,e="")}while(l&&e.length);return i.map(function(e){return e.trim()}).map(function(e){return e=e.split("="),{k:e.shift(),v:e.join("=")}}).forEach(function(e){t[e.k]=e.v}),t}var r=/[a-zA-Z][a-zA-Z0-9]+=/,s=["version","deviceVendor","deviceProduct","deviceVersion","deviceEventClassID","name","severity","extension"];i.exports={parse:function(e){var i=l(e);return{headers:i,fields:a(i.extension||"")}}}},{}],3:[function(e,i,t){function l(e){do{var i=e.shift();if(void 0===i)return i;i=i.trim()}while(!i);return i}function a(e,i){if(e.host)if(e.appName)if(e.pid){if(e.messageid)return!!e.structuredData||(e.structuredData=i.trim(),!1);e.messageid=i.trim()}else e.pid=i.trim();else e.appName=i.trim();else e.host=i.trim()}function r(e){var i=e.match(o.pri),t={originalMessage:e};if(i){t.pri=i[0],t.prival=parseInt(t.pri.match(o.prival)[1]);var r=s.get(t.prival);t.facilityval=r.facility,t.levelval=r.level,t.facility=s.FACILITY[r.facility].id,t.level=s.LEVEL[r.level].id}else t.pri="",t.prival=NaN;for(var c=e.substring(t.pri.length).split(" "),d=!1;e.length&&!d;){if((h=l(c)+" ").match(o.prinmr))t.version=parseInt(h),t.type="RFC5424",(h=l(c)+" ").match(o.ts)&&(t.ts=new Date(Date.parse(h.match(o.ts)[0].trim())));else if(h.match(o.month)){t.type="BSD";var u=h.trim(),f=l(c),p=l(c),m=(new Date).getYear()+1900;t.ts=new Date(Date.parse(m+" "+u+" "+f+" "+p))}else t.type="UNKNOWN",c.unshift(h.trim());d=!0}if(t.ts||(t.ts=new Date),t.type){var g=function(e){c.unshift(e),t.message=c.join(" "),d=!0};for(d=!1;e.length&&!d;){var h=l(c);if(h)if(h.endsWith(":")){var v=h.replace(/:$/,"").trim();v.match(o.invalid)?g(h):(a(t,v),t.message=c.join(" "),d=!0)}else if(c.length)if(h.match(o.invalid))g(h);else{var y=a(t,h.replace(/: $/,"").trim());!0===y?(c.unshift(h),t.message=c.join(" "),d=!0):!1===y&&(t.message=c.join(" "),d=!0)}else g(h);else d=!0}}else t.message=c.join(" ");if(t.chain=(t.host||"").split("/"),t.host=t.chain.pop(),"RFC5424"==t.type){var b=t.message.match(o.sdata)||[],E=0;t.structuredData=b.map(function(e){var i={},l=null;return E=t.message.indexOf(e)+e.length+1,e.replace(/(^\[)|(\]$)/g,"").split(" ").forEach(function(e,t){if(e.trim())if(0==t)i.$id=e;else{var a=e.split("=");a[0]&&a[1]&&'"'!=a[1]?(l=a.shift(),i[l]=a.join("=").replace(/\"/g,"")):a[0]&&void 0===a[1]?i[l]+=" "+(a[0]||"").replace(/\"/g,""):!a[0]||a[1].length&&'"'!=a[1]||(i[l]+=" "+(a[0]||"").replace(/\"/g,"")+"=")}}),i}),t.message=t.message.substring(E)}if(o.cef.test(t.message)){t.type="CEF";var x=n.parse(t.message);t.cef=x.headers,t.fields=x.fields}else{var w=[];t.message.split(",").forEach(function(e){var i=e.split("=");2==i.length&&(w[i[0]]=i[1])}),t.fields=w}return t.header=e.substring(0,e.length-t.message.length),t}var s=e("./pri.js"),n=e("./cef.js"),o={pri:/^<\d+>/,prinmr:/^\d+ /,prival:/<(\d+)>/,month:/^[a-zA-Z]{3} /,day:/^\d{1,2} /,time:/^\d+:\d+:\d+ /,ts:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\S+ /,invalid:/[^a-zA-Z0-9\.\$\-_#%\/\[\]]/,sdata:/\[(\S+)( [^\=]+\=\"[^\"]+\")+\]/g,cef:/^CEF:\d+/};i.exports=function(e){try{return r(e)}catch(e){return{err:e}}}},{"./cef.js":2,"./pri.js":4}],4:[function(e,i,t){var l=[{id:"kern",label:"kernel messages"},{id:"user",label:"user-level messages"},{id:"mail",label:"mail system"},{id:"daemon",label:"system daemons"},{id:"auth",label:"security/authorization messages"},{id:"syslog",label:"messages generated internally by syslogd"},{id:"lpr",label:"line printer subsystem"},{id:"news",label:"network news subsystem"},{id:"uucp",label:"UUCP subsystem"},{id:"cron",label:"clock daemon"},{id:"authpriv",label:"security/authorization messages"},{id:"ftp",label:"FTP daemon"},{id:"ntp",label:"NTP subsystem"},{id:"security",label:"log audit"},{id:"console",label:"log alert"},{id:"solaris-cron",label:"clock daemon"},{id:"local0",label:"locally used facility 0"},{id:"local1",label:"locally used facility 0"},{id:"local2",label:"locally used facility 0"},{id:"local3",label:"locally used facility 0"},{id:"local4",label:"locally used facility 0"},{id:"local5",label:"locally used facility 0"},{id:"local6",label:"locally used facility 0"},{id:"local7",label:"locally used facility 0"}],a=[{id:"emerg",label:"system is unusable"},{id:"alert",label:"action must be taken immediately"},{id:"crit",label:"critical conditions"},{id:"error",label:"error conditions"},{id:"warn",label:"warning conditions"},{id:"notice",label:"normal but significant condition"},{id:"info",label:"informational messages"},{id:"debug",label:"debug-level messages"}],r=[],s=[];l.forEach(function(e,i){return r[e.id]=i}),a.forEach(function(e,i){return s[e.id]=i}),i.exports.LEVEL=a,i.exports.FACILITY=l,i.exports.LEVELS=s,i.exports.FACILITIES=r,i.exports.get=function(e,i){return"number"==typeof e&&void 0===i?{level:7&e,facility:e>>3}:"number"==typeof e&&"number"==typeof i?8*e+i:"string"==typeof e&&"number"==typeof i?8*(r[e]||0)+i:"number"==typeof e&&"string"==typeof i?8*e+(s[i]||0):"string"==typeof e&&"string"==typeof i?8*(r[e]||0)+(s[i]||0):{level:0,facility:0}}},{}]},{},[1]);
"use strict";!function r(s,n,o){function c(i,e){if(!n[i]){if(!s[i]){var t="function"==typeof require&&require;if(!e&&t)return t(i,!0);if(d)return d(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var a=n[i]={exports:{}};s[i][0].call(a.exports,function(e){return c(s[i][1][e]||e)},a,a.exports,r,s,n,o)}return n[i].exports}for(var d="function"==typeof require&&require,e=0;e<o.length;e++)c(o[e]);return c}({1:[function(e,i,t){var l,a;l=window,a=e("./parser.js"),l.NSyslog=l.NSyslog||{},l.NSyslog.parse=a},{"./parser.js":3}],2:[function(e,i,t){var n=/[a-zA-Z][a-zA-Z0-9]+=/,o=["version","deviceVendor","deviceProduct","deviceVersion","deviceEventClassID","name","severity","extension"];i.exports={parse:function(e){var t,l,i,a,r,s=(t=[],i=!(l={}),a=7,r="",e.split("").forEach(function(e){a?"|"==e?i?(i=!1,r+=e):(t.push(r),r="",a--):"\\"==e?(r+=e,i=!i):(i=!1,r+=e):r+=e}),r.length&&t.push(r),o.forEach(function(e,i){return l[e]=t[i]}),l);return{headers:s,fields:function(e){var i=[],t={},l=null;do{if(l=n.exec(e)){var a=l[0],r=l.index;i.length&&(i[i.length-1]+=e.substring(0,r)),i.push(a),e=e.substring(r+a.length)}else e.length&&i.length&&(i[i.length-1]+=e,e="")}while(l&&e.length);return i.map(function(e){return e.trim()}).map(function(e){return{k:(e=e.split("=")).shift(),v:e.join("=")}}).forEach(function(e){t[e.k]=e.v}),t}(s.extension||"")}}}},{}],3:[function(e,i,t){var v=e("./pri.js"),b=e("./cef.js"),E={pri:/^<\d+>/,prinmr:/^\d+ /,prival:/<(\d+)>/,month:/^[A-Z][a-z]{2} /,day:/^\d{1,2} /,time:/^\d+:\d+:\d+ /,ts:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\S+ /,invalid:/[^a-zA-Z0-9\.\$\-_#%\/\[\]\(\)]/,sdata:/\[(\S+)( [^\=]+\=\"[^\"]+\")+\]/g,cef:/^CEF:\d+/};function x(e){do{var i=e.shift();if(void 0===i)return i;i=i.trim()}while(!i);return i}function w(e,i){if(e.host)if(e.appName)if(e.pid){if(e.messageid)return!!e.structuredData||(e.structuredData=i.trim(),!1);e.messageid=i.trim()}else e.pid=i.trim();else e.appName=i.trim();else e.host=i.trim()}i.exports=function(e){try{return function(e){var i=e.match(E.pri),t={originalMessage:e};if(i){t.pri=i[0],t.prival=parseInt(t.pri.match(E.prival)[1]);var l=v.get(t.prival);t.facilityval=l.facility,t.levelval=l.level,t.facility=v.FACILITY[l.facility].id,t.level=v.LEVEL[l.level].id}else t.pri="",t.prival=NaN;for(var a=e.substring(t.pri.length).split(" "),r=!1;e.length&&!r;){if((u=x(a)+" ").match(E.prinmr))t.version=parseInt(u),t.type="RFC5424",(u=x(a)+" ").match(E.ts)&&(t.ts=new Date(Date.parse(u.match(E.ts)[0].trim())));else if(u.match(E.month)){t.type="BSD";var s=u.trim(),n=x(a),o=x(a),c=(new Date).getYear()+1900;t.ts=new Date(Date.parse(c+" "+s+" "+n+" "+o))}else t.type="UNKNOWN",a.unshift(u.trim());r=!0}if(t.ts||(t.ts=new Date),t.type){var d=function(e){a.unshift(e),t.message=a.join(" "),r=!0};for(r=!1;e.length&&!r;){var u;if(u=x(a))if(u.endsWith(":")){var f=u.replace(/:$/,"").trim();f.match(E.invalid)?d(u):(w(t,f),t.message=a.join(" "),r=!0)}else if(a.length)if(u.match(E.invalid))d(u);else{var p=w(t,u.replace(/: $/,"").trim());!0===p?(a.unshift(u),t.message=a.join(" "),r=!0):!1===p&&(t.message=a.join(" "),r=!0)}else d(u);else r=!0}}else t.message=a.join(" ");if(t.chain=(t.host||"").split("/"),t.host=t.chain.pop(),"RFC5424"==t.type){var m=t.message.match(E.sdata)||[],g=0;t.structuredData=m.map(function(e){var l={},a=null;return g=t.message.indexOf(e)+e.length+1,e.replace(/(^\[)|(\]$)/g,"").split(" ").forEach(function(e,i){if(e.trim())if(0==i)l.$id=e;else{var t=e.split("=");t[0]&&t[1]&&'"'!=t[1]?(a=t.shift(),l[a]=t.join("=").replace(/\"/g,"")):t[0]&&void 0===t[1]?l[a]+=" "+(t[0]||"").replace(/\"/g,""):!t[0]||t[1].length&&'"'!=t[1]||(l[a]+=" "+(t[0]||"").replace(/\"/g,"")+"=")}}),l}),t.message=t.message.substring(g)}if(E.cef.test(t.message)){t.type="CEF";var h=b.parse(t.message);t.cef=h.headers,t.fields=h.fields}else{var y=[];t.message.split(",").forEach(function(e){var i=e.split("=");2==i.length&&(y[i[0]]=i[1])}),t.fields=y}return t.header=e.substring(0,e.length-t.message.length),t}(e)}catch(e){return{err:e}}}},{"./cef.js":2,"./pri.js":4}],4:[function(e,i,t){var l=[{id:"kern",label:"kernel messages"},{id:"user",label:"user-level messages"},{id:"mail",label:"mail system"},{id:"daemon",label:"system daemons"},{id:"auth",label:"security/authorization messages"},{id:"syslog",label:"messages generated internally by syslogd"},{id:"lpr",label:"line printer subsystem"},{id:"news",label:"network news subsystem"},{id:"uucp",label:"UUCP subsystem"},{id:"cron",label:"clock daemon"},{id:"authpriv",label:"security/authorization messages"},{id:"ftp",label:"FTP daemon"},{id:"ntp",label:"NTP subsystem"},{id:"security",label:"log audit"},{id:"console",label:"log alert"},{id:"solaris-cron",label:"clock daemon"},{id:"local0",label:"locally used facility 0"},{id:"local1",label:"locally used facility 0"},{id:"local2",label:"locally used facility 0"},{id:"local3",label:"locally used facility 0"},{id:"local4",label:"locally used facility 0"},{id:"local5",label:"locally used facility 0"},{id:"local6",label:"locally used facility 0"},{id:"local7",label:"locally used facility 0"}],a=[{id:"emerg",label:"system is unusable"},{id:"alert",label:"action must be taken immediately"},{id:"crit",label:"critical conditions"},{id:"error",label:"error conditions"},{id:"warn",label:"warning conditions"},{id:"notice",label:"normal but significant condition"},{id:"info",label:"informational messages"},{id:"debug",label:"debug-level messages"}],r=[],s=[];l.forEach(function(e,i){return r[e.id]=i}),a.forEach(function(e,i){return s[e.id]=i}),i.exports.LEVEL=a,i.exports.FACILITY=l,i.exports.LEVELS=s,i.exports.FACILITIES=r,i.exports.get=function(e,i){return"number"==typeof e&&void 0===i?{level:7&e,facility:e>>3}:"number"==typeof e&&"number"==typeof i?8*e+i:"string"==typeof e&&"number"==typeof i?8*(r[e]||0)+i:"number"==typeof e&&"string"==typeof i?8*e+(s[i]||0):"string"==typeof e&&"string"==typeof i?8*(r[e]||0)+(s[i]||0):{level:0,facility:0}}},{}]},{},[1]);
{
"name": "nsyslog-parser",
"version": "0.8.3",
"version": "0.8.4",
"description": "Syslog Parser. Accepts RFC 3164 (BSD), RFC 5424 and CEF formats",

@@ -25,11 +25,12 @@ "author": "David Gómez Matarrodona <solzimer@gmail.com>",

"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"grunt": "^1.0.1",
"grunt-babel": "^6.0.0",
"grunt-browserify": "^5.0.0",
"grunt": "^1.0.3",
"grunt-babel": "^7.0.0",
"grunt-browserify": "^5.3.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-uglify": "^3.0.1",
"load-grunt-tasks": "^3.5.2",
"grunt-contrib-uglify": "^3.4.0",
"load-grunt-tasks": "^4.0.0",
"uglify": "^0.1.5"
}
}

@@ -9,7 +9,7 @@ const

"prival" : /<(\d+)>/,
"month" : /^[a-zA-Z]{3} /,
"month" : /^[A-Z][a-z]{2} /,
"day" : /^\d{1,2} /,
"time" : /^\d+:\d+:\d+ /,
"ts" : /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\S+ /,
"invalid" : /[^a-zA-Z0-9\.\$\-_#%\/\[\]]/,
"invalid" : /[^a-zA-Z0-9\.\$\-_#%\/\[\]\(\)]/,
"sdata" : /\[(\S+)( [^\=]+\=\"[^\"]+\")+\]/g,

@@ -16,0 +16,0 @@ "cef" : /^CEF:\d+/

@@ -26,3 +26,4 @@ module.exports = [

'<30>1 2018-06-24T22:22:53Z my.test.com testapp 26599 testapp - This: contains two : colons',
'<30>Aug 4 16:53:13 pinger[1334]: 64 bytes from 87.250.250.242: seq=69 ttl=37 time=33.918 ms\n'
'<30>Aug 4 16:53:13 pinger[1334]: 64 bytes from 87.250.250.242: seq=69 ttl=37 time=33.918 ms\n',
'<190>AMP (airwave)[6944]: Your license does not allow you to create or authorize additional APs/Devices\tSystem\tSystem\t\t\t'
];

Sorry, the diff of this file is not supported yet

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