captchr 0.0.1

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: a1a899120b17ee9ff9653d6c8f85f3286f36edfa
4
+ data.tar.gz: 42b9b9452e8adffc97cddf0e944d9bd5c017af6f
5
+ SHA512:
6
+ metadata.gz: c1173b8b7897900941cf92681838e4710fe77d74f9c9925babf418393d9fb79329ff3d3026336b3efe5f9570430019fe61b415337802ce4e0203dc4cc576813f
7
+ data.tar.gz: bfd4b4dcb75def16b84aefd0009e4a45d3ef9de190fd536402756a3a2d45eecda21787df282fbcaa2f0b255f2387513c1a2d0405e2e1992924fa9c181c5a10ce
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.1
6
+ - 2.2.2
7
+
8
+ notifications:
9
+ email: false
10
+
11
+ bundler_args: --without test --jobs 3 --retry 3
12
+ script: bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # explicitly not specifying a ruby version
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # don't install these unless you're running Home
6
+ group :home do
7
+ gem 'sequel', '~> 4.32.0', '>= 4.32.0'
8
+ gem 'sinatra', '~> 1.4.7', '>= 1.4.7'
9
+ gem 'sqlite3', '~> 1.3.11', '>=1.3.11'
10
+ end
11
+
12
+
13
+ group :development do
14
+ gem 'jeweler', '~> 2.0.1', '>= 2.0.1'
15
+ gem 'test-unit', '~> 3.0.0', '>= 3.0.0'
16
+ end
17
+
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ faraday (0.9.2)
9
+ multipart-post (>= 1.2, < 3)
10
+ git (1.3.0)
11
+ github_api (0.13.1)
12
+ addressable (~> 2.4.0)
13
+ descendants_tracker (~> 0.0.4)
14
+ faraday (~> 0.8, < 0.10)
15
+ hashie (>= 3.4)
16
+ multi_json (>= 1.7.5, < 2.0)
17
+ oauth2
18
+ hashie (3.4.3)
19
+ highline (1.7.8)
20
+ jeweler (2.0.1)
21
+ builder
22
+ bundler (>= 1.0)
23
+ git (>= 1.2.5)
24
+ github_api
25
+ highline (>= 1.6.15)
26
+ nokogiri (>= 1.5.10)
27
+ rake
28
+ rdoc
29
+ json (1.8.3)
30
+ jwt (1.5.1)
31
+ mini_portile2 (2.0.0)
32
+ multi_json (1.11.2)
33
+ multi_xml (0.5.5)
34
+ multipart-post (2.0.0)
35
+ nokogiri (1.6.7.2)
36
+ mini_portile2 (~> 2.0.0.rc2)
37
+ oauth2 (1.1.0)
38
+ faraday (>= 0.8, < 0.10)
39
+ jwt (~> 1.0, < 1.5.2)
40
+ multi_json (~> 1.3)
41
+ multi_xml (~> 0.5)
42
+ rack (>= 1.2, < 3)
43
+ power_assert (0.2.7)
44
+ rack (1.6.4)
45
+ rack-protection (1.5.3)
46
+ rack
47
+ rake (10.5.0)
48
+ rdoc (4.2.2)
49
+ json (~> 1.4)
50
+ sequel (4.32.0)
51
+ sinatra (1.4.7)
52
+ rack (~> 1.5)
53
+ rack-protection (~> 1.4)
54
+ tilt (>= 1.3, < 3)
55
+ sqlite3 (1.3.11)
56
+ test-unit (3.0.9)
57
+ power_assert
58
+ thread_safe (0.3.5)
59
+ tilt (2.0.2)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ jeweler (~> 2.0.1, >= 2.0.1)
66
+ sequel (~> 4.32.0, >= 4.32.0)
67
+ sinatra (~> 1.4.7, >= 1.4.7)
68
+ sqlite3 (~> 1.3.11, >= 1.3.11)
69
+ test-unit (~> 3.0.0, >= 3.0.0)
70
+
71
+ BUNDLED WITH
72
+ 1.11.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Conor Horan-Kates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # captchr
2
+
3
+ DO NOT INSTALL - captchr is a project to determine who is automatically downloading your gem from rubygems.org
4
+
5
+ if you download/run/install/instantialize this gem, you are consenting to sending the following information to the authors:
6
+ - hashed_hostname
7
+ - ruby_version
8
+ - platform
9
+
10
+ we will record this information (along with the IP the request came from) in a local database, so we can conduct analysis on it at a later time. we will never intentionally release the raw dataset.
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'jeweler'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+
6
+ CLEAN.include('pkg/*')
7
+
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = 'captchr'
10
+ gem.summary = 'sends (mostly) non-identifying information from you to us!'
11
+ gem.description = 'ever wonder why your rubygems.org download count goes up by 100 within an hour of a new version? we did too.'
12
+ gem.email = ['conor.code@gmail.com']
13
+ gem.homepage = 'http://github.com/chorankates/captchr'
14
+ gem.authors = ['Conor Horan-Kates', 'Maureen Long']
15
+ gem.licenses = 'MIT'
16
+
17
+ end
18
+ Jeweler::RubygemsDotOrgTasks.new
19
+
20
+ namespace :test do
21
+ Rake::TestTask.new do |t|
22
+ t.name = 'unit'
23
+ t.libs << 'lib'
24
+ t.test_files = FileList['test/**/test_*.rb']
25
+ t.verbose = true
26
+ end
27
+ end
28
+
29
+ desc 'run all tests'
30
+ task :test => ['test:unit'] do; end
31
+
32
+ desc 'run Home'
33
+ task :home do
34
+ sh 'ruby bin/home.rb'
35
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/geolo.rb ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/ruby
2
+ # geolo.rb - updates bike.db with geolocation information it derives from <whatismyip.com>
3
+
data/bin/home.rb ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/ruby
2
+ # home.rb is the server side of captchr, listens for ET. loves reeses pieces.
3
+
4
+ DESMOND = sprintf('sqlite://%s', File.join(sprintf('%s/../bike.db', File.dirname(__FILE__))))
5
+
6
+ require 'sequel'
7
+ require 'sinatra'
8
+
9
+ class PhoneHome
10
+
11
+ attr_reader :db
12
+
13
+ def initialize(db = DESMOND)
14
+ @db = Sequel.connect(db)
15
+
16
+ # create a table if necessary
17
+ @db.create_table? :entries do
18
+ primary_key :id
19
+ String :hashed_hostname
20
+ String :ip
21
+ String :platform
22
+ String :ruby_version
23
+ String :geolocation
24
+ Date :created
25
+ Date :updated
26
+ end
27
+ end
28
+
29
+ # +phe+ a PhoneHomeEntry
30
+ def add_entry(phe)
31
+ self.db[:entries].insert(
32
+ :hashed_hostname => phe.hashed_hostname,
33
+ :ip => phe.ip,
34
+ :platform => phe.platform,
35
+ :ruby_version => phe.ruby_version,
36
+ :geolocation => nil,
37
+ :created => Time.now,
38
+ :updated => nil,
39
+ )
40
+ end
41
+
42
+ end
43
+
44
+ class PhoneHomeEntry
45
+ attr_reader :created, :geolocation, :hashed_hostname, :ip, :platform, :ruby_version
46
+
47
+ def initialize(hashed_hostname, ip, platform, ruby_version, geolocation = nil)
48
+ @created = Time.now
49
+ @geolocation = geolocation
50
+ @hashed_hostname = hashed_hostname
51
+ @ip = ip
52
+ @platform = platform
53
+ @ruby_version = ruby_version
54
+ end
55
+
56
+ end
57
+
58
+ ## initialize some helpers
59
+ ph = PhoneHome.new()
60
+
61
+ post '/et' do
62
+
63
+ ip = self.request.env['REMOTE_ADDR']
64
+
65
+ hashed_hostname = params[:hashed_hostname]
66
+ platform = params[:platform]
67
+ ruby_version = params[:ruby_version]
68
+
69
+ # TODO error checking? .. it should just be us calling us, but..
70
+
71
+ phe = PhoneHomeEntry.new(hashed_hostname, ip, platform, ruby_version)
72
+ ph.add_entry(phe)
73
+ phe # return the object we created
74
+ end
75
+
76
+ configure do
77
+ set :bind, '0.0.0.0'
78
+ end
79
+
80
+ # don't respond to anything except what we've defined
81
+ error Sinatra::NotFound do
82
+ content_type 'text/plain'
83
+ [404, '']
84
+ end
data/bin/reeses.rb ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/ruby
2
+ # reeses.rb - pulls useful information out of the PhoneHome datanase
3
+
data/config.ru ADDED
@@ -0,0 +1,7 @@
1
+ require 'sinatra'
2
+
3
+ set :environment, :production
4
+ disable :run
5
+
6
+ require File.expand_path(File.join(File.dirname(__FILE__), 'bin/home.rb'))
7
+ run Sinatra::Application
data/lib/captchr.rb ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/ruby
2
+ ## captchr - a dummy class for this gem
3
+
4
+ require 'digest/sha2'
5
+ require 'net/http'
6
+ require 'uri'
7
+
8
+ class Captchr
9
+
10
+ attr_accessor :hashed_hostname, :platform, :ruby_version
11
+
12
+ def initialize
13
+ reporting_hostname = ENV['DEV'].nil? ? 'captchr.pwnz.org' : 'localhost'
14
+ @reporting_endpoint = sprintf('http://%s:%i', reporting_hostname, 4567)
15
+
16
+ @hashed_hostname = Digest::SHA2.hexdigest(`hostname`.chomp)
17
+ @platform = RUBY_PLATFORM
18
+ @ruby_version = sprintf('%s-p%i', RUBY_VERSION, RUBY_PATCHLEVEL)
19
+
20
+ homephone # call home as soon as object is initialized
21
+ end
22
+
23
+ def homephone
24
+
25
+ begin
26
+ uri = URI.parse(@reporting_endpoint)
27
+ http = Net::HTTP.new(uri.host, uri.port)
28
+
29
+ request = Net::HTTP::Post.new(
30
+ sprintf('/et?hashed_hostname=%s&platform=%s&ruby_version=%s',
31
+ @hashed_hostname,
32
+ @platform,
33
+ @ruby_version,
34
+ )
35
+ )
36
+
37
+ http.request(request)
38
+ rescue => e
39
+ puts sprintf('caught[%s] backtrace[%s]', e.message, e.backtrace)
40
+ end
41
+
42
+ end
43
+
44
+ def self.add(a, b)
45
+ a + b
46
+ end
47
+
48
+ def self.subtract(a, b)
49
+ a - b
50
+ end
51
+
52
+ end
@@ -0,0 +1,25 @@
1
+ # DON'T RUN THIS TEST! IT WILL SEND YOUR HOSTNAME (hashed), RUBY_PLATFORM and RUBY_VERSION information to the authors of this gem
2
+
3
+ $LOAD_PATH << File.expand_path(sprintf('%s/../lib/', File.dirname(__FILE__)))
4
+
5
+ require 'test-unit'
6
+ require 'captchr'
7
+
8
+ class TestCaptchr < Test::Unit::TestCase
9
+
10
+ def setup; end
11
+ def teardown; end
12
+
13
+ def test_et_phone_home
14
+ captchr = Captchr.new
15
+ end
16
+
17
+ def test_add
18
+ assert_equal(42, Captchr.add(15, 27))
19
+ end
20
+
21
+ def test_subtract
22
+ assert_equal(27, Captchr.subtract(29, 2))
23
+ end
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: captchr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Conor Horan-Kates
8
+ - Maureen Long
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-03-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jeweler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 2.0.1
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.1
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 2.0.1
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
34
+ - !ruby/object:Gem::Dependency
35
+ name: test-unit
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 3.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: 3.0.0
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 3.0.0
54
+ description: ever wonder why your rubygems.org download count goes up by 100 within
55
+ an hour of a new version? we did too.
56
+ email:
57
+ - conor.code@gmail.com
58
+ executables:
59
+ - geolo.rb
60
+ - home.rb
61
+ - reeses.rb
62
+ extensions: []
63
+ extra_rdoc_files:
64
+ - LICENSE
65
+ - README.md
66
+ files:
67
+ - .travis.yml
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - VERSION
74
+ - bin/geolo.rb
75
+ - bin/home.rb
76
+ - bin/reeses.rb
77
+ - config.ru
78
+ - lib/captchr.rb
79
+ - test/test_captchr.rb
80
+ homepage: http://github.com/chorankates/captchr
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.2.2
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: sends (mostly) non-identifying information from you to us!
104
+ test_files: []