Permalink
Browse files

Adding tests to decode privals.

In the course of this test I discovered that higher than pesmissable privals
(>=191) were being "let through". They now return false.
  • Loading branch information...
squeeks committed Mar 7, 2013
1 parent 90b4821 commit fc0922f8f03d5fc9fe334198411f18e3c33bddfc
Showing with 26 additions and 0 deletions.
  1. +2 −0 lib/glossy/parse.js
  2. +24 −0 test/decode_pri.js
View
@@ -223,6 +223,8 @@ GlossyParser.prototype.decodePri = function(message) {
returnVal.facility = FacilityIndex[returnVal.facilityID];
returnVal.severity = SeverityIndex[returnVal.severityID];
}
+ } else if(returnVal.prival >= 191) {
+ return false;
}
return returnVal;
View
@@ -0,0 +1,24 @@
+var syslogParser = require('../lib/glossy/parse.js'),
+ assert = require('assert');
+
+assert.ok(syslogParser, 'parser loaded');
+assert.deepEqual(syslogParser.decodePri('<16>'), {
+ prival: 16,
+ facilityID: 2,
+ severityID: 0,
+ facility: 'mail',
+ severity: 'emerg'
+});
+
+assert.deepEqual(syslogParser.decodePri('<66>1'), {
+ prival: 66,
+ facilityID: 8,
+ severityID: 2,
+ facility: 'uucp',
+ severity: 'crit'
+});
+
+
+assert.equal(syslogParser.decodePri('1<16>'), false);
+assert.equal(syslogParser.decodePri('<200>'), false);
+

0 comments on commit fc0922f

Please sign in to comment.