Skip to content

Commit

Permalink
Merge pull request #445 from owasp-noir/fixed-444
Browse files Browse the repository at this point in the history
Fixed 444 Issue
  • Loading branch information
hahwul authored Nov 6, 2024
2 parents 62d436f + f47791c commit 642d20f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 5 additions & 2 deletions spec/functional_test/fixtures/ruby/rails/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Rails.application.routes.draw do
resources :posts
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

# Defines the root path route ("/")
# root "articles#index"
end
get "up" => "rails/health#show", as: :rails_health_check
get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
end
3 changes: 3 additions & 0 deletions spec/functional_test/testers/ruby/rails_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ extected_endpoints = [
Param.new("X-API-KEY", "", "header"),
]),
Endpoint.new("/posts/1", "DELETE"),
Endpoint.new("/up", "GET"),
Endpoint.new("/service-worker", "GET"),
Endpoint.new("/manifest", "GET"),
]

FunctionalTester.new("fixtures/ruby/rails/", {
Expand Down
11 changes: 11 additions & 0 deletions src/models/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class NoirRunner

@endpoints.each do |endpoint|
tiny_tmp = endpoint

# Remove space in param name
if endpoint.params.size > 0
tiny_tmp.params = [] of Param
endpoint.params.each do |param|
Expand All @@ -149,6 +151,15 @@ class NoirRunner
end
end

# Check start with slash
if tiny_tmp.url[0] != "/"
tiny_tmp.url = "/#{tiny_tmp.url}"
end

# Check double slash
tiny_tmp.url = tiny_tmp.url.gsub_repeatedly("//", "/")

# Duplicate check
if tiny_tmp.url != ""
is_new = true
final.each do |dup|
Expand Down

0 comments on commit 642d20f

Please sign in to comment.