Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
add base for investigations collection, clean up consistent naming fo…
Browse files Browse the repository at this point in the history
…r incident(s) publishing
  • Loading branch information
jeffbryner committed Jan 26, 2015
1 parent 4c9cf47 commit 4d9eb87
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 54 deletions.
3 changes: 1 addition & 2 deletions meteor/app/client/incidents.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,7 @@ if (Meteor.isClient) {

//set up reactive data
Deps.autorun(function() {
//Meteor.subscribe("incidents-details",Session.get('incidentID'));
Meteor.subscribe("incidents-details",Session.get('incidentID'), onReady=function(){
Meteor.subscribe("incident-details",Session.get('incidentID'), onReady=function(){
initDatePickers();
});
}); //end deps.autorun
Expand Down
108 changes: 57 additions & 51 deletions meteor/app/lib/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Anthony Verez averez@mozilla.com

//collections shared by client/server

incidents = new Meteor.Collection("incidents");
events = new Meteor.Collection("events");
alerts = new Meteor.Collection("alerts");
investigations = new Meteor.Collection("investigations");
incidents = new Meteor.Collection("incidents");
veris = new Meteor.Collection("veris");
kibanadashboards = new Meteor.Collection("kibanadashboards");
mozdefsettings = new Meteor.Collection("mozdefsettings");
Expand All @@ -25,7 +26,6 @@ Anthony Verez averez@mozilla.com
attackers = new Meteor.Collection("attackers");
actions = new Meteor.Collection("actions");


if (Meteor.isServer) {
//Publishing setups
Meteor.publish("mozdefsettings",function(){
Expand All @@ -46,19 +46,20 @@ if (Meteor.isServer) {

if ( timeperiod ==='tail' || timeperiod == 'none' ){
return alerts.find(
{summary: {$regex:searchregex}},
{fields:{
_id:1,
esmetadata:1,
utctimestamp:1,
utcepoch:1,
summary:1,
severity:1,
category:1,
acknowledged:1
},
sort: {utcepoch: -1},
limit:recordlimit});
{summary: {$regex:searchregex}},
{fields:{
_id:1,
esmetadata:1,
utctimestamp:1,
utcepoch:1,
summary:1,
severity:1,
category:1,
acknowledged:1
},
sort: {utcepoch: -1},
limit:recordlimit}
);
} else {
//determine the utcepoch range
beginningtime=moment().utc();
Expand All @@ -67,20 +68,21 @@ if (Meteor.isServer) {
timeunits=timeperiod.split(" ")[1];
beginningtime.subtract(timevalue,timeunits);
return alerts.find(
{summary: {$regex:searchregex},
utcepoch: {$gte: beginningtime.unix()}},
{fields:{
_id:1,
esmetadata:1,
utctimestamp:1,
utcepoch:1,
summary:1,
severity:1,
category:1,
acknowledged:1
},
sort: {utcepoch: -1},
limit:recordlimit});
{summary: {$regex:searchregex},
utcepoch: {$gte: beginningtime.unix()}},
{fields:{
_id:1,
esmetadata:1,
utctimestamp:1,
utcepoch:1,
summary:1,
severity:1,
category:1,
acknowledged:1
},
sort: {utcepoch: -1},
limit:recordlimit}
);
}
});

Expand All @@ -89,10 +91,10 @@ if (Meteor.isServer) {
//alert ids can be either mongo or elastic search IDs
//look for both to publish to the collection.
return alerts.find({
$or:[
{'esmetadata.id': alertid},
{'_id': alertid},
]
$or:[
{'esmetadata.id': alertid},
{'_id': alertid},
]
});
});

Expand Down Expand Up @@ -142,23 +144,7 @@ if (Meteor.isServer) {
handle.stop();
});
});




Meteor.publish("incidents-summary", function () {
return incidents.find({},
{fields: {
_id:1,
summary:1,
phase:1,
dateOpened:1,
dateClosed:1
},
sort: {dateOpened: -1},
limit:100});
});

Meteor.publish("attackers", function () {
return attackers.find({}, {limit:100});
});
Expand All @@ -178,8 +164,21 @@ if (Meteor.isServer) {
sort: {lastseentimestamp: -1},
limit:100});
});

Meteor.publish("incidents-details",function(incidentid){

Meteor.publish("incidents-summary", function () {
return incidents.find({},
{fields: {
_id:1,
summary:1,
phase:1,
dateOpened:1,
dateClosed:1
},
sort: {dateOpened: -1},
limit:100});
});

Meteor.publish("incident-details",function(incidentid){
return incidents.find({'_id': incidentid});
});

Expand Down Expand Up @@ -241,6 +240,13 @@ if (Meteor.isServer) {
return (userId);
}
});

investigations.allow({
update: function (userId, doc, fields, modifier) {
// the user must be logged in
return (userId);
}
});
};

if (Meteor.isClient) {
Expand Down
2 changes: 1 addition & 1 deletion meteor/app/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Router.map(function () {
path: '/incident/:_id/edit',
waitOn: function() {
Session.set('incidentID', this.params._id);
return Meteor.subscribe('incidents-details', Session.get('incidentID'))
return Meteor.subscribe('incident-details', Session.get('incidentID'))
},
data: function() {
if (!Session.get('revisionsundo')) {
Expand Down

0 comments on commit 4d9eb87

Please sign in to comment.