Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace timespan with Moment and remove security warnings #22

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -224,7 +224,7 @@ common.loggly = function () {
//
// retries to send buffered logs to loggly in every 30 seconds
//
if (timerFunctionForBufferedLogs === null) {
if (timerFunctionForBufferedLogs === null && bufferOptions) {

This comment has been minimized.

@Shwetajain148

Shwetajain148 Oct 10, 2017
Author

@mchaudhary @mostlyjason, At this point, if we are using the search functionality of our library like- (In our app.js file)

client.search('foo', function (err, results) {
  console.dir(results.events);
});

Then the library does not set the bufferOptions object and when the library tries to access the bufferOptions.retriesInMilliSeconds property, an error is thrown so I put this check to enter into this block only when the bufferOptions object is set and has some value.

timerFunctionForBufferedLogs = setInterval(function () {
if (arrBufferedMsg.length) sendBufferdLogstoLoggly();
if (timerFunctionForBufferedLogs && !arrBufferedMsg.length) {
@@ -258,7 +258,7 @@ common.loggly = function () {
// This function will store logs into buffer
//
function storeLogs(logs) {
if (!logs.length) return;
if (!logs.length || !bufferOptions) return;

This comment has been minimized.

@Shwetajain148

Shwetajain148 Oct 10, 2017
Author

@mchaudhary @mostlyjason The same condition lies here too. I put this check to store the logs only when the bufferOptions object is set and containing the value for retriesInMilliSeconds and size otherwise this code line will throw an error.

var numberOfLogsToBeRemoved = (arrBufferedMsg.length + logs.length) - bufferOptions.size;
if (numberOfLogsToBeRemoved > 0) arrBufferedMsg = arrBufferedMsg.splice(numberOfLogsToBeRemoved);
arrBufferedMsg = arrBufferedMsg.concat(logs);
@@ -9,7 +9,7 @@
var events = require('events'),
util = require('util'),
qs = require('querystring'),
timespan = require('timespan'),
moment = require('moment'),
common = require('./common');

//
@@ -139,18 +139,18 @@ Search.prototype._checkRange = function () {
this.options.until = this.options.until || 'now';
this.options.from = this.options.from || '-24h';

if (!timespan.parseDate(this.options.until)) {
if (!moment.parseDate(this.options.until)) {
this.options.until = 'now';
}

if (!timespan.parseDate(this.options.from)) {
if (!moment.parseDate(this.options.from)) {
this.options.from = '-24h';
}

if (timespan.fromDates(this.options.from, this.options.until) < 0
if (moment.fromDates(this.options.from, this.options.until) < 0
|| this.options.until === this.options.from) {
//
// If the length of the timespan for this Search instance is
// If the length of the moment for this Search instance is
// negative then set it to default values
//
this.options.until = 'now';
@@ -1,7 +1,7 @@
{
"name": "node-loggly-bulk",
"description": "A client implementation for Loggly cloud Logging-as-a-Service API",
"version": "2.0.1",
"version": "2.0.2",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
"repository": {
"type": "git",
@@ -15,7 +15,7 @@
],
"dependencies": {
"request": ">=2.76.0 <3.0.0",
"timespan": "2.3.x",
"moment": "^2.18.1",
"json-stringify-safe": "5.0.x"
},
"devDependencies": {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.