Skip to content

Commit

Permalink
feat: introduce Standard and Overcommit
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Aug 28, 2021
1 parent 0d5a87c commit 29991ae
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 28 deletions.
12 changes: 12 additions & 0 deletions .overcommit.yml
@@ -0,0 +1,12 @@
PreCommit:
BundleCheck:
enabled: true

RuboCop:
enabled: true
required_executable: bundle
command: ["bundle", "exec", "standardrb"]
on_warn: fail

YamlSyntax:
enabled: true
4 changes: 4 additions & 0 deletions .standard.yml
@@ -0,0 +1,4 @@
ignore:
- "**/*":
- Layout/SpaceInsideHashLiteralBraces
- Style/RescueStandardError
4 changes: 2 additions & 2 deletions lib/miteru/attachement.rb
Expand Up @@ -31,7 +31,7 @@ def vt_link
{
type: "button",
text: "Lookup on VirusTotal",
url: _vt_link,
url: _vt_link
}
end

Expand All @@ -41,7 +41,7 @@ def urlscan_link
{
type: "button",
text: "Lookup on urlscan.io",
url: _urlscan_link,
url: _urlscan_link
}
end

Expand Down
1 change: 1 addition & 0 deletions lib/miteru/error.rb
Expand Up @@ -2,5 +2,6 @@

module Miteru
class HTTPResponseError < StandardError; end

class DownloadError < StandardError; end
end
4 changes: 2 additions & 2 deletions lib/miteru/feeds.rb
Expand Up @@ -9,7 +9,7 @@

module Miteru
class Feeds
IGNORE_EXTENSIONS = %w(.htm .html .php .asp .aspx .exe .txt).freeze
IGNORE_EXTENSIONS = %w[.htm .html .php .asp .aspx .exe .txt].freeze

def initialize
@feeds = [
Expand Down Expand Up @@ -48,7 +48,7 @@ def breakdown(url)
segments = uri.path.split("/")
return [base] if segments.length.zero?

urls = (0...segments.length).map { |idx| "#{base}#{segments[0..idx].join('/')}" }
urls = (0...segments.length).map { |idx| "#{base}#{segments[0..idx].join("/")}" }

urls.reject do |breakdowned_url|
# Reject a url which ends with specific extension names
Expand Down
12 changes: 6 additions & 6 deletions lib/miteru/http_client.rb
Expand Up @@ -27,18 +27,18 @@ def head(url, options = {})
options = options.merge default_options

HTTP.follow
.timeout(3)
.headers(urlscan_url?(url) ? urlscan_headers : default_headers)
.head(url, options)
.timeout(3)
.headers(urlscan_url?(url) ? urlscan_headers : default_headers)
.head(url, options)
end

def get(url, options = {})
options = options.merge default_options

HTTP.follow
.timeout(write: 2, connect: 5, read: 10)
.headers(urlscan_url?(url) ? urlscan_headers : default_headers)
.get(url, options)
.timeout(write: 2, connect: 5, read: 10)
.headers(urlscan_url?(url) ? urlscan_headers : default_headers)
.get(url, options)
end

def post(url, options = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/miteru/kit.rb
Expand Up @@ -22,7 +22,7 @@ def initialize(url)
@status = nil
end

def valid?;
def valid?
# make a HEAD request for the validation
before_validation

Expand Down
24 changes: 13 additions & 11 deletions miteru.gemspec
@@ -1,34 +1,36 @@
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "miteru/version"

Gem::Specification.new do |spec|
spec.name = "miteru"
spec.version = Miteru::VERSION
spec.authors = ["Manabu Niseki"]
spec.email = ["manabu.niseki@gmail.com"]
spec.name = "miteru"
spec.version = Miteru::VERSION
spec.authors = ["Manabu Niseki"]
spec.email = ["manabu.niseki@gmail.com"]

spec.summary = "An experimental phishing kit detector"
spec.description = "An experimental phishing kit detector"
spec.homepage = "https://github.com/ninoseki/miteru"
spec.license = "MIT"
spec.summary = "An experimental phishing kit detector"
spec.description = "An experimental phishing kit detector"
spec.homepage = "https://github.com/ninoseki/miteru"
spec.license = "MIT"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 2.2"
spec.add_development_dependency "coveralls_reborn", "~> 0.22"
spec.add_development_dependency "glint", "~> 0.1"
spec.add_development_dependency "overcommit", "~> 0.58"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.10"
spec.add_development_dependency "standard", "~> 1.3"
spec.add_development_dependency "vcr", "~> 6.0"
spec.add_development_dependency "webmock", "~> 3.14"
spec.add_development_dependency "webrick", "~> 1.7.0"
Expand Down
2 changes: 1 addition & 1 deletion spec/cli_spec.rb
Expand Up @@ -9,7 +9,7 @@
end

it "does not raise any error" do
capture(:stdout) { described_class.start %w(execute) }
capture(:stdout) { described_class.start %w[execute] }
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/downloader_spec.rb
Expand Up @@ -44,7 +44,7 @@
it "removes duplicated files" do
kits = [
Miteru::Kit.new(url + "/test.zip"),
Miteru::Kit.new( url + "/test.zip")
Miteru::Kit.new(url + "/test.zip")
]
expect(Dir.glob("#{base_dir}/*.zip").empty?).to be(true)

Expand Down
2 changes: 2 additions & 0 deletions spec/support/helpers/helpers.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true

# rubocop:disable Style/EvalWithLocation, Security/Eval
module Spec
module Support
module Helpers
Expand All @@ -17,3 +18,4 @@ def capture(stream)
end
end
end
# rubocop:enable Style/EvalWithLocation, Security/Eval
8 changes: 4 additions & 4 deletions spec/support/shared_contexts/http_server_context.rb
Expand Up @@ -22,7 +22,7 @@ def server

res.status = status
res.content_length = body.size
res.content_type = 'text/plain'
res.content_type = "text/plain"
res.body = body
end

Expand All @@ -32,7 +32,7 @@ def server

res.status = 200
res.content_length = body.size
res.content_type = 'application/zip'
res.content_type = "application/zip"
res.body = body
end

Expand All @@ -42,7 +42,7 @@ def server

res.status = 200
res.content_length = body.size
res.content_type = 'application/gzip'
res.content_type = "application/gzip"
res.body = body
end

Expand All @@ -53,7 +53,7 @@ def server

res.status = status
res.content_length = body.size
res.content_type = 'text/plain'
res.content_type = "text/plain"
res.body = body
end

Expand Down

0 comments on commit 29991ae

Please sign in to comment.