recog 2.0.14 → 2.0.15

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: 2d08dc173999e1694bdc5f102a28be119f4e8866
4
- data.tar.gz: 46283f711629cc12bb944b02cfe6ce1bbfc1f5d5
3
+ metadata.gz: 81ca81c5892d0fb7882afdb14f8c6e0324196cbb
4
+ data.tar.gz: 793218a1570ce08ee7e3c0895b1c5822e5f49922
5
5
  SHA512:
6
- metadata.gz: 44b5b348c47caefd5998d36fa2439e64b05ae679daba22a58014d484b1a55baa0348b301ecbe3ccfeea337ca5fd2afb35b94580ebefa0f2161284f69d22c4c76
7
- data.tar.gz: ab0237e095304a36ae8b72f1afbbb9abb6e2fd4423af1d8e071546c178eb3e547355c70b8f9ea4ec78a1e38738fe4b582b9e36a1ebf0ea0bbf9e8d3e3a63c060
6
+ metadata.gz: fa6edf956ca223ea34ebd8c39a6a2e4a471b3f225d9642ba83e4e945ce4135f0691b64b67b767d48b557df83c474563ccf7ff28f11e77bac5007a6607cc81272
7
+ data.tar.gz: 9e9045604f3a260422e0002bf63d565ebedad35ab1a2afb99775a2bb28bf70d459ed9330feba2742c1f1b118daf421c2965b7c11498c30de02c406dc967a4831
data/bin/recog_verify CHANGED
@@ -6,7 +6,7 @@ require 'ostruct'
6
6
  require 'recog'
7
7
  require 'recog/verifier_factory'
8
8
 
9
- options = OpenStruct.new(color: false, detail: false)
9
+ options = OpenStruct.new(color: false, detail: false, quiet: false, warnings: true)
10
10
 
11
11
  option_parser = OptionParser.new do |opts|
12
12
  opts.banner = "Usage: #{$0} [options] XML_FINGERPRINT_FILE1 ..."
@@ -17,16 +17,24 @@ option_parser = OptionParser.new do |opts|
17
17
  opts.on("-f", "--format FORMATTER",
18
18
  "Choose a formatter.",
19
19
  " [s]ummary (default - failure/warning msgs and summary)",
20
+ " [q]uiet (configured failure/warning msgs only)",
20
21
  " [d]etail (fingerprint name with tests and expanded summary)") do |format|
21
22
  if format.start_with? 'd'
22
23
  options.detail = true
23
24
  end
25
+ if format.start_with? 'q'
26
+ options.quiet = true
27
+ end
24
28
  end
25
29
 
26
30
  opts.on("-c", "--color", "Enable color in the output.") do
27
31
  options.color = true
28
32
  end
29
33
 
34
+ opts.on("--[no-]warnings", "Track warnings") do |o|
35
+ options.warnings = o
36
+ end
37
+
30
38
  opts.on("-h", "--help", "Show this message.") do
31
39
  puts opts
32
40
  exit
@@ -40,9 +48,17 @@ if ARGV.empty?
40
48
  exit(1)
41
49
  end
42
50
 
43
- ARGV.each do |file|
44
- ndb = Recog::DB.new(file)
45
- options.fingerprints = ndb.fingerprints
46
- verifier = Recog::VerifierFactory.build(options)
47
- verifier.verify_tests
51
+ warnings = 0
52
+ failures = 0
53
+ ARGV.each do |arg|
54
+ Dir.glob(arg).each do |file|
55
+ ndb = Recog::DB.new(file)
56
+ options.fingerprints = ndb.fingerprints
57
+ verifier = Recog::VerifierFactory.build(options)
58
+ verified = verifier.verify
59
+ failures += verifier.reporter.failure_count
60
+ warnings += verifier.reporter.warning_count
61
+ end
48
62
  end
63
+
64
+ exit failures + warnings
@@ -10,11 +10,11 @@
10
10
  <!-- Fail: doesn't match -->
11
11
  <example>This almost matches</example>
12
12
  </fingerprint>
13
- <fingerprint pattern="^bar ([\d.]+)$">
13
+ <fingerprint pattern="^(\S+) ([\d.]+)$">
14
14
  <description>bar test</description>
15
15
  <!-- Fail: expected os.version doesn't match the capture group -->
16
16
  <example os.version="5.0" >bar 1.0</example>
17
- <param pos="1" name="os.version" />
18
- <param pos="0" name="os.name" value="Bar" />
17
+ <param pos="2" name="os.version" />
18
+ <param pos="1" name="os.name" value="Bar" />
19
19
  </fingerprint>
