Skip to content

Commit

Permalink
Merge pull request #405 from owasp-noir/chore/code-linting
Browse files Browse the repository at this point in the history
chore: Apply Linting
  • Loading branch information
ksg97031 authored Sep 21, 2024
2 parents 9cf5be5 + ddef4d0 commit 074b8e0
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion spec/functional_test/func_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class FunctionalTester
@app
end

def set_url(url)
def url=(url)
@app.options["url"] = YAML::Any.new(url)
end
end
2 changes: 1 addition & 1 deletion spec/functional_test/testers/har_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/unit_test/tagger/tagger_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion spec/unit_test/techs/techs_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/analyzers/crystal/kemal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/analyzers/crystal/lucky.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/analyzers/elixir/elixir_phoenix.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzers/example.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzers/go/fiber.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzers/javascript/express.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzers/javascript/restify.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/analyzers/python/django.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzers/ruby/sinatra.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/analyzer/analyzers/specification/har.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/models/endpoint.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/models/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/options.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion src/tagger/tagger.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module NoirTaggers
},
}

def self.get_taggers
def self.taggers
HasTaggers
end

Expand Down
2 changes: 1 addition & 1 deletion src/techs/techs.cr
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ module NoirTechs
},
}

def self.get_techs
def self.techs
TECHS
end

Expand Down

0 comments on commit 074b8e0

Please sign in to comment.