From ddef4d030649922d3fcd5c941fb3395bca92057b Mon Sep 17 00:00:00 2001 From: ksg Date: Sun, 22 Sep 2024 01:34:43 +0900 Subject: [PATCH] chore: fix naming conventions in models and techs files following linting rules --- spec/functional_test/func_spec.cr | 2 +- spec/functional_test/testers/har_spec.cr | 2 +- spec/unit_test/tagger/tagger_spec.cr | 2 +- spec/unit_test/techs/techs_spec.cr | 2 +- src/analyzer/analyzers/crystal/kemal.cr | 4 ++-- src/analyzer/analyzers/crystal/lucky.cr | 4 ++-- src/analyzer/analyzers/elixir/elixir_phoenix.cr | 4 ++-- src/analyzer/analyzers/example.cr | 2 +- src/analyzer/analyzers/go/fiber.cr | 2 +- src/analyzer/analyzers/javascript/express.cr | 2 +- src/analyzer/analyzers/javascript/restify.cr | 2 +- src/analyzer/analyzers/python/django.cr | 4 ++-- src/analyzer/analyzers/ruby/sinatra.cr | 2 +- src/analyzer/analyzers/specification/har.cr | 4 ++-- src/models/endpoint.cr | 4 ++-- src/models/noir.cr | 4 ++-- src/options.cr | 4 ++-- src/tagger/tagger.cr | 2 +- src/techs/techs.cr | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-) diff --git a/spec/functional_test/func_spec.cr b/spec/functional_test/func_spec.cr index 7b3d9067..acadd6af 100644 --- a/spec/functional_test/func_spec.cr +++ b/spec/functional_test/func_spec.cr @@ -130,7 +130,7 @@ class FunctionalTester @app end - def set_url(url) + def url=(url) @app.options["url"] = YAML::Any.new(url) end end diff --git a/spec/functional_test/testers/har_spec.cr b/spec/functional_test/testers/har_spec.cr index 8c743b20..658c98bc 100644 --- a/spec/functional_test/testers/har_spec.cr +++ b/spec/functional_test/testers/har_spec.cr @@ -15,5 +15,5 @@ instance = FunctionalTester.new("fixtures/har/", { :endpoints => extected_endpoints.size, }, extected_endpoints) -instance.set_url "https://www.hahwul.com" +instance.url = "https://www.hahwul.com" instance.test_all diff --git a/spec/unit_test/tagger/tagger_spec.cr b/spec/unit_test/tagger/tagger_spec.cr index 3472f288..397cbaf1 100644 --- a/spec/unit_test/tagger/tagger_spec.cr +++ b/spec/unit_test/tagger/tagger_spec.cr @@ -117,7 +117,7 @@ describe "Tagger" do config_init = ConfigInitializer.new noir_options = config_init.default_options e = Endpoint.new("/ws", "GET") - e.set_protocol("ws") + e.protocol = "ws" extected_endpoints = [e] diff --git a/spec/unit_test/techs/techs_spec.cr b/spec/unit_test/techs/techs_spec.cr index 55c7ea58..5b6ead85 100644 --- a/spec/unit_test/techs/techs_spec.cr +++ b/spec/unit_test/techs/techs_spec.cr @@ -19,7 +19,7 @@ describe "Similar to tech" do end describe "Get Techs" do - techs = NoirTechs.get_techs + techs = NoirTechs.techs techs.each do |k, v| it "#{k} in techs" do v.should_not be_empty diff --git a/src/analyzer/analyzers/crystal/kemal.cr b/src/analyzer/analyzers/crystal/kemal.cr index 5a6fad5d..f734a613 100644 --- a/src/analyzer/analyzers/crystal/kemal.cr +++ b/src/analyzer/analyzers/crystal/kemal.cr @@ -18,7 +18,7 @@ module Analyzer::Crystal endpoint = line_to_endpoint(line) if endpoint.method != "" details = Details.new(PathInfo.new(path, index + 1)) - endpoint.set_details(details) + endpoint.details = details result << endpoint last_endpoint = endpoint end @@ -162,7 +162,7 @@ module Analyzer::Crystal content.scan(/ws\s+['"](.+?)['"]/) do |match| if match.size > 1 endpoint = Endpoint.new("#{match[1]}", "GET") - endpoint.set_protocol("ws") + endpoint.protocol = "ws" return endpoint end end diff --git a/src/analyzer/analyzers/crystal/lucky.cr b/src/analyzer/analyzers/crystal/lucky.cr index cd1ee22e..3fddb1c1 100644 --- a/src/analyzer/analyzers/crystal/lucky.cr +++ b/src/analyzer/analyzers/crystal/lucky.cr @@ -26,7 +26,7 @@ module Analyzer::Crystal endpoint = line_to_endpoint(line) if endpoint.method != "" details = Details.new(PathInfo.new(path, index + 1)) - endpoint.set_details(details) + endpoint.details = details result << endpoint last_endpoint = endpoint end @@ -127,7 +127,7 @@ module Analyzer::Crystal content.scan(/ws\s+['"](.+?)['"]/) do |match| if match.size > 1 endpoint = Endpoint.new("#{match[1]}", "GET") - endpoint.set_protocol("ws") + endpoint.protocol = "ws" return endpoint end end diff --git a/src/analyzer/analyzers/elixir/elixir_phoenix.cr b/src/analyzer/analyzers/elixir/elixir_phoenix.cr index fbdd3e27..a3c73d82 100644 --- a/src/analyzer/analyzers/elixir/elixir_phoenix.cr +++ b/src/analyzer/analyzers/elixir/elixir_phoenix.cr @@ -14,7 +14,7 @@ module Analyzer::Elixir endpoints.each do |endpoint| if endpoint.method != "" details = Details.new(PathInfo.new(path, index + 1)) - endpoint.set_details(details) + endpoint.details = details @result << endpoint end end @@ -54,7 +54,7 @@ module Analyzer::Elixir line.scan(/socket\s+['"](.+?)['"]\s*,\s*(.+?)\s*/) do |match| tmp = Endpoint.new("#{match[1]}", "GET") - tmp.set_protocol("ws") + tmp.protocol = "ws" endpoints << tmp end diff --git a/src/analyzer/analyzers/example.cr b/src/analyzer/analyzers/example.cr index 85cff499..c94f1694 100644 --- a/src/analyzer/analyzers/example.cr +++ b/src/analyzer/analyzers/example.cr @@ -12,7 +12,7 @@ class AnalyzerExample < Analyzer # For example (Add endpoint to result) # endpoint = Endpoint.new("/", "GET") # details = Details.new(PathInfo.new(path, index + 1)) - # endpoint.set_details(details) + # endpoint.details=details # @result << endpoint end end diff --git a/src/analyzer/analyzers/go/fiber.cr b/src/analyzer/analyzers/go/fiber.cr index 163c9f44..cb75e89e 100644 --- a/src/analyzer/analyzers/go/fiber.cr +++ b/src/analyzer/analyzers/go/fiber.cr @@ -53,7 +53,7 @@ module Analyzer::Go if route_path.size > 0 new_endpoint = Endpoint.new("#{route_path}", line.split(".")[1].split("(")[0].upcase, details) if line.includes?("websocket.New(") - new_endpoint.set_protocol("ws") + new_endpoint.protocol = "ws" end result << new_endpoint last_endpoint = new_endpoint diff --git a/src/analyzer/analyzers/javascript/express.cr b/src/analyzer/analyzers/javascript/express.cr index 4951eacd..39f0904b 100644 --- a/src/analyzer/analyzers/javascript/express.cr +++ b/src/analyzer/analyzers/javascript/express.cr @@ -14,7 +14,7 @@ module Analyzer::Javascript endpoint = line_to_endpoint(line) if endpoint.method != "" details = Details.new(PathInfo.new(path, index + 1)) - endpoint.set_details(details) + endpoint.details = details result << endpoint last_endpoint = endpoint end diff --git a/src/analyzer/analyzers/javascript/restify.cr b/src/analyzer/analyzers/javascript/restify.cr index b9cdf0e8..2e055dba 100644 --- a/src/analyzer/analyzers/javascript/restify.cr +++ b/src/analyzer/analyzers/javascript/restify.cr @@ -14,7 +14,7 @@ module Analyzer::Javascript endpoint = line_to_endpoint(line) if endpoint.method != "" details = Details.new(PathInfo.new(path, index + 1)) - endpoint.set_details(details) + endpoint.details = details result << endpoint last_endpoint = endpoint end diff --git a/src/analyzer/analyzers/python/django.cr b/src/analyzer/analyzers/python/django.cr index 4e061a11..4fc26569 100644 --- a/src/analyzer/analyzers/python/django.cr +++ b/src/analyzer/analyzers/python/django.cr @@ -127,7 +127,7 @@ module Analyzer::Python new_django_urls = DjangoUrls.new("#{django_urls.prefix}#{route}", new_route_path, django_urls.basepath) details = Details.new(PathInfo.new(new_route_path)) extract_endpoints(new_django_urls).each do |endpoint| - endpoint.set_details(details) + endpoint.details = details endpoints << endpoint end end @@ -156,7 +156,7 @@ module Analyzer::Python if filepath != "" extract_endpoints_from_file(url, filepath, function_or_class_name).each do |endpoint| - endpoint.set_details(details) + endpoint.details = details endpoints << endpoint end else diff --git a/src/analyzer/analyzers/ruby/sinatra.cr b/src/analyzer/analyzers/ruby/sinatra.cr index 7a623a37..fd4e0c05 100644 --- a/src/analyzer/analyzers/ruby/sinatra.cr +++ b/src/analyzer/analyzers/ruby/sinatra.cr @@ -14,7 +14,7 @@ module Analyzer::Ruby endpoint = line_to_endpoint(line) if endpoint.method != "" details = Details.new(PathInfo.new(path, index + 1)) - endpoint.set_details(details) + endpoint.details = details @result << endpoint last_endpoint = endpoint end diff --git a/src/analyzer/analyzers/specification/har.cr b/src/analyzer/analyzers/specification/har.cr index 90016dac..8108242f 100644 --- a/src/analyzer/analyzers/specification/har.cr +++ b/src/analyzer/analyzers/specification/har.cr @@ -48,9 +48,9 @@ module Analyzer::Specification end details = Details.new(PathInfo.new(har_file, 0)) - endpoint.set_details(details) + endpoint.details = details if is_websocket - endpoint.set_protocol "ws" + endpoint.protocol = "ws" end @result << endpoint end diff --git a/src/models/endpoint.cr b/src/models/endpoint.cr index 6aaa36ec..0d538db2 100644 --- a/src/models/endpoint.cr +++ b/src/models/endpoint.cr @@ -30,10 +30,10 @@ struct Endpoint @tags = [] of Tag end - def set_details(@details : Details) + def details=(@details : Details) end - def set_protocol(protocol : String) + def protocol=(protocol : String) @protocol = protocol end diff --git a/src/models/noir.cr b/src/models/noir.cr index 805a1855..814708ea 100644 --- a/src/models/noir.cr +++ b/src/models/noir.cr @@ -90,7 +90,7 @@ class NoirRunner @logger.success "Running all taggers." NoirTaggers.run_tagger @endpoints, @options, "all" if @is_debug - NoirTaggers.get_taggers.each do |tagger| + NoirTaggers.taggers.each do |tagger| @logger.debug "Tagger: #{tagger}" end end @@ -125,7 +125,7 @@ class NoirRunner if dup.method == tiny_tmp.method && dup.url == tiny_tmp.url is_new = false tiny_tmp.params.each do |param| - existing_param = dup.params.find { |p| p.name == param.name } + existing_param = dup.params.find { |dup_param| dup_param.name == param.name } unless existing_param dup.params << param end diff --git a/src/options.cr b/src/options.cr index 12a945c4..7d1bf76d 100644 --- a/src/options.cr +++ b/src/options.cr @@ -69,7 +69,7 @@ def run_options_parser parser.on "--use-taggers VALUES", "Activates specific taggers (e.g., --use-taggers hunt,oauth)" { |var| noir_options["use_taggers"] = YAML::Any.new(var) } parser.on "--list-taggers", "Lists all available taggers" do puts "Available taggers:" - techs = NoirTaggers.get_taggers + techs = NoirTaggers.taggers techs.each do |tagger, value| puts " #{tagger.to_s.colorize(:green)}" value.each do |k, v| @@ -101,7 +101,7 @@ def run_options_parser parser.on "--exclude-techs rails,php", "Specify the technologies to be excluded" { |var| noir_options["exclude_techs"] = YAML::Any.new(var) } parser.on "--list-techs", "Show all technologies" do puts "Available technologies:" - techs = NoirTechs.get_techs + techs = NoirTechs.techs techs.each do |tech, value| puts " #{tech.to_s.colorize(:green)}" value.each do |k, v| diff --git a/src/tagger/tagger.cr b/src/tagger/tagger.cr index be8b3c83..9e284e54 100644 --- a/src/tagger/tagger.cr +++ b/src/tagger/tagger.cr @@ -30,7 +30,7 @@ module NoirTaggers }, } - def self.get_taggers + def self.taggers HasTaggers end diff --git a/src/techs/techs.cr b/src/techs/techs.cr index c3793c09..14515738 100644 --- a/src/techs/techs.cr +++ b/src/techs/techs.cr @@ -474,7 +474,7 @@ module NoirTechs }, } - def self.get_techs + def self.techs TECHS end