20
20
  </fingerprints>
@@ -13,22 +13,32 @@ Feature: Verify
13
13
  SUMMARY: Test completed with 4 successful, 0 warnings, and 0 failures
14
14
  """
15
15
 
16
- Scenario: Tests with warnings
16
+ Scenario: Tests with warnings, warnings enabled
17
17
  When I run `recog_verify tests_with_warnings.xml`
18
- Then it should pass with:
18
+ Then it should fail with:
19
19
  """
20
20
  WARN: 'Pure-FTPd' has no test cases
21
21
  SUMMARY: Test completed with 1 successful, 1 warnings, and 0 failures
22
22
  """
23
+ And the exit status should be 1
24
+
25
+ Scenario: Tests with warnings, warnings disabled
26
+ When I run `recog_verify --no-warnings tests_with_warnings.xml`
27
+ Then it should pass with:
28
+ """
29
+ SUMMARY: Test completed with 1 successful, 0 warnings, and 0 failures
30
+ """
23
31
 
24
32
  Scenario: Tests with failures
25
33
  When I run `recog_verify tests_with_failures.xml`
26
- Then it should pass with:
34
+ Then it should fail with:
27
35
  """
28
36
  FAIL: 'foo test' failed to match "bar" with (?-mix:^foo$)'
29
37
  FAIL: '' failed to match "This almost matches" with (?-mix:^This matches$)'
38
+ FAIL: 'bar test's os.name is a non-zero pos but specifies a value of 'Bar'
30
39
  FAIL: 'bar test' failed to find expected capture group os.version '5.0'
