sonar-client 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 820db139f2824907be22a0f34c228fa5d9175f33
4
- data.tar.gz: 5d3f107c6d8e627891c4de9e3b2e4886dcb19d8e
3
+ metadata.gz: 46f4c95ec260a3eb4b212c2f85c4bee5893dc461
4
+ data.tar.gz: 4a574ae9f388f0db79f28e80e9dc69b9c97de3eb
5
5
  SHA512:
6
- metadata.gz: d1ceabcd6de7dfbf8e8d985413ed05e3c873a4e94df64ef3be6ffbb01330a6f455df8f9104c7b4b165b8d7cbad591ac518f7ea4f84465a48cf9f87531dd43f5b
7
- data.tar.gz: d3b32283cb878fbad817379ce73d3ecf520701295a133c755d3c5c0adfa5731b4d484369f411b36e663083d53e517c94b57bddd3e0e30be83eb8827ca1447128
6
+ metadata.gz: 8056aa52de648957853d67ad2ebcdb8168e4ee586dc8dfe0bdab2e6ef9d638f6caac2ae142c4eceffd9c598f0e17e402179bfad8a71df5d700b94dbce477b852
7
+ data.tar.gz: 66db84c021545e129f001839cb8de8e56b221175bbbb202df443d8f35e92ee5dd344c34dbb5ec034599abededc92f805a9d4cdea2b979d9c28a3a180aca684c0
data/bin/sonar CHANGED
@@ -5,7 +5,9 @@ require 'bundler/setup'
5
5
  require 'sonar'
6
6
 
7
7
  begin
8
- exit(Sonar::CLI.start(ARGV))
8
+ Sonar::CLI.start(ARGV)
9
+ rescue Sonar::Search::SearchError => e
10
+ exit 1
9
11
  rescue Interrupt
10
12
  puts 'Quitting...'
11
13
  end
@@ -46,7 +46,7 @@ module Sonar
46
46
  print_json(cleanup_data(resp), options['format'])
47
47
  end
48
48
 
49
- return errors
49
+ raise Search::SearchError.new("Encountered #{errors} errors while searching") if errors > 0
50
50
  end
51
51
 
52
52
  desc 'types', 'List all Sonar query types'
@@ -18,6 +18,12 @@ module Sonar
18
18
  'whois_ip' => 'Whois (IP)'
19
19
  }
20
20
 
21
+ ##
22
+ # Generic exception for errors encountered while searching
23
+ ##
24
+ class SearchError < StandardError
25
+ end
26
+
21
27
  ##
22
28
  # Get search
23
29
  #
@@ -1,3 +1,3 @@
1
1
  module Sonar
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -6,13 +6,8 @@ describe Sonar::CLI do
6
6
  before do
7
7
  Sonar::RCFile.instance.path = "#{fixtures_path}/sonar-stock.rc"
8
8
  end
9
- it 'warns user of missing config values when trying to search' do
10
- output, _ = run_command('search rdns 8.8.8.8')
11
- expect(output).to match(/Could not authenticate/)
12
- end
13
- it 'exits non-zero when errors are encountered' do
14
- _, ret = run_command('search rdns 8.8.8.8')
15
- expect(ret).to eq(1)
9
+ it 'throws an exception because of errors' do
10
+ expect { run_command('search rdns 8.8.8.8') }.to raise_error(Sonar::Search::SearchError)
16
11
  end
17
12
  end
18
13
 
@@ -21,7 +16,7 @@ describe Sonar::CLI do
21
16
  Sonar::RCFile.instance.path = "#{fixtures_path}/sonar.rc"
22
17
  end
23
18
  it "should return the profile" do
24
- output, _ = run_command('profile')
19
+ output = run_command('profile')
25
20
  expect(output).to match(/email@asdfasdfasfd.com/)
26
21
  end
27
22
 
@@ -32,11 +27,11 @@ describe Sonar::CLI do
32
27
  )
33
28
  end
34
29
  it 'strips whitespace from values' do
35
- output, _ = run_command('search rdns 8.8.8.8')
30
+ output = run_command('search rdns 8.8.8.8')
36
31
  expect(output).to eq('{"collection":[{"address":"192.168.1.1"}],"more":"false"}')
37
32
  end
38
33
  it 'can return lines format' do
39
- output, _ = run_command('search --format lines rdns 8.8.8.8')
34
+ output = run_command('search --format lines rdns 8.8.8.8')
40
35
  expect(output).to eq('{"address":"192.168.1.1"}')
41
36
  end
42
37
  end
@@ -47,7 +42,7 @@ describe Sonar::CLI do
47
42
  )
48
43
  end
49
44
  it 'parses the nested values in an array' do
50
- output, _ = run_command('search sslcert 152a0a633aaf13f02c428ac1a3e672e895512bfd')
45
+ output = run_command('search sslcert 152a0a633aaf13f02c428ac1a3e672e895512bfd')
51
46
  expect(JSON.parse(output)['collection'].first['details'].first['subject']['ST']).to eq('California')
52
47
  end
53
48
  end
@@ -58,7 +53,7 @@ describe Sonar::CLI do
58
53
  )
59
54
  end
60
55
  xit 'parses the nested value as a string' do
61
- output, _ = run_command('search processed 8.8.8.')
56
+ output = run_command('search processed 8.8.8.')
62
57
  expect(JSON.parse(output)['collection'].first['value']['ip']).to eq('8.8.8.8')
63
58
  end
64
59
  end
@@ -70,7 +65,7 @@ describe Sonar::CLI do
70
65
  )
71
66
  end
72
67
  it 'matches exactly with --exact' do
73
- output, _ = run_command('search fdns 208.118.227.20 --exact')
68
+ output = run_command('search fdns 208.118.227.20 --exact')
74
69
  expect(JSON.parse(output)['collection'].size).to be >= 1
75
70
  expect(JSON.parse(output)['collection'].any? { |c| c['name'] == '208.118.227.20' }).to be(true)
76
71
  end
@@ -82,7 +77,7 @@ describe Sonar::CLI do
82
77
  )
83
78
  end
84
79
  it 'matches exactly without --exact' do
85
- output, _ = run_command('search fdns 208.118.227.20')
80
+ output = run_command('search fdns 208.118.227.20')
86
81
  expect(JSON.parse(output)['collection'].size).to be > 1
87
82
  end
88
83
  end
@@ -90,8 +85,6 @@ describe Sonar::CLI do
90
85
  end
91
86
 
92
87
  def run_command(args)
93
- ret = 0
94
- output, _ = capture(:stdout) { ret = Sonar::CLI.start(args.split) }.strip
95
- [output, ret]
88
+ capture(:stdout) { ret = Sonar::CLI.start(args.split) }.strip
96
89
  end
97
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sonar-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Deardorff & HD Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware