block_slackbot 1.0.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: 80d4d687046ec5e1964d60db28a8f0c701902034
4
+ data.tar.gz: 69d275f19b4fce2d8900cf5018954742dca14568
5
+ SHA512:
6
+ metadata.gz: e23a54e25814f03ff18ffb3342392d2d5ec61695c67264b2470dc1f81371a93ae73be113026c864a413b1b19d5471c7b99ef49facdf8c371758856ad62fff154
7
+ data.tar.gz: 6687398942cd83fdbed3e9c6e86afb5c9f642808cc13aca73bede6b04841da0e90794808df4a9081c20b985f489fce2933ad03954fba06e82f9a6b7a22724831
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /bin/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,46 @@
1
+ ---
2
+ language: ruby
3
+
4
+ dist: trusty
5
+ sudo: false
6
+
7
+ before_install:
8
+ - rvm get head
9
+ - gem install bundler
10
+ - export CXX="g++-4.8"
11
+
12
+ addons:
13
+ apt:
14
+ sources:
15
+ - ubuntu-toolchain-r-test
16
+ packages:
17
+ - g++-4.8
18
+
19
+ rvm:
20
+ - 2.1.10
21
+ - 2.2.4
22
+ - 2.3.1
23
+ - ruby-head
24
+ - rbx
25
+ - jruby-9.1.0.0
26
+ - jruby-9.1.3.0
27
+ - jruby-head
28
+
29
+ matrix:
30
+ allow_failures:
31
+ - rvm: ruby-head
32
+ - rvm: jruby-head
33
+ - rvm: rbx
34
+ # rack 2.0 requires Ruby version >= 2.2.2
35
+ - gemfile: gemfiles/rack_2_0_x.gemfile
36
+ rvm: 2.1.10
37
+
38
+ before_install: gem install bundler
39
+
40
+ script:
41
+ - bundle exec rspec
42
+
43
+ gemfile:
44
+ - gemfiles/rack_1_3_x.gemfile
45
+ - gemfiles/rack_1_6_x.gemfile
46
+ - gemfiles/rack_2_0_x.gemfile
@@ -0,0 +1,11 @@
1
+ appraise "rack-1-3-x" do
2
+ gem "rack", "~> 1.3.0"
3
+ end
4
+
5
+ appraise "rack-1-6-x" do
6
+ gem "rack", "~> 1.6.0"
7
+ end
8
+
9
+ appraise "rack-2-0-x" do
10
+ gem "rack", "~> 2.0.0"
11
+ end
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at TODO: Write your email address. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in block_slackbot.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "appraisal"
8
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Robert Schulze <robert@dotless.de>
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # BlockSlackbot
2
+
3
+ [![Build Status](https://travis-ci.org/fnordfish/block_slackbot.svg?branch=master)](https://travis-ci.org/fnordfish/block_slackbot)
4
+
5
+ BlockSlackbot is a [Rack](http://rack.rubyforge.org/) middleware that blocks [Slack](http://slack.com) crawlers which don't honor `robots.txt` files.
6
+ It does so by identifiying the crawler by it's user agent string as defined in [Slack's API documentation](https://api.slack.com/robots).
7
+
8
+ By default, BlockSlackbot will return with a `403` http status code and a body `Bad Robot`.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'block_slackbot'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install block_slackbot
25
+
26
+ ## Usage
27
+
28
+ In your rackup file:
29
+
30
+ ```ruby
31
+ # config.ru
32
+
33
+ require 'rack/block_slackbot'
34
+ use Rack::BlockSlackbot
35
+ ```
36
+
37
+ In a Sinatra app:
38
+
39
+ ```ruby
40
+ # my_app.rb
41
+
42
+ require 'rack/block_slackbot'
43
+ class MyApp < Sinatra::Base
44
+ configure do
45
+ use Rack::BlockSlackbot
46
+ ```
47
+
48
+ ### Custom Response
49
+
50
+ To change the blocking response, provide a Rack response array as an option like this:
51
+
52
+ ```ruby
53
+ # Redirect somewhere:
54
+ use Rack::BlockSlackbot, :response => [302, { "Location" => "https://example.com" }, []]
55
+ ```
56
+
57
+ ## Development
58
+
59
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/block_slackbot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
66
+
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
71
+
@@ -0,0 +1,8 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'block_slackbot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "block_slackbot"
8
+ spec.version = BlockSlackbot::VERSION
9
+ spec.authors = ["Robert Schulze"]
10
+ spec.email = ["robert@dotless.de"]
11
+
12
+ spec.summary = %q{A Rack Middleware to block Slackbot requests}
13
+ spec.description = %q{Slackbot does not honor robots.txt, this Middleware will return a HTTP 403 error response}
14
+ spec.homepage = "https://github.com/fnordfish/block_slackbot"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "rack", ">= 1.3"
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "rspec-its", "~> 1.0"
27
+ spec.add_development_dependency "rack-test", "~> 0.6"
28
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'appraisal' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("appraisal", "appraisal")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'bundler' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("bundler", "bundler")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'htmldiff' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("diff-lcs", "htmldiff")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'ldiff' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("diff-lcs", "ldiff")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rackup' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rack", "rackup")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'thor' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../rack_1_3.gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("thor", "thor")
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 1.3.0"
6
+
7
+ group :development do
8
+ gem "appraisal"
9
+ end
10
+
11
+ gemspec :path => "../"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ block_slackbot (1.0.0)
5
+ rack (>= 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (2.1.0)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ diff-lcs (1.2.5)
15
+ rack (1.3.10)
16
+ rack-test (0.6.3)
17
+ rack (>= 1.0)
18
+ rake (10.5.0)
19
+ rspec (3.5.0)
20
+ rspec-core (~> 3.5.0)
21
+ rspec-expectations (~> 3.5.0)
22
+ rspec-mocks (~> 3.5.0)
23
+ rspec-core (3.5.2)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-expectations (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-its (1.2.0)
29
+ rspec-core (>= 3.0.0)
30
+ rspec-expectations (>= 3.0.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ thor (0.19.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ appraisal
42
+ block_slackbot!
43
+ bundler (~> 1.12)
44
+ rack (~> 1.3.0)
45
+ rack-test (~> 0.6)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rspec-its (~> 1.0)
49
+
50
+ BUNDLED WITH
51
+ 1.12.5
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 1.3.0"
6
+
7
+ group :development do
8
+ gem "appraisal"
9
+ end
10
+
11
+ gemspec :path => "../"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ block_slackbot (1.0.0)
5
+ rack (>= 1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (2.1.0)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ diff-lcs (1.2.5)
15
+ rack (1.3.10)
16
+ rack-test (0.6.3)
17
+ rack (>= 1.0)
18
+ rake (10.5.0)
19
+ rspec (3.5.0)
20
+ rspec-core (~> 3.5.0)
21
+ rspec-expectations (~> 3.5.0)
22
+ rspec-mocks (~> 3.5.0)
23
+ rspec-core (3.5.2)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-expectations (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-its (1.2.0)
29
+ rspec-core (>= 3.0.0)
30
+ rspec-expectations (>= 3.0.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ thor (0.19.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ appraisal
42
+ block_slackbot!
43
+ bundler (~> 1.12)
44
+ rack (~> 1.3.0)
45
+ rack-test (~> 0.6)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rspec-its (~> 1.0)
49
+
50
+ BUNDLED WITH
51
+ 1.12.5
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 1.6.0"
6
+
7
+ group :development do
8
+ gem "appraisal"
9
+ end
10
+
11
+ gemspec :path => "../"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ block_slackbot (1.0.0)
5
+ rack (>= 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (2.1.0)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ diff-lcs (1.2.5)
15
+ rack (1.6.4)
16
+ rack-test (0.6.3)
17
+ rack (>= 1.0)
18
+ rake (10.5.0)
19
+ rspec (3.5.0)
20
+ rspec-core (~> 3.5.0)
21
+ rspec-expectations (~> 3.5.0)
22
+ rspec-mocks (~> 3.5.0)
23
+ rspec-core (3.5.2)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-expectations (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-its (1.2.0)
29
+ rspec-core (>= 3.0.0)
30
+ rspec-expectations (>= 3.0.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ thor (0.19.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ appraisal
42
+ block_slackbot!
43
+ bundler (~> 1.12)
44
+ rack (~> 1.6.0)
45
+ rack-test (~> 0.6)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rspec-its (~> 1.0)
49
+
50
+ BUNDLED WITH
51
+ 1.12.5
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 1.6.0"
6
+
7
+ group :development do
8
+ gem "appraisal"
9
+ end
10
+
11
+ gemspec :path => "../"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ block_slackbot (1.0.0)
5
+ rack (>= 1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (2.1.0)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ diff-lcs (1.2.5)
15
+ rack (1.6.4)
16
+ rack-test (0.6.3)
17
+ rack (>= 1.0)
18
+ rake (10.5.0)
19
+ rspec (3.5.0)
20
+ rspec-core (~> 3.5.0)
21
+ rspec-expectations (~> 3.5.0)
22
+ rspec-mocks (~> 3.5.0)
23
+ rspec-core (3.5.2)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-expectations (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-its (1.2.0)
29
+ rspec-core (>= 3.0.0)
30
+ rspec-expectations (>= 3.0.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ thor (0.19.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ appraisal
42
+ block_slackbot!
43
+ bundler (~> 1.12)
44
+ rack (~> 1.6.0)
45
+ rack-test (~> 0.6)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rspec-its (~> 1.0)
49
+
50
+ BUNDLED WITH
51
+ 1.12.5
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 2.0.0"
6
+
7
+ group :development do
8
+ gem "appraisal"
9
+ end
10
+
11
+ gemspec :path => "../"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ block_slackbot (1.0.0)
5
+ rack (>= 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (2.1.0)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ diff-lcs (1.2.5)
15
+ rack (2.0.1)
16
+ rack-test (0.6.3)
17
+ rack (>= 1.0)
18
+ rake (10.5.0)
19
+ rspec (3.5.0)
20
+ rspec-core (~> 3.5.0)
21
+ rspec-expectations (~> 3.5.0)
22
+ rspec-mocks (~> 3.5.0)
23
+ rspec-core (3.5.2)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-expectations (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-its (1.2.0)
29
+ rspec-core (>= 3.0.0)
30
+ rspec-expectations (>= 3.0.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ thor (0.19.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ appraisal
42
+ block_slackbot!
43
+ bundler (~> 1.12)
44
+ rack (~> 2.0.0)
45
+ rack-test (~> 0.6)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rspec-its (~> 1.0)
49
+
50
+ BUNDLED WITH
51
+ 1.12.5
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 2.0.0"
6
+
7
+ group :development do
8
+ gem "appraisal"
9
+ end
10
+
11
+ gemspec :path => "../"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ block_slackbot (1.0.0)
5
+ rack (>= 1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (2.1.0)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ diff-lcs (1.2.5)
15
+ rack (2.0.1)
16
+ rack-test (0.6.3)
17
+ rack (>= 1.0)
18
+ rake (10.5.0)
19
+ rspec (3.5.0)
20
+ rspec-core (~> 3.5.0)
21
+ rspec-expectations (~> 3.5.0)
22
+ rspec-mocks (~> 3.5.0)
23
+ rspec-core (3.5.2)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-expectations (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-its (1.2.0)
29
+ rspec-core (>= 3.0.0)
30
+ rspec-expectations (>= 3.0.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ thor (0.19.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ appraisal
42
+ block_slackbot!
43
+ bundler (~> 1.12)
44
+ rack (~> 2.0.0)
45
+ rack-test (~> 0.6)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ rspec-its (~> 1.0)
49
+
50
+ BUNDLED WITH
51
+ 1.12.5
@@ -0,0 +1,4 @@
1
+ require "block_slackbot/version"
2
+
3
+ module BlockSlackbot
4
+ end
@@ -0,0 +1,3 @@
1
+ module BlockSlackbot
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ require "rack"
3
+
4
+ class Rack::BlockSlackbot
5
+ # Pattern to match Slack's robots. Documentation here:
6
+ # https://api.slack.com/robots
7
+ SLACKBOT_UA_PATTERN = /\ASlack(bot-LinkExpanding|-ImgProxy|bot) /.freeze
8
+
9
+ DEFAULT_RESPONSE = [
10
+ 403,
11
+ { "Content-Type" => "text/plain" }.freeze,
12
+ ["Bad Robot"].freeze
13
+ ].freeze
14
+
15
+ HTTP_USER_AGENT = "HTTP_USER_AGENT".freeze
16
+
17
+ def initialize(app, options = {})
18
+ @app = app
19
+ @response = options.fetch(:response, DEFAULT_RESPONSE)
20
+ end
21
+
22
+ def call(env)
23
+ if block?(env)
24
+ @response
25
+ else
26
+ @app.call(env)
27
+ end
28
+ end
29
+
30
+ def block?(env)
31
+ env[HTTP_USER_AGENT] && env[HTTP_USER_AGENT] =~ SLACKBOT_UA_PATTERN
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: block_slackbot
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Robert Schulze
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
97
+ description: Slackbot does not honor robots.txt, this Middleware will return a HTTP
98
+ 403 error response
99
+ email:
100
+ - robert@dotless.de
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Appraisals
109
+ - CODE_OF_CONDUCT.md
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
116
+ - block_slackbot.gemspec
117
+ - gemfiles/bin/appraisal
118
+ - gemfiles/bin/bundler
119
+ - gemfiles/bin/htmldiff
120
+ - gemfiles/bin/ldiff
121
+ - gemfiles/bin/rackup
122
+ - gemfiles/bin/rake
123
+ - gemfiles/bin/rspec
124
+ - gemfiles/bin/thor
125
+ - gemfiles/rack_1_3.gemfile
126
+ - gemfiles/rack_1_3.gemfile.lock
127
+ - gemfiles/rack_1_3_x.gemfile
128
+ - gemfiles/rack_1_3_x.gemfile.lock
129
+ - gemfiles/rack_1_6.gemfile
130
+ - gemfiles/rack_1_6.gemfile.lock
131
+ - gemfiles/rack_1_6_x.gemfile
132
+ - gemfiles/rack_1_6_x.gemfile.lock
133
+ - gemfiles/rack_2_0.gemfile
134
+ - gemfiles/rack_2_0.gemfile.lock
135
+ - gemfiles/rack_2_0_x.gemfile
136
+ - gemfiles/rack_2_0_x.gemfile.lock
137
+ - lib/block_slackbot.rb
138
+ - lib/block_slackbot/version.rb
139
+ - lib/rack/block_slackbot.rb
140
+ homepage: https://github.com/fnordfish/block_slackbot
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.5.1
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: A Rack Middleware to block Slackbot requests
164
+ test_files: []