Fixes #23 by updating array syntax for rails4 - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
DIR Log
DIR Files
DIR Refs
DIR README
---
DIR commit 52add4388c07da3d4eedcd10ba3df9623b2457aa
DIR parent f6291b823e9c2d5d2382765ec292183101c69e2e
HTML Author: HD Moore <hd_moore@rapid7.com>
Date: Mon, 27 Oct 2014 00:13:05 -0500
Fixes #23 by updating array syntax for rails4
Diffstat:
M Gemfile | 1 +
M app/assets/stylesheets/application… | 2 +-
M app/models/call.rb | 43 +++++++++++++++++--------------
A app/views/application/_nav.html.erb | 67 +++++++++++++++++++++++++++++++
M app/views/shared/graphs/_lines_by_… | 2 +-
5 files changed, 93 insertions(+), 22 deletions(-)
---
DIR diff --git a/Gemfile b/Gemfile
@@ -6,6 +6,7 @@ gem 'pg', '>=0.17'
gem 'jquery-rails', '>= 3.1.2'
gem 'jquery-datatables-rails', '>= 2.2.3'
+#gem 'postgres_ext', :git => 'git://github.com/dockyard/postgres_ext.git'
gem 'kissfft'
gem 'rex', '~> 2.0.3'
DIR diff --git a/app/assets/stylesheets/application.css.scss.erb b/app/assets/stylesheets/application.css.scss.erb
@@ -300,7 +300,7 @@ a .project-title, a:visited .project-title {
}
.fwd_match_span {
- width: 100px;
+ width: 150px;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 5px;
DIR diff --git a/app/models/call.rb b/app/models/call.rb
@@ -19,7 +19,7 @@ class Call < ActiveRecord::Base
# "AND (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & calls.fprint::int[]) / icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}'::int[])::float ) * 100.0 ) > 10.0 " +
self.find_by_sql([
'SELECT calls.*, ' +
- " (( icount(?::int[] & calls.fprint::int[]) / icount(?::int[])::float ) * 100.0 ) AS matchscore " +
+ " (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icount(ARRAY[?]::int[])::float ) * 100.0 ) AS matchscore " +
'FROM calls ' +
'WHERE icount(calls.fprint) > 0 AND ' +
"calls.job_id = ? AND " +
@@ -37,43 +37,46 @@ class Call < ActiveRecord::Base
# "AND (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & calls.fprint::int[]) / icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}'::int[])::float ) * 100.0 ) > 10.0 " +
self.find_by_sql([
'SELECT calls.*, ' +
- " (( icount(?::int[] & calls.fprint::int[]) / icount(?::int[])::float ) * 100.0 ) AS matchscore " +
+ " (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icount(ARRAY[?]::int[])::float ) * 100.0 ) AS matchscore " +
'FROM calls ' +
'WHERE icount(calls.fprint) > 0 AND ' +
"calls.id != ? " +
'ORDER BY matchscore DESC',
- fprint_map,
- fprint_map,
+ fprint,
+ fprint,
self.id
])
end
- def fprint_map
- @fprint_map ||= "{" + fprint.map{|x| x.to_s}.join(",") + "}"
- end
-
after_save :update_linked_line
def paginate_matches(scope, min_match, page, per_page)
- scope_limit = ""
+ match_sql =
+ 'SELECT calls.*, ' +
+ " (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icount(ARRAY[?]::int[])::float ) * 100.0 ) AS matchscore " +
+ 'FROM calls ' +
+ 'WHERE icount(calls.fprint) > 0 AND '
+ args = [fprint, fprint]
+
case scope
when 'job'
- scope_limit = "calls.job_id = \'#{job_id.to_i}\' AND "
+ match_sql << " calls.job_id = ? AND "
+ args << job.id.to_i
when 'project'
- scope_limit = "calls.project_id = \'#{project_id.to_i}\' AND "
+ match_sql << " calls.project_id = ? AND "
+ args << project_id.to_i
end
- query =
- 'SELECT calls.*, ' +
- " (( icount(\'{#{fprint_map}}\'::int[] & calls.fprint::int[]) / icount(\'{#{fprint_map}'::int[])::float ) * 100.0 ) AS matchscore " +
- 'FROM calls ' +
- 'WHERE icount(calls.fprint) > 0 AND ' +
- scope_limit +
- "calls.id != \'#{id}\' " +
- "AND (( icount(\'#{fprint_map}\'::int[] & calls.fprint::int[]) / icount(\'#{fprint_map}\'::int[])::float ) * 100.0 ) > #{min_match.to_f} " +
- 'ORDER BY matchscore DESC'
+ match_sql << "calls.id != ? "
+ args << self.id
+
+ match_sql << " AND (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icount(ARRAY[?]::int[])::float ) * 100.0 ) > ? ORDER BY matchscore DESC"
+ args << fprint
+ args << fprint
+ args << min_match.to_f
+ query = [match_sql, *args]
Call.paginate_by_sql(query, :page => page, :per_page => per_page)
end
DIR diff --git a/app/views/application/_nav.html.erb b/app/views/application/_nav.html.erb
@@ -0,0 +1,67 @@
+
+<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
+ <div class="container-fluid">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="fa fa-bar"></span>
+ <span class="fa fa-bar"></span>
+ <span class="fa fa-bar"></span>
+ </button>
+ <a class="navbar-brand" href="/"><img src="/assets/logo_light.png" border=0 alt="WarVOX"></a>
+ </div>
+
+ <div class="collapse navbar-collapse navbar-ex1-collapse">
+ <ul class="nav navbar-nav navbar-right">
+
+ <% if @project and @project.id %>
+ <li>
+ <%= link_to(
+ raw(
+ '<i class="fa fa-chevron-left icon-white"></i> ' +
+ h(truncate(@project.name, :length => 20)) +
+ ' <i class="fa fa-chevron-right icon-white"></i>'), project_path(@project), :class => 'project-title') %>
+ </li>
+ <li><a href="<%= results_path(@project) %>">Scans</a></li>
+ <li><a href="<%= analyze_path(@project) %>">Analysis</a></li>
+ <% end %>
+
+ <li><a href="<%= jobs_path %>">Jobs</a></li>
+
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Projects <span class="caret"></span></a>
+ <ul class="dropdown-menu" role="menu">
+
+ <% if Project.count > 0 %>
+ <li><a href="<%= projects_path %>"><i class="fa fa-list"></i> Browse Projects</a></li>
+ <% end %>
+
+ <li><a href="<%= new_project_path %>"><i class="fa fa-plus"></i> Create Project</a></li>
+
+ <% if Project.count > 0 %>
+ <li class="divider"></li>
+ <li> Recent Projects</li>
+ <% Project.order('ID DESC').limit(5).each do |project| %>
+ <li><a href="<%= project_path(project)%>"><i class="fa fa-chevron-right"></i> <%= truncate(project.name, :length => 15) %></a></li>
+ <% end %>
+ <% end %>
+ </ul>
+ </li>
+
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <span class="caret"></span></a>
+ <ul class="dropdown-menu" role="menu">
+ <li><a href="<%= user_path(current_user) %>"><i class="fa fa-user"></i> My Account</a></li>
+ <li><a href="<%= providers_path%>"><i class="fa fa-globe"></i> Providers</a></li>
+ <!-- <li><a href="<%= settings_path%>"><i class="fa fa-wrench"></i> Config</a></li> -->
+ <li><a href="<%= about_path%>"><i class="fa fa-info-circle"></i> About</a></li>
+ </ul>
+ </li>
+
+ <li><a href="<%= logout_path %>"><div class="help-icon"><i class="fa fa-sign-out" rel="tooltip" title="Logout"></i></div></a></li>
+ <li><a href="<%= check_path %>"<div class="help-icon"><i class="fa fa-question" rel="tooltip" title="Help!"></i></div></a></li>
+ </ul>
+ </div><!-- /.navbar-collapse -->
+ </div><!-- /.container-fluid -->
+</nav>
DIR diff --git a/app/views/shared/graphs/_lines_by_type.html.erb b/app/views/shared/graphs/_lines_by_type.html.erb
@@ -18,7 +18,7 @@ end
chart: {
renderTo: '<%= graph_id %>',
type: 'bar',
- height: 150
+ height: 250
},
title: {
text: 'Line Types'