From dc1c65b4187ba3d62f8b81bc44911fa35b5bdcef Mon Sep 17 00:00:00 2001 From: erwanlr Date: Mon, 30 Dec 2013 11:50:43 +0000 Subject: [PATCH] Tabs replaced by spaces ! The presence of tabs can be checked with 'rubocop --only Tab --format files' --- dev/pre-commit-hook.rb | 30 ++++++------ lib/common/models/vulnerability.rb | 22 ++++----- lib/common/models/vulnerability/output.rb | 12 ++--- lib/common/models/vulnerability/urls.rb | 46 +++++++++---------- lib/common/models/wp_item/output.rb | 6 +-- lib/common/version_compare.rb | 2 +- .../plugins/checker/checker_spelling.rb | 6 +-- spec/lib/common/models/vulnerability_spec.rb | 24 +++++----- spec/lib/common/models/wp_item_spec.rb | 16 +++---- spec/lib/common/models/wp_plugin_spec.rb | 16 +++---- spec/lib/common/models/wp_theme_spec.rb | 16 +++---- spec/lib/common/models/wp_version_spec.rb | 16 +++---- 12 files changed, 106 insertions(+), 106 deletions(-) diff --git a/dev/pre-commit-hook.rb b/dev/pre-commit-hook.rb index 925c80d4..af3e6079 100755 --- a/dev/pre-commit-hook.rb +++ b/dev/pre-commit-hook.rb @@ -6,16 +6,16 @@ require 'pty' html_path = 'rspec_results.html' begin - PTY.spawn( "rspec spec --format h > #{html_path}" ) do |stdin, stdout, pid| - begin - stdin.each { |line| print line } + PTY.spawn( "rspec spec --format h > #{html_path}" ) do |stdin, stdout, pid| + begin + stdin.each { |line| print line } rescue Errno::EIO => e puts "Error: #{e.to.s}" return 1 - end - end + end + end rescue PTY::ChildExited - puts 'Child process exit!' + puts 'Child process exit!' end # find out if there were any errors @@ -23,18 +23,18 @@ html = open(html_path).read examples = html.match(/(\d+) examples/)[0].to_i rescue 0 errors = html.match(/(\d+) errors/)[0].to_i rescue 0 if errors == 0 then - errors = html.match(/(\d+) failure/)[0].to_i rescue 0 + errors = html.match(/(\d+) failure/)[0].to_i rescue 0 end pending = html.match(/(\d+) pending/)[0].to_i rescue 0 if errors.zero? - puts "0 failed! #{examples} run, #{pending} pending" - sleep 1 - exit 0 + puts "0 failed! #{examples} run, #{pending} pending" + sleep 1 + exit 0 else - puts "\aCOMMIT FAILED!!" - puts "View your rspec results at #{File.expand_path(html_path)}" - puts - puts "#{errors} failed! #{examples} run, #{pending} pending" - exit 1 + puts "\aCOMMIT FAILED!!" + puts "View your rspec results at #{File.expand_path(html_path)}" + puts + puts "#{errors} failed! #{examples} run, #{pending} pending" + exit 1 end diff --git a/lib/common/models/vulnerability.rb b/lib/common/models/vulnerability.rb index e4383bb1..371bf71f 100755 --- a/lib/common/models/vulnerability.rb +++ b/lib/common/models/vulnerability.rb @@ -5,7 +5,7 @@ require 'vulnerability/urls' class Vulnerability include Vulnerability::Output - include Vulnerability::Urls + include Vulnerability::Urls attr_accessor :title, :references, :type, :fixed_in @@ -41,16 +41,16 @@ class Vulnerability # # @return [ Vulnerability ] def self.load_from_xml_node(xml_node) - references = {} - refs = xml_node.search('references') - if refs - references[:url] = refs.search('url').map(&:text) - references[:cve] = refs.search('cve').map(&:text) - references[:secunia] = refs.search('secunia').map(&:text) - references[:osvdb] = refs.search('osvdb').map(&:text) - references[:metasploit] = refs.search('metasploit').map(&:text) - references[:exploitdb] = refs.search('exploitdb').map(&:text) - end + references = {} + refs = xml_node.search('references') + if refs + references[:url] = refs.search('url').map(&:text) + references[:cve] = refs.search('cve').map(&:text) + references[:secunia] = refs.search('secunia').map(&:text) + references[:osvdb] = refs.search('osvdb').map(&:text) + references[:metasploit] = refs.search('metasploit').map(&:text) + references[:exploitdb] = refs.search('exploitdb').map(&:text) + end new( xml_node.search('title').text, xml_node.search('type').text, diff --git a/lib/common/models/vulnerability/output.rb b/lib/common/models/vulnerability/output.rb index 8f4aac2c..94ff5503 100644 --- a/lib/common/models/vulnerability/output.rb +++ b/lib/common/models/vulnerability/output.rb @@ -8,12 +8,12 @@ class Vulnerability puts ' |' puts ' | ' + red("* Title: #{title}") references.each do |key, urls| - methodname = "url_#{key}" - urls.each do |u| - url = send(methodname, u) - puts ' | ' + red("* Reference: #{url}") if url - end - end + methodname = "url_#{key}" + urls.each do |u| + url = send(methodname, u) + puts ' | ' + red("* Reference: #{url}") if url + end + end if !fixed_in.empty? puts " | * Fixed in: #{fixed_in}" end diff --git a/lib/common/models/vulnerability/urls.rb b/lib/common/models/vulnerability/urls.rb index 2a6cf967..7c0b309f 100644 --- a/lib/common/models/vulnerability/urls.rb +++ b/lib/common/models/vulnerability/urls.rb @@ -1,33 +1,33 @@ # encoding: UTF-8 class Vulnerability - module Urls - # @return [ String ] The url to the metasploit module page - def url_metasploit(module_path) - # remove leading slash - module_path = module_path.sub(/^\//, '') - "http://www.metasploit.com/modules/#{module_path}" - end + module Urls + # @return [ String ] The url to the metasploit module page + def url_metasploit(module_path) + # remove leading slash + module_path = module_path.sub(/^\//, '') + "http://www.metasploit.com/modules/#{module_path}" + end - def url_url(url) - url - end + def url_url(url) + url + end - def url_cve(cve) - "http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-#{cve}" - end + def url_cve(cve) + "http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-#{cve}" + end - def url_osvdb(id) - "http://osvdb.org/#{id}" - end + def url_osvdb(id) + "http://osvdb.org/#{id}" + end - def url_secunia(id) - "http://secunia.com/advisories/#{id}" - end + def url_secunia(id) + "http://secunia.com/advisories/#{id}" + end - def url_exploitdb(id) - "http://www.exploit-db.com/exploits/#{id}/" - end + def url_exploitdb(id) + "http://www.exploit-db.com/exploits/#{id}/" + end - end + end end \ No newline at end of file diff --git a/lib/common/models/wp_item/output.rb b/lib/common/models/wp_item/output.rb index 80c6daf7..1701831b 100644 --- a/lib/common/models/wp_item/output.rb +++ b/lib/common/models/wp_item/output.rb @@ -13,9 +13,9 @@ class WpItem puts " | Readme: #{readme_url}" if has_readme? puts " | Changelog: #{changelog_url}" if has_changelog? - if respond_to?(:additional_output) - additional_output(verbose) - end + if respond_to?(:additional_output) + additional_output(verbose) + end vulnerabilities.output diff --git a/lib/common/version_compare.rb b/lib/common/version_compare.rb index fc4e322f..fa3a98ba 100644 --- a/lib/common/version_compare.rb +++ b/lib/common/version_compare.rb @@ -22,5 +22,5 @@ class VersionCompare raise end return false - end + end end diff --git a/lib/wpstools/plugins/checker/checker_spelling.rb b/lib/wpstools/plugins/checker/checker_spelling.rb index 1ef0fa3c..5dda1c44 100644 --- a/lib/wpstools/plugins/checker/checker_spelling.rb +++ b/lib/wpstools/plugins/checker/checker_spelling.rb @@ -36,10 +36,10 @@ class CheckerSpelling < Plugin file.close end - end + end - puts - puts "[+] Found #{mistakes} spelling mistakes" + puts + puts "[+] Found #{mistakes} spelling mistakes" mistakes end diff --git a/spec/lib/common/models/vulnerability_spec.rb b/spec/lib/common/models/vulnerability_spec.rb index 3002c692..c05b4f12 100644 --- a/spec/lib/common/models/vulnerability_spec.rb +++ b/spec/lib/common/models/vulnerability_spec.rb @@ -21,10 +21,10 @@ describe Vulnerability do context 'with fixed version argument' do let(:fixed_version) { '1.0' } - its(:title) { should be title } - its(:references) { should be references } - its(:type) { should be type } - its(:fixed_in) { should be fixed_version } + its(:title) { should be title } + its(:references) { should be references } + its(:type) { should be type } + its(:fixed_in) { should be fixed_version } end end @@ -35,14 +35,14 @@ describe Vulnerability do xml(MODELS_FIXTURES + '/vulnerability/xml_node.xml').xpath('//vulnerability') } - expected_refs = { - :url=>['Ref 1', 'Ref 2'], - :cve=>['2011-001'], - :secunia=>['secunia'], - :osvdb=>['osvdb'], - :metasploit=>['exploit/ex1'], - :exploitdb=>['exploitdb'] - } + expected_refs = { + :url=>['Ref 1', 'Ref 2'], + :cve=>['2011-001'], + :secunia=>['secunia'], + :osvdb=>['osvdb'], + :metasploit=>['exploit/ex1'], + :exploitdb=>['exploitdb'] + } its(:title) { should == 'Vuln Title' } its(:type) { should == 'CSRF' } diff --git a/spec/lib/common/models/wp_item_spec.rb b/spec/lib/common/models/wp_item_spec.rb index bf0a9875..2849a805 100644 --- a/spec/lib/common/models/wp_item_spec.rb +++ b/spec/lib/common/models/wp_item_spec.rb @@ -13,14 +13,14 @@ describe WpItem do it_behaves_like 'WpItem::Vulnerable' do let(:vulns_file) { MODELS_FIXTURES + '/wp_item/vulnerable/items_vulns.xml' } let(:vulns_xpath) { "//item[@name='neo']/vulnerability" } - let(:expected_refs) { { - :url => ['Ref 1', 'Ref 2'], - :cve => ['2011-001'], - :secunia => ['secunia'], - :osvdb => ['osvdb'], - :metasploit => ['exploit/ex1'], - :exploitdb => ['exploitdb'] - } } + let(:expected_refs) { { + :url => ['Ref 1', 'Ref 2'], + :cve => ['2011-001'], + :secunia => ['secunia'], + :osvdb => ['osvdb'], + :metasploit => ['exploit/ex1'], + :exploitdb => ['exploitdb'] + } } let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new("I'm the one", 'XSS', expected_refs) } end diff --git a/spec/lib/common/models/wp_plugin_spec.rb b/spec/lib/common/models/wp_plugin_spec.rb index 8a89879e..50dca22f 100644 --- a/spec/lib/common/models/wp_plugin_spec.rb +++ b/spec/lib/common/models/wp_plugin_spec.rb @@ -7,14 +7,14 @@ describe WpPlugin do it_behaves_like 'WpItem::Vulnerable' do let(:options) { { name: 'white-rabbit' } } let(:vulns_file) { MODELS_FIXTURES + '/wp_plugin/vulnerable/plugins_vulns.xml' } - let(:expected_refs) { { - :url => ['Ref 1', 'Ref 2'], - :cve => ['2011-001'], - :secunia => ['secunia'], - :osvdb => ['osvdb'], - :metasploit => ['exploit/ex1'], - :exploitdb => ['exploitdb'] - } } + let(:expected_refs) { { + :url => ['Ref 1', 'Ref 2'], + :cve => ['2011-001'], + :secunia => ['secunia'], + :osvdb => ['osvdb'], + :metasploit => ['exploit/ex1'], + :exploitdb => ['exploitdb'] + } } let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('Follow me!', 'REDIRECT', expected_refs) } end diff --git a/spec/lib/common/models/wp_theme_spec.rb b/spec/lib/common/models/wp_theme_spec.rb index cf5174b3..328fc8fa 100644 --- a/spec/lib/common/models/wp_theme_spec.rb +++ b/spec/lib/common/models/wp_theme_spec.rb @@ -12,14 +12,14 @@ describe WpTheme do it_behaves_like 'WpItem::Vulnerable' do let(:options) { { name: 'the-oracle' } } let(:vulns_file) { MODELS_FIXTURES + '/wp_theme/vulnerable/themes_vulns.xml' } - let(:expected_refs) { { - :url => ['Ref 1', 'Ref 2'], - :cve => ['2011-001'], - :secunia => ['secunia'], - :osvdb => ['osvdb'], - :metasploit => ['exploit/ex1'], - :exploitdb => ['exploitdb'] - } } + let(:expected_refs) { { + :url => ['Ref 1', 'Ref 2'], + :cve => ['2011-001'], + :secunia => ['secunia'], + :osvdb => ['osvdb'], + :metasploit => ['exploit/ex1'], + :exploitdb => ['exploitdb'] + } } let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('I see you', 'FPD', expected_refs) } end diff --git a/spec/lib/common/models/wp_version_spec.rb b/spec/lib/common/models/wp_version_spec.rb index 6e43a24f..85387fb6 100644 --- a/spec/lib/common/models/wp_version_spec.rb +++ b/spec/lib/common/models/wp_version_spec.rb @@ -7,14 +7,14 @@ describe WpVersion do it_behaves_like 'WpItem::Vulnerable' do let(:options) { { number: '3.2' } } let(:vulns_file) { MODELS_FIXTURES + '/wp_version/vulnerable/versions_vulns.xml' } - let(:expected_refs) { { - :url => ['Ref 1', 'Ref 2'], - :cve => ['2011-001'], - :secunia => ['secunia'], - :osvdb => ['osvdb'], - :metasploit => ['exploit/ex1'], - :exploitdb => ['exploitdb'] - } } + let(:expected_refs) { { + :url => ['Ref 1', 'Ref 2'], + :cve => ['2011-001'], + :secunia => ['secunia'], + :osvdb => ['osvdb'], + :metasploit => ['exploit/ex1'], + :exploitdb => ['exploitdb'] + } } let(:expected_vulns) { Vulnerabilities.new << Vulnerability.new('Here I Am', 'SQLI', expected_refs) } end