ruby-spfquery 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f0cd8814b31a048b4a436bb2c403140b0e87427
4
+ data.tar.gz: e76faa4024ffb19277651a78cec0a7266388ea3a
5
+ SHA512:
6
+ metadata.gz: d491470aaaf1848581f32eff285ad96d1aa4324964d3c82eb4dc64375fccb5afaca3f585bf34ace2f29720fd683373f87bb8e21f1f6ab9666705454effdcb36d
7
+ data.tar.gz: 0b1d070b17c8e4f2a8d546c0a0eb274de8f48680c7c031b0c498049218aebb5a12648562c99849b7aba4779eeac35fe887dfba221fcf963191985e6ee9b3af6c
@@ -1,4 +1,5 @@
1
1
  require 'stringio'
2
+ require 'open3'
2
3
 
3
4
  class Spfquery
4
5
  attr_reader :ip, :sender, :helo
@@ -18,7 +19,13 @@ class Spfquery
18
19
  end
19
20
 
20
21
  def result
21
- @result ||= output.lines.first.chomp.downcase
22
+ @result ||= begin
23
+ if line = output.lines.first
24
+ line.chomp.downcase
25
+ else
26
+ 'none'
27
+ end
28
+ end
22
29
  end
23
30
 
24
31
  private
@@ -28,6 +35,10 @@ class Spfquery
28
35
  end
29
36
 
30
37
  def run_spfquery
31
- `spfquery --ip=#{ip} --sender=#{sender} #{" --helo=#{helo}" if helo} 2>/dev/null`
38
+ args = ['spfquery', "--ip=#{ip}", "--sender=#{sender}"]
39
+ args << "--helo=#{helo}" if helo
40
+ Open3.popen3(*args) do |stdin, stdout, stderr, wait_thr|
41
+ stdout.read
42
+ end
32
43
  end
33
44
  end
@@ -1,3 +1,3 @@
1
1
  class Spfquery
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -4,7 +4,7 @@ require 'spfquery/version'
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "ruby-spfquery"
7
- gem.version = '0.0.1'
7
+ gem.version = Spfquery::VERSION
8
8
  gem.authors = ['Brett Gibson']
9
9
  gem.email = ['bdg@brettdgibson.com']
10
10
  gem.description = %q{very thin ruby wrapper for spfquery cli}
@@ -33,8 +33,8 @@ describe Spfquery do
33
33
  it 'handles none' do
34
34
  Spfquery.new('1.1.1.1', 'abc@probably-wont-have-spf.org').result.must_equal 'none'
35
35
  end
36
- it 'handles neutral' do
37
- Spfquery.new('1.1.1.1', 'abc@gmail.com').result.must_equal 'neutral'
36
+ it 'handles softfail' do
37
+ Spfquery.new('1.1.1.1', 'abc@gmail.com').result.must_equal 'softfail'
38
38
  end
39
39
  it 'handles fail' do
40
40
  Spfquery.new('1.1.1.1', 'abc@example.org').result.must_equal 'fail'
@@ -43,6 +43,11 @@ describe Spfquery do
43
43
  Spfquery.new(VALID_OUTLOOK_IP, 'abc@outlook.com').result.must_equal 'pass'
44
44
  Spfquery.new(VALID_OUTLOOK_IP, 'abc@example.org', 'outlook.com').result.must_equal 'pass'
45
45
  end
46
+
47
+ it 'should not allow shell injection' do
48
+ Spfquery.new(';say "this cannot be good";', 'abc').result.must_equal 'none'
49
+ Spfquery.new('1.1.1.1', ';echo pass').result.must_equal 'none'
50
+ end
46
51
  end
47
52
 
48
53
  describe '#pass?' do
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-spfquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brett Gibson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: very thin ruby wrapper for spfquery cli
15
14
  email:
@@ -29,27 +28,26 @@ files:
29
28
  - test/spfquery_test.rb
30
29
  homepage:
31
30
  licenses: []
31
+ metadata: {}
32
32
  post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
36
36
  required_ruby_version: !ruby/object:Gem::Requirement
37
- none: false
38
37
  requirements:
39
- - - ! '>='
38
+ - - '>='
40
39
  - !ruby/object:Gem::Version
41
40
  version: 1.9.2
42
41
  required_rubygems_version: !ruby/object:Gem::Requirement
43
- none: false
44
42
  requirements:
45
- - - ! '>='
43
+ - - '>='
46
44
  - !ruby/object:Gem::Version
47
45
  version: '0'
48
46
  requirements: []
49
47
  rubyforge_project:
50
- rubygems_version: 1.8.23
48
+ rubygems_version: 2.0.14
51
49
  signing_key:
52
- specification_version: 3
50
+ specification_version: 4
53
51
  summary: very thin ruby wrapper for spfquery cli
54
52
  test_files:
55
53
  - test/spfquery_test.rb