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.10.0 to 0.10.1

3

dist/nsyslog-parser.js

@@ -204,5 +204,4 @@ "use strict";

var tokens = msg.split(delimiter);
console.log(tokens);
var map = tokens.reduce(function (map, token) {
keyval = token.split('=');
var keyval = token.split('=');
map[keyval[0]] = keyval[1];

@@ -209,0 +208,0 @@ return map;

/*! nsyslog-parser 2023-01-03 */
"use strict";!function l(r,n,o){function f(i,e){if(!n[i]){if(!r[i]){var t="function"==typeof require&&require;if(!e&&t)return t(i,!0);if(d)return d(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var s=n[i]={exports:{}};r[i][0].call(s.exports,function(e){return f(r[i][1][e]||e)},s,s.exports,l,r,n,o)}return n[i].exports}for(var d="function"==typeof require&&require,e=0;e<o.length;e++)f(o[e]);return f}({1:[function(e,i,t){var a,s;a=window,s=e("./parser.js"),a.NSyslog=a.NSyslog||{},a.NSyslog.parse=s},{"./parser.js":4}],2:[function(e,i,t){var r=["version","deviceVendor","deviceProduct","deviceVersion","deviceEventClassID","name","severity","extension"];i.exports={parse:function(e){var i=function(e){var t=[],a={},i=!1,s=7,l="";return e.split("").forEach(function(e){s?"|"==e?i?(i=!1,l+=e):(t.push(l),l="",s--):"\\"==e?(l+=e,i=!i):(i=!1,l+=e):l+=e}),l.length&&t.push(l),r.forEach(function(e,i){return a[e]=t[i]}),a}(e);return{headers:i,fields:function(e){for(var i=e.split(" "),t={},a=null;i.length;)if(a){var s=i.shift();s.indexOf("=")<0?t[a]+=" ".concat(s):(a=null,i.unshift(s))}else if(0<=(a=i.shift()).indexOf("=")){var l=a.split("=");t[a=l[0]]=l[1]}else t[a]="";return t}(i.extension||"")}}}},{}],3:[function(e,i,t){var f=[{k:"leefVersion",v1:!0,v2:!0},{k:"vendor",v1:!0,v2:!0},{k:"product",v1:!0,v2:!0},{k:"version",v1:!0,v2:!0},{k:"eventID",v1:!0,v2:!0},{k:"delimiter",v1:!1,v2:!0},{k:"extension",v1:!0,v2:!0}],d=f.length;i.exports={parse:function(e){var i=function(e){var i=[],t={},a=!1,s=7,l="";e.split("").forEach(function(e){s?"|"==e?a?(a=!1,l+=e):(i.push(l),l="",s--):"\\"==e?(l+=e,a=!a):(a=!1,l+=e):l+=e}),l.length&&i.push(l);for(var r="LEEF:1.0"==i[0]?"v1":"v2",n=0;n<d;n++){var o=f[n];o[r]&&(t[o.k]=i.shift())}return t}(e);return{headers:i,fields:function(e,i){i=i||"\t";var t=e.split(i);return console.log(t),t.reduce(function(e,i){return keyval=i.split("="),e[keyval[0]]=keyval[1],e},{})}(i.extension||"",i.delimiter)}}}},{}],4:[function(e,i,t){var j=e("./pri.js"),D=e("./cef.js"),w=e("./leef.js"),L={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+/,leef:/^LEEF:(1|2)\.0/},F={cef:!0,leef:!0,fields:!0,pid:!0,generateTimestamp:!0};function I(e){do{var i=e.shift();if(void 0===i)return i;i=i.trim()}while(!i);return i}function O(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({},F,i):F;var t=e.match(L.pri),l={originalMessage:e};if(t){l.pri=t[0],l.prival=parseInt(l.pri.match(L.prival)[1]);var a=j.get(l.prival);l.facilityval=a.facility,l.levelval=a.level,l.facility=j.FACILITY[a.facility].id,l.level=j.LEVEL[a.level].id}else l.pri="",l.prival=NaN;for(var s=e.substring(l.pri.length).split(" "),r=!1;e.length&&!r;){if((u=I(s)+" ").match(L.prinmr))l.version=parseInt(u),l.type="RFC5424",(u=I(s)+" ").match(L.ts)&&(l.ts=new Date(Date.parse(u.match(L.ts)[0].trim())));else if(u.match(L.month)){l.type="BSD";var n=u.trim(),o=I(s),f=I(s),d=(new Date).getYear()+1900;l.ts=new Date(Date.parse(d+" "+n+" "+o+" "+f))}else l.type="UNKNOWN",s.unshift(u.trim());r=!0}if(!l.ts&&i.generateTimestamp&&(l.ts=new Date),l.type){var c=function(e){s.unshift(e),l.message=s.join(" "),r=!0};for(r=!1;e.length&&!r;){var u;if(u=I(s))if(u.endsWith(":")){var p=u.replace(/:$/,"").trim();p.match(L.invalid)?c(u):(O(l,p),l.message=s.join(" "),r=!0)}else if(s.length)if(u.match(L.invalid))c(u);else{var m=O(l,u.replace(/: $/,"").trim());!0===m?(s.unshift(u),l.message=s.join(" "),r=!0):!1===m&&(l.message=s.join(" "),r=!0)}else c(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=L.bsdata.test(l.message),v=L.asdata.test(l.message),h=l.message.match(L.sdata)||[],y=0;if(l.structuredData=h.map(function(e){var a={},s=null;return y=l.message.indexOf(e)+e.length+1,e.replace(/(^\[)|(\]$)/g,"").split(" ").forEach(function(e,i){if(e.trim())if(0==i)a.$id=e;else{var t=e.split("=");t[0]&&t[1]&&'"'!=t[1]?(s=t.shift(),a[s]=t.join("=").replace(/\"/g,"")):t[0]&&void 0===t[1]?a[s]+=" "+(t[0]||"").replace(/\"/g,""):!t[0]||t[1].length&&'"'!=t[1]||(a[s]+=" "+(t[0]||"").replace(/\"/g,"")+"=")}}),a}),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(y)):v&&0<=b&&(l.header=e.substring(0,e.length-l.message.length),l.message=l.message.substring(0,b))}}if(!1!==i.cef&&L.cef.test(l.message)){l.type="CEF";var E=D.parse(l.message);l.cef=E.headers,l.fields=E.fields}else if(!1!==i.leef&&L.leef.test(l.message)){l.type="LEEF";var N=w.parse(l.message);l.leef=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 k=l.appName.indexOf("[");0<=k&&(l.pid=l.appName.substring(k+1,l.appName.length-1),l.appName=l.appName.substring(0,k))}return l}(e,i)}catch(e){return{err:e}}}},{"./cef.js":2,"./leef.js":3,"./pri.js":5}],5:[function(e,i,t){var a=[{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=[];a.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=a,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 r(l,n,o){function f(i,e){if(!n[i]){if(!l[i]){var t="function"==typeof require&&require;if(!e&&t)return t(i,!0);if(d)return d(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var s=n[i]={exports:{}};l[i][0].call(s.exports,function(e){return f(l[i][1][e]||e)},s,s.exports,r,l,n,o)}return n[i].exports}for(var d="function"==typeof require&&require,e=0;e<o.length;e++)f(o[e]);return f}({1:[function(e,i,t){var a,s;a=window,s=e("./parser.js"),a.NSyslog=a.NSyslog||{},a.NSyslog.parse=s},{"./parser.js":4}],2:[function(e,i,t){var l=["version","deviceVendor","deviceProduct","deviceVersion","deviceEventClassID","name","severity","extension"];i.exports={parse:function(e){var i=function(e){var t=[],a={},i=!1,s=7,r="";return e.split("").forEach(function(e){s?"|"==e?i?(i=!1,r+=e):(t.push(r),r="",s--):"\\"==e?(r+=e,i=!i):(i=!1,r+=e):r+=e}),r.length&&t.push(r),l.forEach(function(e,i){return a[e]=t[i]}),a}(e);return{headers:i,fields:function(e){for(var i=e.split(" "),t={},a=null;i.length;)if(a){var s=i.shift();s.indexOf("=")<0?t[a]+=" ".concat(s):(a=null,i.unshift(s))}else if(0<=(a=i.shift()).indexOf("=")){var r=a.split("=");t[a=r[0]]=r[1]}else t[a]="";return t}(i.extension||"")}}}},{}],3:[function(e,i,t){var f=[{k:"leefVersion",v1:!0,v2:!0},{k:"vendor",v1:!0,v2:!0},{k:"product",v1:!0,v2:!0},{k:"version",v1:!0,v2:!0},{k:"eventID",v1:!0,v2:!0},{k:"delimiter",v1:!1,v2:!0},{k:"extension",v1:!0,v2:!0}],d=f.length;i.exports={parse:function(e){var i=function(e){var i=[],t={},a=!1,s=7,r="";e.split("").forEach(function(e){s?"|"==e?a?(a=!1,r+=e):(i.push(r),r="",s--):"\\"==e?(r+=e,a=!a):(a=!1,r+=e):r+=e}),r.length&&i.push(r);for(var l="LEEF:1.0"==i[0]?"v1":"v2",n=0;n<d;n++){var o=f[n];o[l]&&(t[o.k]=i.shift())}return t}(e);return{headers:i,fields:function(e,i){return i=i||"\t",e.split(i).reduce(function(e,i){var t=i.split("=");return e[t[0]]=t[1],e},{})}(i.extension||"",i.delimiter)}}}},{}],4:[function(e,i,t){var D=e("./pri.js"),k=e("./cef.js"),w=e("./leef.js"),L={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+/,leef:/^LEEF:(1|2)\.0/},F={cef:!0,leef:!0,fields:!0,pid:!0,generateTimestamp:!0};function I(e){do{var i=e.shift();if(void 0===i)return i;i=i.trim()}while(!i);return i}function O(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({},F,i):F;var t=e.match(L.pri),r={originalMessage:e};if(t){r.pri=t[0],r.prival=parseInt(r.pri.match(L.prival)[1]);var a=D.get(r.prival);r.facilityval=a.facility,r.levelval=a.level,r.facility=D.FACILITY[a.facility].id,r.level=D.LEVEL[a.level].id}else r.pri="",r.prival=NaN;for(var s=e.substring(r.pri.length).split(" "),l=!1;e.length&&!l;){if((u=I(s)+" ").match(L.prinmr))r.version=parseInt(u),r.type="RFC5424",(u=I(s)+" ").match(L.ts)&&(r.ts=new Date(Date.parse(u.match(L.ts)[0].trim())));else if(u.match(L.month)){r.type="BSD";var n=u.trim(),o=I(s),f=I(s),d=(new Date).getYear()+1900;r.ts=new Date(Date.parse(d+" "+n+" "+o+" "+f))}else r.type="UNKNOWN",s.unshift(u.trim());l=!0}if(!r.ts&&i.generateTimestamp&&(r.ts=new Date),r.type){var c=function(e){s.unshift(e),r.message=s.join(" "),l=!0};for(l=!1;e.length&&!l;){var u;if(u=I(s))if(u.endsWith(":")){var p=u.replace(/:$/,"").trim();p.match(L.invalid)?c(u):(O(r,p),r.message=s.join(" "),l=!0)}else if(s.length)if(u.match(L.invalid))c(u);else{var m=O(r,u.replace(/: $/,"").trim());!0===m?(s.unshift(u),r.message=s.join(" "),l=!0):!1===m&&(r.message=s.join(" "),l=!0)}else c(u);else l=!0}}else r.message=s.join(" ");if(r.chain=(r.host||"").split("/"),r.host=r.chain.pop(),"RFC5424"==r.type){var g=L.bsdata.test(r.message),v=L.asdata.test(r.message),h=r.message.match(L.sdata)||[],y=0;if(r.structuredData=h.map(function(e){var a={},s=null;return y=r.message.indexOf(e)+e.length+1,e.replace(/(^\[)|(\]$)/g,"").split(" ").forEach(function(e,i){if(e.trim())if(0==i)a.$id=e;else{var t=e.split("=");t[0]&&t[1]&&'"'!=t[1]?(s=t.shift(),a[s]=t.join("=").replace(/\"/g,"")):t[0]&&void 0===t[1]?a[s]+=" "+(t[0]||"").replace(/\"/g,""):!t[0]||t[1].length&&'"'!=t[1]||(a[s]+=" "+(t[0]||"").replace(/\"/g,"")+"=")}}),a}),r.structuredData.length){var b=r.message.indexOf("[");g?(0<=b&&(r.header=e.substring(0,e.length-r.message.length)),r.message=r.message.substring(y)):v&&0<=b&&(r.header=e.substring(0,e.length-r.message.length),r.message=r.message.substring(0,b))}}if(!1!==i.cef&&L.cef.test(r.message)){r.type="CEF";var E=k.parse(r.message);r.cef=E.headers,r.fields=E.fields}else if(!1!==i.leef&&L.leef.test(r.message)){r.type="LEEF";var N=w.parse(r.message);r.leef=N.headers,r.fields=N.fields}else if(!1!==i.fields&&"UNKNOWN"!=r.type){var x=[];r.message.split(",").forEach(function(e){var i=e.split("=");2==i.length&&(x[i[0]]=i[1])}),r.fields=x}if(r.header=r.header||e.substring(0,e.length-r.message.length),r.message=r.message.trim(),i.pid&&r.appName&&r.appName.endsWith("]")){var j=r.appName.indexOf("[");0<=j&&(r.pid=r.appName.substring(j+1,r.appName.length-1),r.appName=r.appName.substring(0,j))}return r}(e,i)}catch(e){return{err:e}}}},{"./cef.js":2,"./leef.js":3,"./pri.js":5}],5:[function(e,i,t){var a=[{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"}],r=[],l=[];a.forEach(function(e,i){return r[e.id]=i}),s.forEach(function(e,i){return l[e.id]=i}),i.exports.LEVEL=s,i.exports.FACILITY=a,i.exports.LEVELS=l,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+(l[i]||0):"string"==typeof e&&"string"==typeof i?8*(r[e]||0)+(l[i]||0):{level:0,facility:0}}},{}]},{},[1]);

@@ -62,5 +62,4 @@ const FRX = /[a-zA-Z][a-zA-Z0-9]+=/;

console.log(tokens);
let map = tokens.reduce((map,token)=>{
keyval = token.split('=');
let keyval = token.split('=');
map[keyval[0]] = keyval[1];

@@ -67,0 +66,0 @@ return map;

{
"name": "nsyslog-parser",
"version": "0.10.0",
"version": "0.10.1",
"description": "Syslog Parser. Accepts RFC 3164 (BSD), RFC 5424 and CEF formats",

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

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