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.9.5 to 0.9.6

2

dist/nsyslog-parser.js

@@ -142,3 +142,3 @@ "use strict";

"invalid": /[^a-zA-Z0-9\.\$\-_#%\/\[\]\(\)]/,
"sdata": /\[(\S+)( [^\=]+\=\"[^\"]+\")+\]/g,
"sdata": /\[(\S+)( [^\=]+\=\"[^\"]*\")+\]/g,
"asdata": /^\s*[^\[]+\[/,

@@ -145,0 +145,0 @@ "bsdata": /^\s*\[/,

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

/*! nsyslog-parser 2019-11-08 */
/*! nsyslog-parser 2019-11-13 */
"use strict";!function l(r,n,o){function d(i,e){if(!n[i]){if(!r[i]){var a="function"==typeof require&&require;if(!e&&a)return a(i,!0);if(c)return c(i,!0);var t=new Error("Cannot find module '"+i+"'");throw t.code="MODULE_NOT_FOUND",t}var s=n[i]={exports:{}};r[i][0].call(s.exports,function(e){return d(r[i][1][e]||e)},s,s.exports,l,r,n,o)}return n[i].exports}for(var c="function"==typeof require&&require,e=0;e<o.length;e++)d(o[e]);return d}({1:[function(e,i,a){var t,s;t=window,s=e("./parser.js"),t.NSyslog=t.NSyslog||{},t.NSyslog.parse=s},{"./parser.js":3}],2:[function(e,i,a){var r=["version","deviceVendor","deviceProduct","deviceVersion","deviceEventClassID","name","severity","extension"];i.exports={parse:function(e){var i=function(e){var a=[],t={},i=!1,s=7,l="";return e.split("").forEach(function(e){s?"|"==e?i?(i=!1,l+=e):(a.push(l),l="",s--):"\\"==e?(l+=e,i=!i):(i=!1,l+=e):l+=e}),l.length&&a.push(l),r.forEach(function(e,i){return t[e]=a[i]}),t}(e);return{headers:i,fields:function(e){for(var i=e.split(" "),a={},t=null;i.length;)if(t){var s=i.shift();s.indexOf("=")<0?a[t]+=" ".concat(s):(t=null,i.unshift(s))}else if(0<=(t=i.shift()).indexOf("=")){var l=t.split("=");a[t=l[0]]=l[1]}else a[t]="";return a}(i.extension||"")}}}},{}],3:[function(e,i,a){var w=e("./pri.js"),D=e("./cef.js"),j={pri:/^<\d+>/,prinmr:/^\d+ /,prival:/<(\d+)>/,month:/^[A-Za-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,asdata:/^\s*[^\[]+\[/,bsdata:/^\s*\[/,cef:/^CEF:\d+/},O={cef:!0,fields:!0,pid:!0,generateTimestamp:!0};function C(e){do{var i=e.shift();if(void 0===i)return i;i=i.trim()}while(!i);return i}function I(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,i){try{return function(e,i){i=i?Object.assign({},O,i):O;var a=e.match(j.pri),l={originalMessage:e};if(a){l.pri=a[0],l.prival=parseInt(l.pri.match(j.prival)[1]);var t=w.get(l.prival);l.facilityval=t.facility,l.levelval=t.level,l.facility=w.FACILITY[t.facility].id,l.level=w.LEVEL[t.level].id}else l.pri="",l.prival=NaN;for(var s=e.substring(l.pri.length).split(" "),r=!1;e.length&&!r;){if((u=C(s)+" ").match(j.prinmr))l.version=parseInt(u),l.type="RFC5424",(u=C(s)+" ").match(j.ts)&&(l.ts=new Date(Date.parse(u.match(j.ts)[0].trim())));else if(u.match(j.month)){l.type="BSD";var n=u.trim(),o=C(s),d=C(s),c=(new Date).getYear()+1900;l.ts=new Date(Date.parse(c+" "+n+" "+o+" "+d))}else l.type="UNKNOWN",s.unshift(u.trim());r=!0}if(!l.ts&&i.generateTimestamp&&(l.ts=new Date),l.type){var f=function(e){s.unshift(e),l.message=s.join(" "),r=!0};for(r=!1;e.length&&!r;){var u;if(u=C(s))if(u.endsWith(":")){var p=u.replace(/:$/,"").trim();p.match(j.invalid)?f(u):(I(l,p),l.message=s.join(" "),r=!0)}else if(s.length)if(u.match(j.invalid))f(u);else{var m=I(l,u.replace(/: $/,"").trim());!0===m?(s.unshift(u),l.message=s.join(" "),r=!0):!1===m&&(l.message=s.join(" "),r=!0)}else f(u);else r=!0}}else l.message=s.join(" ");if(l.chain=(l.host||"").split("/"),l.host=l.chain.pop(),"RFC5424"==l.type){var g=j.bsdata.test(l.message),h=j.asdata.test(l.message),y=l.message.match(j.sdata)||[],v=0;if(l.structuredData=y.map(function(e){var t={},s=null;return v=l.message.indexOf(e)+e.length+1,e.replace(/(^\[)|(\]$)/g,"").split(" ").forEach(function(e,i){if(e.trim())if(0==i)t.$id=e;else{var a=e.split("=");a[0]&&a[1]&&'"'!=a[1]?(s=a.shift(),t[s]=a.join("=").replace(/\"/g,"")):a[0]&&void 0===a[1]?t[s]+=" "+(a[0]||"").replace(/\"/g,""):!a[0]||a[1].length&&'"'!=a[1]||(t[s]+=" "+(a[0]||"").replace(/\"/g,"")+"=")}}),t}),l.structuredData.length){var b=l.message.indexOf("[");g?(0<=b&&(l.header=e.substring(0,e.length-l.message.length)),l.message=l.message.substring(v)):h&&0<=b&&(l.header=e.substring(0,e.length-l.message.length),l.message=l.message.substring(0,b))}}if(!1!==i.cef&&j.cef.test(l.message)){l.type="CEF";var N=D.parse(l.message);l.cef=N.headers,l.fields=N.fields}else if(!1!==i.fields&&"UNKNOWN"!=l.type){var x=[];l.message.split(",").forEach(function(e){var i=e.split("=");2==i.length&&(x[i[0]]=i[1])}),l.fields=x}if(l.header=l.header||e.substring(0,e.length-l.message.length),l.message=l.message.trim(),i.pid&&l.appName&&l.appName.endsWith("]")){var E=l.appName.indexOf("[");0<=E&&(l.pid=l.appName.substring(E+1,l.appName.length-1),l.appName=l.appName.substring(0,E))}return l}(e,i)}catch(e){return{err:e}}}},{"./cef.js":2,"./pri.js":4}],4:[function(e,i,a){var t=[{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"}],s=[{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"}],l=[],r=[];t.forEach(function(e,i){return l[e.id]=i}),s.forEach(function(e,i){return r[e.id]=i}),i.exports.LEVEL=s,i.exports.FACILITY=t,i.exports.LEVELS=r,i.exports.FACILITIES=l,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*(l[e]||0)+i:"number"==typeof e&&"string"==typeof i?8*e+(r[i]||0):"string"==typeof e&&"string"==typeof i?8*(l[e]||0)+(r[i]||0):{level:0,facility:0}}},{}]},{},[1]);
"use strict";!function l(r,n,o){function d(i,e){if(!n[i]){if(!r[i]){var a="function"==typeof require&&require;if(!e&&a)return a(i,!0);if(c)return c(i,!0);var t=new Error("Cannot find module '"+i+"'");throw t.code="MODULE_NOT_FOUND",t}var s=n[i]={exports:{}};r[i][0].call(s.exports,function(e){return d(r[i][1][e]||e)},s,s.exports,l,r,n,o)}return n[i].exports}for(var c="function"==typeof require&&require,e=0;e<o.length;e++)d(o[e]);return d}({1:[function(e,i,a){var t,s;t=window,s=e("./parser.js"),t.NSyslog=t.NSyslog||{},t.NSyslog.parse=s},{"./parser.js":3}],2:[function(e,i,a){var r=["version","deviceVendor","deviceProduct","deviceVersion","deviceEventClassID","name","severity","extension"];i.exports={parse:function(e){var i=function(e){var a=[],t={},i=!1,s=7,l="";return e.split("").forEach(function(e){s?"|"==e?i?(i=!1,l+=e):(a.push(l),l="",s--):"\\"==e?(l+=e,i=!i):(i=!1,l+=e):l+=e}),l.length&&a.push(l),r.forEach(function(e,i){return t[e]=a[i]}),t}(e);return{headers:i,fields:function(e){for(var i=e.split(" "),a={},t=null;i.length;)if(t){var s=i.shift();s.indexOf("=")<0?a[t]+=" ".concat(s):(t=null,i.unshift(s))}else if(0<=(t=i.shift()).indexOf("=")){var l=t.split("=");a[t=l[0]]=l[1]}else a[t]="";return a}(i.extension||"")}}}},{}],3:[function(e,i,a){var w=e("./pri.js"),D=e("./cef.js"),j={pri:/^<\d+>/,prinmr:/^\d+ /,prival:/<(\d+)>/,month:/^[A-Za-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,asdata:/^\s*[^\[]+\[/,bsdata:/^\s*\[/,cef:/^CEF:\d+/},O={cef:!0,fields:!0,pid:!0,generateTimestamp:!0};function C(e){do{var i=e.shift();if(void 0===i)return i;i=i.trim()}while(!i);return i}function I(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,i){try{return function(e,i){i=i?Object.assign({},O,i):O;var a=e.match(j.pri),l={originalMessage:e};if(a){l.pri=a[0],l.prival=parseInt(l.pri.match(j.prival)[1]);var t=w.get(l.prival);l.facilityval=t.facility,l.levelval=t.level,l.facility=w.FACILITY[t.facility].id,l.level=w.LEVEL[t.level].id}else l.pri="",l.prival=NaN;for(var s=e.substring(l.pri.length).split(" "),r=!1;e.length&&!r;){if((u=C(s)+" ").match(j.prinmr))l.version=parseInt(u),l.type="RFC5424",(u=C(s)+" ").match(j.ts)&&(l.ts=new Date(Date.parse(u.match(j.ts)[0].trim())));else if(u.match(j.month)){l.type="BSD";var n=u.trim(),o=C(s),d=C(s),c=(new Date).getYear()+1900;l.ts=new Date(Date.parse(c+" "+n+" "+o+" "+d))}else l.type="UNKNOWN",s.unshift(u.trim());r=!0}if(!l.ts&&i.generateTimestamp&&(l.ts=new Date),l.type){var f=function(e){s.unshift(e),l.message=s.join(" "),r=!0};for(r=!1;e.length&&!r;){var u;if(u=C(s))if(u.endsWith(":")){var p=u.replace(/:$/,"").trim();p.match(j.invalid)?f(u):(I(l,p),l.message=s.join(" "),r=!0)}else if(s.length)if(u.match(j.invalid))f(u);else{var m=I(l,u.replace(/: $/,"").trim());!0===m?(s.unshift(u),l.message=s.join(" "),r=!0):!1===m&&(l.message=s.join(" "),r=!0)}else f(u);else r=!0}}else l.message=s.join(" ");if(l.chain=(l.host||"").split("/"),l.host=l.chain.pop(),"RFC5424"==l.type){var g=j.bsdata.test(l.message),h=j.asdata.test(l.message),y=l.message.match(j.sdata)||[],v=0;if(l.structuredData=y.map(function(e){var t={},s=null;return v=l.message.indexOf(e)+e.length+1,e.replace(/(^\[)|(\]$)/g,"").split(" ").forEach(function(e,i){if(e.trim())if(0==i)t.$id=e;else{var a=e.split("=");a[0]&&a[1]&&'"'!=a[1]?(s=a.shift(),t[s]=a.join("=").replace(/\"/g,"")):a[0]&&void 0===a[1]?t[s]+=" "+(a[0]||"").replace(/\"/g,""):!a[0]||a[1].length&&'"'!=a[1]||(t[s]+=" "+(a[0]||"").replace(/\"/g,"")+"=")}}),t}),l.structuredData.length){var b=l.message.indexOf("[");g?(0<=b&&(l.header=e.substring(0,e.length-l.message.length)),l.message=l.message.substring(v)):h&&0<=b&&(l.header=e.substring(0,e.length-l.message.length),l.message=l.message.substring(0,b))}}if(!1!==i.cef&&j.cef.test(l.message)){l.type="CEF";var N=D.parse(l.message);l.cef=N.headers,l.fields=N.fields}else if(!1!==i.fields&&"UNKNOWN"!=l.type){var x=[];l.message.split(",").forEach(function(e){var i=e.split("=");2==i.length&&(x[i[0]]=i[1])}),l.fields=x}if(l.header=l.header||e.substring(0,e.length-l.message.length),l.message=l.message.trim(),i.pid&&l.appName&&l.appName.endsWith("]")){var E=l.appName.indexOf("[");0<=E&&(l.pid=l.appName.substring(E+1,l.appName.length-1),l.appName=l.appName.substring(0,E))}return l}(e,i)}catch(e){return{err:e}}}},{"./cef.js":2,"./pri.js":4}],4:[function(e,i,a){var t=[{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"}],s=[{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"}],l=[],r=[];t.forEach(function(e,i){return l[e.id]=i}),s.forEach(function(e,i){return r[e.id]=i}),i.exports.LEVEL=s,i.exports.FACILITY=t,i.exports.LEVELS=r,i.exports.FACILITIES=l,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*(l[e]||0)+i:"number"==typeof e&&"string"==typeof i?8*e+(r[i]||0):"string"==typeof e&&"string"==typeof i?8*(l[e]||0)+(r[i]||0):{level:0,facility:0}}},{}]},{},[1]);
{
"name": "nsyslog-parser",
"version": "0.9.5",
"version": "0.9.6",
"description": "Syslog Parser. Accepts RFC 3164 (BSD), RFC 5424 and CEF formats",

@@ -5,0 +5,0 @@ "author": "David Gómez Matarrodona <solzimer@gmail.com>",

@@ -14,3 +14,3 @@ const

"invalid" : /[^a-zA-Z0-9\.\$\-_#%\/\[\]\(\)]/,
"sdata" : /\[(\S+)( [^\=]+\=\"[^\"]+\")+\]/g,
"sdata" : /\[(\S+)( [^\=]+\=\"[^\"]*\")+\]/g,
"asdata" : /^\s*[^\[]+\[/,

@@ -222,3 +222,3 @@ "bsdata" : /^\s*\[/,

}
}
}
}

@@ -225,0 +225,0 @@ }

@@ -939,3 +939,33 @@ module.exports = [

"fields": []
},
{
"originalMessage": "<36>0 2019-11-12T17:57:55+01:00 ICA.domini.age Unmanaged - - - hosts discovered [alertMeta@0 oid=\"1.3.6.1.4.1.2213.84.2147483647.30\" shost=\"ICA.domini.age\" uid=\"ICA.domini.age\" domainTreePath=\"\" message=\"91 unmanaged host(s) discovered.\"]",
"pri": "<36>",
"prival": 36,
"facilityval": 4,
"levelval": 4,
"facility": "auth",
"level": "warn",
"version": 0,
"type": "RFC5424",
"ts": "2019-11-12T16:57:55.000Z",
"host": "ICA.domini.age",
"appName": "Unmanaged",
"pid": "-",
"messageid": "-",
"structuredData": [
{
"$id": "alertMeta@0",
"oid": "1.3.6.1.4.1.2213.84.2147483647.30",
"shost": "ICA.domini.age",
"uid": "ICA.domini.age",
"domainTreePath": "",
"message": "91 unmanaged host(s) discovered."
}
],
"message": "hosts discovered",
"chain": [],
"header": "<36>0 2019-11-12T17:57:55+01:00 ICA.domini.age Unmanaged - - - ",
"fields": []
}
];

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