security_guard 0.0.4 → 0.0.5
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.
- data/.gitignore +2 -2
- data/README.md +12 -10
- data/lib/security_guard/deduplication.rb +2 -2
- data/lib/security_guard/version.rb +1 -1
- data/security_guard.gemspec +1 -0
- data/specs/country_ips_spec.rb +4 -4
- data/specs/deduplication_spec.rb +16 -12
- data/specs/tmp/.gitkeep +0 -0
- metadata +31 -13
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,12 @@ This gem is a collection of useful tools for auditing data and performing securi
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
### Standalone
|
8
|
+
|
9
|
+
$ gem install security_guard
|
10
|
+
|
11
|
+
### As part of your application
|
12
|
+
|
7
13
|
Add this line to your application's Gemfile:
|
8
14
|
|
9
15
|
gem 'security_guard'
|
@@ -12,10 +18,6 @@ And then execute:
|
|
12
18
|
|
13
19
|
$ bundle
|
14
20
|
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install security_guard
|
18
|
-
|
19
21
|
## Usage
|
20
22
|
|
21
23
|
### Executable
|
@@ -62,10 +64,10 @@ country_ips.ips_from_file = '/path/to/the/file'
|
|
62
64
|
|
63
65
|
### Deduplication
|
64
66
|
|
65
|
-
Deduplicates content contained within a list of files. Useful for deduplicating email newsletter subscription lists.
|
67
|
+
Deduplicates line-delimited content contained within a list of files. Useful for deduplicating email newsletter subscription lists.
|
66
68
|
|
67
69
|
```ruby
|
68
|
-
|
70
|
+
SecurityGuard::Deduplication.new(
|
69
71
|
:input_folder => '/path/to/the/input/folder',
|
70
72
|
:output_folder => '/path/to/the/output/folder'
|
71
73
|
).process
|
@@ -75,12 +77,12 @@ dedupe = SecurityGuard::Deduplication.new(
|
|
75
77
|
|
76
78
|
### v0.0.4 [2012-02-08]
|
77
79
|
|
78
|
-
- Fixed Concerns::Initializable for CountryIps
|
79
|
-
- Added Deduplication
|
80
|
+
- Fixed `Concerns::Initializable` for `CountryIps`
|
81
|
+
- Added `Deduplication`
|
80
82
|
|
81
83
|
### v0.0.3 [2012-01-20]
|
82
84
|
|
83
|
-
- Added Concerns::Initializable
|
85
|
+
- Added `Concerns::Initializable`
|
84
86
|
|
85
87
|
### v0.0.2 [2012-01-19]
|
86
88
|
|
@@ -90,7 +92,7 @@ dedupe = SecurityGuard::Deduplication.new(
|
|
90
92
|
|
91
93
|
### v0.0.1 [2012-01-18]
|
92
94
|
|
93
|
-
- First release, implemented
|
95
|
+
- First release, implemented `CountryIps` and `bin/sguard`
|
94
96
|
|
95
97
|
## Contributing
|
96
98
|
|
@@ -20,7 +20,7 @@ module SecurityGuard
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def read_data_from(folder)
|
23
|
-
files = Dir["#{folder}/*"]
|
23
|
+
files = Dir["#{folder}/*"].sort
|
24
24
|
|
25
25
|
raise Exception.new('Input folder is invalid or is empty.') if files.empty?
|
26
26
|
|
@@ -61,4 +61,4 @@ module SecurityGuard
|
|
61
61
|
(target - other & target).uniq
|
62
62
|
end
|
63
63
|
end
|
64
|
-
end
|
64
|
+
end
|
data/security_guard.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency 'clamp'
|
19
19
|
gem.add_dependency 'awesome_print'
|
20
20
|
gem.add_dependency 'geoip'
|
21
|
+
gem.add_development_dependency 'rake'
|
21
22
|
gem.add_development_dependency 'simplecov'
|
22
23
|
gem.add_development_dependency 'minitest-colorize'
|
23
24
|
end
|
data/specs/country_ips_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe SecurityGuard::CountryIps do
|
4
|
-
|
5
|
-
|
4
|
+
let :country_ips do
|
5
|
+
SecurityGuard::CountryIps.new(
|
6
6
|
:countries => ['Australia'],
|
7
7
|
:ips => ['4.4.4.4', '8.8.8.8', '203.206.0.1']
|
8
8
|
)
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'contains GeoIP data' do
|
12
|
-
|
12
|
+
country_ips.instance_variable_get(:@geoip).must_be_instance_of SecurityGuard::Utils::GeoIps
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'returns all IPs from the given country and IP dictionaries' do
|
16
|
-
|
16
|
+
country_ips.result.must_equal ['203.206.0.1']
|
17
17
|
end
|
18
18
|
end
|
data/specs/deduplication_spec.rb
CHANGED
@@ -1,39 +1,43 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe SecurityGuard::Deduplication do
|
4
|
-
|
5
|
-
|
4
|
+
let :dedupe do
|
5
|
+
SecurityGuard::Deduplication.new(
|
6
6
|
:input_folder => fixture_file('dedupe_lists/'),
|
7
7
|
:output_folder => fixture_file('../tmp/')
|
8
8
|
)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
let :source_data do
|
12
|
+
[
|
11
13
|
['a@example.com', 'b@example.com', 'c@example.com', 'c@example.com'],
|
12
14
|
['b@example.com', 'd@example.com'],
|
13
15
|
['c@example.com', 'd@example.com', 'e@example.com'],
|
14
16
|
]
|
17
|
+
end
|
15
18
|
|
19
|
+
before do
|
16
20
|
`rm -rf #{fixture_file('../tmp/*')}`
|
17
21
|
end
|
18
22
|
|
19
23
|
it 'reads data from the input folder' do
|
20
|
-
|
21
|
-
|
24
|
+
dedupe.send :read_data_from, fixture_file('dedupe_lists/')
|
25
|
+
dedupe.source_data.must_equal source_data
|
22
26
|
end
|
23
27
|
|
24
28
|
it 'writes data to the output folder' do
|
25
|
-
|
29
|
+
dedupe.deduped_data = [
|
26
30
|
[1, 2, 3],
|
27
31
|
[4, 5, 6],
|
28
32
|
]
|
29
|
-
|
33
|
+
dedupe.send :write_data_to, fixture_file('../tmp/')
|
30
34
|
|
31
35
|
File.read(fixture_file('../tmp/1.txt')).must_equal "1\n2\n3\n"
|
32
36
|
File.read(fixture_file('../tmp/2.txt')).must_equal "4\n5\n6\n"
|
33
37
|
end
|
34
38
|
|
35
39
|
it 'reads input and writes output' do
|
36
|
-
|
40
|
+
dedupe.process
|
37
41
|
|
38
42
|
File.read(fixture_file('../tmp/1.txt')).must_equal "a@example.com\nb@example.com\nc@example.com\n"
|
39
43
|
File.read(fixture_file('../tmp/2.txt')).must_equal "d@example.com\n"
|
@@ -41,14 +45,14 @@ describe SecurityGuard::Deduplication do
|
|
41
45
|
end
|
42
46
|
|
43
47
|
it 'dedupes an array with another array' do
|
44
|
-
|
48
|
+
dedupe.send(:_deduped,
|
45
49
|
['a@example.com', 'b@example.com', 'c@example.com', 'c@example.com'],
|
46
50
|
['b@example.com', 'd@example.com'],
|
47
51
|
).must_equal ['a@example.com', 'c@example.com']
|
48
52
|
end
|
49
53
|
|
50
54
|
it 'dedupes an array against multiple arrays' do
|
51
|
-
|
55
|
+
dedupe.send(:_deduped_multi,
|
52
56
|
['c@example.com', 'd@example.com', 'e@example.com'],
|
53
57
|
[
|
54
58
|
['a@example.com', 'b@example.com', 'c@example.com', 'c@example.com'],
|
@@ -58,8 +62,8 @@ describe SecurityGuard::Deduplication do
|
|
58
62
|
end
|
59
63
|
|
60
64
|
it 'dedupes the source data' do
|
61
|
-
|
62
|
-
|
65
|
+
dedupe.send :dedupe, source_data
|
66
|
+
dedupe.deduped_data.must_equal [
|
63
67
|
['a@example.com', 'b@example.com', 'c@example.com'],
|
64
68
|
['d@example.com'],
|
65
69
|
['e@example.com'],
|
data/specs/tmp/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: security_guard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
16
|
-
requirement: &
|
16
|
+
requirement: &70171759282640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70171759282640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: awesome_print
|
27
|
-
requirement: &
|
27
|
+
requirement: &70171759282220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70171759282220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: geoip
|
38
|
-
requirement: &
|
38
|
+
requirement: &70171759281800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,21 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70171759281800
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70171759281380 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70171759281380
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: simplecov
|
49
|
-
requirement: &
|
60
|
+
requirement: &70171759280960 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70171759280960
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: minitest-colorize
|
60
|
-
requirement: &
|
71
|
+
requirement: &70171759280540 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,7 +76,7 @@ dependencies:
|
|
65
76
|
version: '0'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70171759280540
|
69
80
|
description: A collection of useful tools for auditing data and performing security
|
70
81
|
checks.
|
71
82
|
email:
|
@@ -101,6 +112,7 @@ files:
|
|
101
112
|
- specs/fixtures/dedupe_lists/c.txt
|
102
113
|
- specs/fixtures/ip_addresses.txt
|
103
114
|
- specs/spec_helper.rb
|
115
|
+
- specs/tmp/.gitkeep
|
104
116
|
- specs/utils/files_spec.rb
|
105
117
|
- specs/utils/geo_ips_spec.rb
|
106
118
|
homepage: https://github.com/sitepoint/security_guard
|
@@ -115,15 +127,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
127
|
- - ! '>='
|
116
128
|
- !ruby/object:Gem::Version
|
117
129
|
version: '0'
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
hash: 1500545349619429618
|
118
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
134
|
none: false
|
120
135
|
requirements:
|
121
136
|
- - ! '>='
|
122
137
|
- !ruby/object:Gem::Version
|
123
138
|
version: '0'
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
hash: 1500545349619429618
|
124
142
|
requirements: []
|
125
143
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
144
|
+
rubygems_version: 1.8.16
|
127
145
|
signing_key:
|
128
146
|
specification_version: 3
|
129
147
|
summary: A collection of useful tools for auditing data and performing security checks.
|