google_safe_browsing 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f5b61271d81882c1bbaea1de9c42b0fcdfa7ae2b
4
+ data.tar.gz: 1ada1d0d3f7c6e6a4708c2d28a38e9e9e0a1a8a9
5
+ SHA512:
6
+ metadata.gz: fe03c531a15358f5098cff412c809533208161ac0a02a9f11469361a5c753733bc36302a78ee750da13a0706ee7a6cc350a65b0d94424385277db639b4d5692d
7
+ data.tar.gz: daf865df013d6d94d5ed184be4da95e41dcc52169ab74106cd98a43a61ac6d0b84c23b784cb56a365dbf0c0699f124422749bb9793affa8fa348081e5618a6af
data/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  This gem allows easy Google Safe Browsing APIv2 usage with optional integration
4
4
  into Rails 3 apps.
5
5
 
6
+ [![Build
7
+ Status](https://travis-ci.org/mobiledefense/google_safe_browsing.png)](https://travis-ci.org//mobiledefense/google_safe_browsing)
8
+
6
9
  It includes:
7
10
 
8
11
  * a migration generator for database schema
@@ -36,7 +39,8 @@ Then, generate the migration and run it
36
39
 
37
40
 
38
41
  Add your Google Safe Browsing API key to congif/application.rb
39
- You can get a key from the [Google Safe Browsing website](http://code.google.com/apis/safebrowsing/key_signup.html)
42
+ You can get a key from the [Google
43
+ Safe Browsing website](http://code.google.com/apis/safebrowsing/key_signup.html)
40
44
 
41
45
  #config/application.rb
42
46
 
@@ -51,10 +55,15 @@ You can run an update manually
51
55
 
52
56
  $ rake google_safe_browsing:update
53
57
 
54
- Or, if you have [Resque](https://github.com/defunkt/resque) and
55
- [Resque Scheduler](https://github.com/bvandenbos/resque-scheduler) set up, you can
56
- run an update and automatically schedule another update based on the 'next polling
57
- interval' parameter from the API
58
+ > Note: The full database is not guarenteed to be returned after a single update.
59
+ In fact, you aren't likely to have the full database even after several
60
+ updates. You will know that you have the full database when an update does
61
+ not return any new Add or Sub Shavars.
62
+
63
+ Or, if you have [Resque](https://github.com/defunkt/resque) and
64
+ [Resque Scheduler](https://github.com/bvandenbos/resque-scheduler) set up, you
65
+ can run an update and automatically schedule another update based on the 'next
66
+ polling interval' parameter from the API
58
67
 
59
68
  $ rake google_safe_browsing:update_and_reschedule
60
69
 
@@ -64,19 +73,55 @@ To programatically run an update in your app
64
73
 
65
74
  GoogleSafeBrowsing::APIv2.update
66
75
 
67
- Note: This can take a while, especially when first seeding your database. I wouldn't recommend
68
- calling this in a controller for a normal page request.
76
+ Note: This can take a while, especially when first seeding your database. I
77
+ wouldn't recommend calling this in a controller for a normal page request.
69
78
 
70
79
  To check a url for badness
71
80
 
72
81
  GoogleSafeBrowsing::APIv2.lookup('http://bad.url.address.here.com.edu/forProfit')
73
82
 
74
- The url string parameter does not have to be any specific format or Canonicalization the Google
75
- Safe Browsing gem will handle all of that for you. Please report any errors from a weirdly formatted
76
- url though. I most likely have missed some cases.
83
+ The url string parameter does not have to be any specific format or
84
+ Canonicalization the Google Safe Browsing gem will handle all of that for you.
85
+ Please report any errors from a weirdly formatted url though. I most likely
86
+ have missed some cases.
87
+
88
+ The `lookup` method returns a string ( either 'malware' or 'phishing' ) for
89
+ the name of the black list which the url appears on, or `nil` if the url is
90
+ not on Google's list.
91
+
92
+ ----------------
93
+
94
+ ## Contributing
95
+
96
+ We've already had some [great
97
+ contributers](https://github.com/mobiledefense/google_safe_browsing/graphs/contributors).
98
+ If you'd like to join us, we'd love to have you. When contributing please
99
+
100
+ 1. [Fork](https://github.com/mobiledefense/google_safe_browsing/fork) the repo
101
+ 1. Start a topic branch.
102
+ 1. Write awesome code!
103
+ 1. Please break your commits into logical units.
104
+ 1. Please add specs when necessary.
105
+ 1. Open a [Pull
106
+ Request](https://github.com/mobiledefense/google_safe_browsing/pulls)
107
+ 1. Make sure [Travis
108
+ CI](https://travis-ci.org/mobiledefense/google_safe_browsing)
109
+ builds the PR successfully.
110
+ 1. See your awesomeness merged in!
111
+
112
+ ### Running specs
113
+
114
+ We use [Rspec](http://rspec.info/) for unit testing. You can run the specs with
115
+ the following command:
116
+
117
+ bundle exec rake
118
+
119
+ Or individual specs/files:
120
+
121
+ bundle exec rspec spec/chunk_helper_spec.rb:10
122
+
77
123
 
78
- The `lookup` method returns a string ( either 'malware' or 'phishing' ) for the name of the black list
79
- which the url appears on, or `nil` if the url is not on Google's list.
124
+ Thanks for helping us make browsing safer!
80
125
 
81
126
  ----------------
82
127
 
@@ -13,12 +13,16 @@ module GoogleSafeBrowsing
13
13
  action_strings = []
14
14
 
15
15
 
16
- nums = GoogleSafeBrowsing::AddShavar.select('distinct chunk_number').where(:list => list).
17
- order(:chunk_number).collect{|c| c.chunk_number }
16
+ nums = GoogleSafeBrowsing::AddShavar.where(list: list)
17
+ .order(:chunk_number)
18
+ .select('distinct chunk_number')
19
+ .map(&:chunk_number)
18
20
  action_strings << "a:#{squish_number_list(nums)}" if nums.any?
19
21
 
20
- nums = GoogleSafeBrowsing::SubShavar.select('distinct chunk_number').where(:list => list).
21
- order(:chunk_number).uniq.collect{|c| c.chunk_number }
22
+ nums = GoogleSafeBrowsing::SubShavar.where(list: list)
23
+ .order(:chunk_number)
24
+ .select('distinct chunk_number')
25
+ .map(&:chunk_number)
22
26
  action_strings << "s:#{squish_number_list(nums)}" if nums.any?
23
27
 
24
28
  ret += "#{action_strings.join(':')}#{":mac" if GoogleSafeBrowsing.config.have_keys?}\n"
@@ -1,5 +1,16 @@
1
1
  module GoogleSafeBrowsing
2
2
  class FullHash < ActiveRecord::Base
3
3
  self.table_name = 'gsb_full_hashes'
4
+
5
+ def self.delete_subbed
6
+ sub_join = <<-SQL
7
+ INNER JOIN gsb_sub_shavars
8
+ ON gsb_sub_shavars.add_chunk_number = gsb_full_hashes.add_chunk_number
9
+ AND gsb_sub_shavars.list = gsb_full_hashes.list
10
+ SQL
11
+
12
+ hash_ids = joins(sub_join).pluck("distinct #{self.table_name}.id")
13
+ where(id: hash_ids).delete_all
14
+ end
4
15
  end
5
16
  end
@@ -157,13 +157,7 @@ module GoogleSafeBrowsing
157
157
  SQL
158
158
  end
159
159
 
160
- FullHash.connection.execute <<-SQL
161
- DELETE FROM gsb_full_hashes
162
- USING gsb_full_hashes
163
- INNER JOIN gsb_sub_shavars ON
164
- gsb_sub_shavars.add_chunk_number = gsb_full_hashes.add_chunk_number
165
- AND gsb_sub_shavars.list = gsb_full_hashes.list;
166
- SQL
160
+ FullHash.delete_subbed
167
161
 
168
162
  @add_shavar_values = []
169
163
  @sub_shavar_values = []
@@ -1,3 +1,3 @@
1
1
  module GoogleSafeBrowsing
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_safe_browsing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
5
- prerelease:
4
+ version: 0.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Marshall
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-12 00:00:00.000000000 Z
11
+ date: 2013-12-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: ruby-ip
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: activerecord
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: sqlite3
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec-rails
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: generator_spec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: webmock
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description: Rails 3 plugin using Google's Safe Browsing API for url lookup against
@@ -157,32 +142,25 @@ files:
157
142
  - README.md
158
143
  homepage: https://github.com/mobiledefense/google_safe_browsing
159
144
  licenses: []
145
+ metadata: {}
160
146
  post_install_message:
161
147
  rdoc_options: []
162
148
  require_paths:
163
149
  - lib
164
150
  required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
151
  requirements:
167
- - - ! '>='
152
+ - - '>='
168
153
  - !ruby/object:Gem::Version
169
154
  version: '0'
170
- segments:
171
- - 0
172
- hash: -4601497305607067111
173
155
  required_rubygems_version: !ruby/object:Gem::Requirement
174
- none: false
175
156
  requirements:
176
- - - ! '>='
157
+ - - '>='
177
158
  - !ruby/object:Gem::Version
178
159
  version: '0'
179
- segments:
180
- - 0
181
- hash: -4601497305607067111
182
160
  requirements: []
183
161
  rubyforge_project:
184
- rubygems_version: 1.8.23
162
+ rubygems_version: 2.0.3
185
163
  signing_key:
186
- specification_version: 3
164
+ specification_version: 4
187
165
  summary: Rails 3 plugin for Google's Safe Browsing API v2
188
166
  test_files: []