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.0 to 0.9.1

0

browser.js

@@ -0,0 +0,0 @@ "use strict";

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

7

dist/nsyslog-parser.js

@@ -148,3 +148,4 @@ "use strict";

fields: true,
pid: true
pid: true,
generateTimestamp: true
};

@@ -169,3 +170,3 @@

function parse(line, opts) {
opts = opts || DOPS;
if (opts) opts = Object.assign({}, DOPS, opts);else opts = DOPS;
var pri = line.match(RXS.pri);

@@ -222,3 +223,3 @@ var entry = {

if (!entry.ts) entry.ts = new Date(); // Is a standard syslog message
if (!entry.ts && opts.generateTimestamp) entry.ts = new Date(); // Is a standard syslog message

@@ -225,0 +226,0 @@ if (entry.type) {

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

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

@@ -0,0 +0,0 @@ module.exports = function(grunt) {

{
"name": "nsyslog-parser",
"version": "0.9.0",
"version": "0.9.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>",

@@ -21,3 +21,4 @@ const

fields : true,
pid : true
pid : true,
generateTimestamp: true
}

@@ -48,3 +49,6 @@

function parse(line,opts) {
opts = opts || DOPS;
if(opts)
opts = Object.assign({},DOPS,opts);
else
opts = DOPS;

@@ -105,3 +109,3 @@ var pri = line.match(RXS.pri);

// No timestamp
if(!entry.ts) entry.ts = new Date();
if(!entry.ts && opts.generateTimestamp) entry.ts = new Date();

@@ -108,0 +112,0 @@ // Is a standard syslog message

@@ -0,0 +0,0 @@ const FACILITY = [

@@ -0,0 +0,0 @@ # nsyslog-parser

@@ -0,0 +0,0 @@ const parser = require("./parser.js");

@@ -0,0 +0,0 @@ module.exports = [

@@ -0,0 +0,0 @@ module.exports = [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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