Snorby / snorby

Ruby On Rails Application For Network Security Monitoring
Other
1k stars 224 forks source link

Dashboard page breaks when order by matches higher than result limit #490

Open wnormand-armor opened 6 years ago

wnormand-armor commented 6 years ago

I know this isn't an active project but we hit this bug on our production server and it took a while to pin down. To reproduce, create about 10 sensors, set all of them to events_count=0, load the page. The limit=5 will load 5 objects, but the view will then load another 5 objects since it's an unordered collection. I was able to work around this by forcing the sensor to an array before passing to the view.

https://github.com/Snorby/snorby/blob/master/app/controllers/page_controller.rb#L46

-@sensors = Sensor.all(:limit => 5, :order => [:events_count.desc]) +@sensors = Sensor.all(:limit => 5, :order => [:events_count.desc]).to_a # eagerly load the initial result set