31
- SUMMARY: Test completed with 0 successful, 0 warnings, and 3 failures
40
+ SUMMARY: Test completed with 0 successful, 0 warnings, and 4 failures
32
41
  """
42
+ And the exit status should be 4
33
43
 
34
44
 
@@ -61,6 +61,21 @@ class Fingerprint
61
61
  return result
62
62
  end
63
63
 
64
+ # Ensure all the {#params} are valid
65
+ #
66
+ # @yieldparam status [Symbol] One of `:warn`, `:fail`, or `:success` to
67
+ # indicate whether a param is valid
68
+ # @yieldparam message [String] A human-readable string explaining the
69
+ # `status`
70
+ def verify_params(&block)
71
+ return if params.empty?
72
+ params.each do |param_name, pos_value|
73
+ pos, value = pos_value
74
+ next unless pos != 0 && !value.to_s.empty?
75
+ yield :fail, "'#{@name}'s #{param_name} is a non-zero pos but specifies a value of '#{value}'"
76
+ end
77
+ end
78
+
64
79
  # Ensure all the {#tests} actually match the fingerprint and return the
65
80
  # expected capture groups.
66
81
  #
@@ -12,7 +12,7 @@ class MatchReporter
12
12
  def report
13
13
  reset_counts
14
14
  yield self
15
- summarize
15
+ summarize unless @options.quiet
16
16
  end
17
17
 
18
18
  def stop?
@@ -7,11 +7,21 @@ class Verifier
7
7
  @reporter = reporter
8
8
  end
9
9
 
10
- def verify_tests
10
+ def verify
11
11
  reporter.report(fingerprints.count) do
12
12
  fingerprints.each do |fp|
13
13
  reporter.print_name fp
14
14
 
15
+ fp.verify_params do |status, message|
16
+ case status
17
+ when :warn
18
+ reporter.warning "WARN: #{message}"
19
+ when :fail
20
+ reporter.failure "FAIL: #{message}"
21
+ when :success
22
+ reporter.success(message)
23
+ end
24
+ end
15
25
  fp.verify_tests do |status, message|
16
26
  case status
17
27
  when :warn
@@ -21,9 +31,7 @@ class Verifier
21
31
  when :success
22
32
  reporter.success(message)
23
33
  end
24
-
25
34
  end
26
-
27
35
  end
28
36
  end
29
37
  end
@@ -12,7 +12,7 @@ class VerifyReporter
12
12
  def report(fingerprint_count)
13
13
  reset_counts
14
14
  yield self
15
- summarize(fingerprint_count)
15
+ summarize(fingerprint_count) unless @options.quiet
16
16
  end
17
17
 
18
18
  def success(text)
@@ -21,6 +21,7 @@ class VerifyReporter
21
21
  end
22
22
 
23
23
  def warning(text)
24
+ return unless @options.warnings
24
25
  @warning_count += 1
25
26
  formatter.warning_message("#{padding}#{text}")
26
27
  end
data/lib/recog/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Recog
2
- VERSION = '2.0.14'
2
+ VERSION = '2.0.15'
3
3
  end
@@ -23,9 +23,3 @@ Windows 7 Starter 7601 Service Pack 1
23
23
  Windows 7 Home Premium 7600
24
24
  Windows 7 Enterprise 7601 Service Pack 1
25
25
  Windows 7 Enterprise 7600
26
- Samba 3.6.9-151.el6_4.1
27
- Samba 3.6.6
28
- Samba 3.6.3
29
- Samba 3.0.32-0.2-2210-SUSE-SL10.3
30
- Samba 3.0.28a
31
- Samba 3.0.24
@@ -1,7 +1,7 @@
1
1
  require 'recog/match_reporter'
2
2
 
3
3
  describe Recog::MatchReporter do
4
- let(:options) { double(detail: false) }
4
+ let(:options) { double(detail: false, quiet: false) }
5
5
  let(:formatter) { double('formatter').as_null_object }
6
6
  subject { Recog::MatchReporter.new(options, formatter) }
7
7
 
@@ -25,7 +25,7 @@ describe Recog::MatchReporter do
25
25
  end
26
26
 
27
27
  context "with detail" do
28
- subject { Recog::MatchReporter.new(double(detail: true), formatter) }
28
+ subject { Recog::MatchReporter.new(double(detail: true, quiet: false), formatter) }
29
29
 
30
30
  it "prints the lines processed" do
31
31
  expect(formatter).to receive(:status_message).with("\nProcessed 1 lines")
@@ -22,10 +22,6 @@ describe Recog::Nizer do
22
22
  if data =~ /^Windows/
23
23
  expect(match_result['os.product']).to match(/^Windows/)
24
24
  end
25
-
26
- if data =~ /^Samba/
27
- expect(match_result['service.product']).to match(/^Samba/)
28
- end
29
25
  end
30
26
 
31
27
  end
@@ -8,7 +8,7 @@ describe Recog::VerifyReporter do
8
8
  "SUMMARY: Test completed with 1 successful, 1 warnings, and 1 failures"
9
9
  end
10
10
 
11
- subject { Recog::VerifyReporter.new(double(detail: false), formatter) }
11
+ subject { Recog::VerifyReporter.new(double(detail: false, quiet: false, warnings: true), formatter) }
12
12
 
13
13
  def run_report
14
14
  subject.report(1) do
@@ -36,7 +36,7 @@ describe Recog::VerifyReporter do
36
36
  end
37
37
 
38
38
  context "with detail" do
39
- subject { Recog::VerifyReporter.new(double(detail: true), formatter) }
39
+ subject { Recog::VerifyReporter.new(double(detail: true, quiet: false, warnings: true), formatter) }
40
40
 
41
41
  it "prints the fingerprint name" do
42
42
  expect(formatter).to receive(:status_message).with("\na name")
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ SMB fingerprints obtained from the Native LM (LAN manager) field of SMB
4
+ negotations
5
+ -->
6
+ <fingerprints matches="smb.native_lm">
7
+ <!-- Mac OS X -->
8
+ <fingerprint pattern="^Samba (3\.0\.28a-apple)$">
9
+ <description>Samba on OS X 10.6</description>
10
+ <example service.version="3.0.28a-apple">Samba 3.0.28a-apple</example>
11
+ <param pos="0" name="os.vendor" value="Apple"/>
12
+ <param pos="0" name="os.family" value="Mac OS X"/>
13
+ <param pos="0" name="os.product" value="Mac OS X"/>
14
+ <param pos="0" name="os.device" value="General"/>
15
+ <param pos="0" name="os.version" value="10.6"/>
16
+ <param pos="0" name="service.vendor" value="Samba"/>
17
+ <param pos="0" name="service.product" value="Samba"/>
18
+ <param pos="1" name="service.version"/>
19
+ </fingerprint>
20
+ <fingerprint pattern="^Samba (3\.0\.25b-apple)$">
21
+ <description>Samba on OS X 10.5</description>
22
+ <example service.version="3.0.25b-apple">Samba 3.0.25b-apple</example>
23
+ <param pos="0" name="os.vendor" value="Apple"/>
24
+ <param pos="0" name="os.family" value="Mac OS X"/>
25
+ <param pos="0" name="os.product" value="Mac OS X"/>
26
+ <param pos="0" name="os.device" value="General"/>
27
+ <param pos="0" name="os.version" value="10.5"/>
28
+ <param pos="0" name="service.vendor" value="Samba"/>
29
+ <param pos="0" name="service.product" value="Samba"/>
30
+ <param pos="1" name="service.version"/>
31
+ </fingerprint>
32
+ <!-- TODO: Detect vendor, distribution, and package versions -->
33
+ <fingerprint pattern="^Samba (\d\.\d+.\d+\w*)">
34
+ <description>Samba</description>
35
+ <example>Samba 3.0.24</example>
36
+ <example>Samba 3.0.28a</example>
37
+ <example>Samba 3.0.32-0.2-2210-SUSE-SL10.3</example>
38
+ <example>Samba 3.6.3</example>
39
+ <example>Samba 3.6.6</example>
40
+ <example>Samba 3.6.9-151.el6_4.1</example>
41
+ <param pos="0" name="service.vendor" value="Samba"/>
42
+ <param pos="0" name="service.product" value="Samba"/>
43
+ <param pos="1" name="service.version"/>
44
+ </fingerprint>
45
+ </fingerprints>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!--
3
- SMB Native OS Fingerprints
3
+ SMB fingerprints obtained from the Native OS field of SMB negotations
4
4
  -->
5
5
  <fingerprints matches="smb.native_os">
6
6
  <fingerprint pattern="^(Windows NT \d\.\d+)$">
@@ -342,44 +342,6 @@
342
342
  <param pos="1" name="os.edition"/>
343
343
  <param pos="2" name="os.build"/>
344
344
  </fingerprint>
345
- <!-- Mac OS X -->
346
- <fingerprint pattern="^Samba (3\.0\.28a-apple)$">
347
- <description>Samba on OS X 10.6</description>
348
- <example service.version="3.0.28a-apple">Samba 3.0.28a-apple</example>
349
- <param pos="0" name="os.vendor" value="Apple"/>
350
- <param pos="0" name="os.family" value="Mac OS X"/>
351
- <param pos="0" name="os.product" value="Mac OS X"/>
352
- <param pos="0" name="os.device" value="General"/>
353
- <param pos="0" name="os.version" value="10.6"/>
354
- <param pos="0" name="service.vendor" value="Samba"/>
355
- <param pos="0" name="service.product" value="Samba"/>
356
- <param pos="1" name="service.version"/>
357
- </fingerprint>
358
- <fingerprint pattern="^Samba (3\.0\.25b-apple)$">
359
- <description>Samba on OS X 10.5</description>
360
- <example service.version="3.0.25b-apple">Samba 3.0.25b-apple</example>
361
- <param pos="0" name="os.vendor" value="Apple"/>
362
- <param pos="0" name="os.family" value="Mac OS X"/>
363
- <param pos="0" name="os.product" value="Mac OS X"/>
364
- <param pos="0" name="os.device" value="General"/>
365
- <param pos="0" name="os.version" value="10.5"/>
366
- <param pos="0" name="service.vendor" value="Samba"/>
367
- <param pos="0" name="service.product" value="Samba"/>
368
- <param pos="1" name="service.version"/>
369
- </fingerprint>
370
- <!-- TODO: Detect vendor, distribution, and package versions -->
371
- <fingerprint pattern="^Samba (\d\.\d+.\d+\w*)">
372
- <description>Samba</description>
373
- <example>Samba 3.0.24</example>
374
- <example>Samba 3.0.28a</example>
375
- <example>Samba 3.0.32-0.2-2210-SUSE-SL10.3</example>
376
- <example>Samba 3.6.3</example>
377
- <example>Samba 3.6.6</example>
378
- <example>Samba 3.6.9-151.el6_4.1</example>
379
- <param pos="0" name="service.vendor" value="Samba"/>
380
- <param pos="0" name="service.product" value="Samba"/>
381
- <param pos="1" name="service.version"/>
382
- </fingerprint>
383
345
  <fingerprint pattern="^VxWorks">
384
346
  <description>VxWorks</description>
385
347
  <example>VxWorks</example>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recog
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rapid7 Research
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -197,6 +197,7 @@ files:
197
197
  - xml/rsh_resp.xml
198
198
  - xml/sip_banners.xml
199
199
  - xml/sip_user_agents.xml
200
+ - xml/smb_native_lm.xml
200
201
  - xml/smb_native_os.xml
201
202
  - xml/smtp_banners.xml
202
203
  - xml/smtp_debug.xml