Skip to content

Commit d875079

Browse files
committed
fix: enable resource identifiers to contain forward slashes
This enables tag names such as 'feat/foo' to be used when escaped. To do this, the path_traversal rack protection was disabled
1 parent 6ca27cc commit d875079

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/pact_broker/app.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def prepare_app
7878
end
7979

8080
def configure_middleware
81-
@app_builder.use Rack::Protection, except: [:remote_token, :session_hijacking, :http_origin]
81+
@app_builder.use Rack::Protection, except: [:path_traversal, :remote_token, :session_hijacking, :http_origin]
8282
@app_builder.use Rack::PactBroker::InvalidUriProtection
8383
@app_builder.use Rack::PactBroker::AddPactBrokerVersionHeader
8484
@app_builder.use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts", "/images"], :root => PactBroker.project_root.join("public")

spec/integration/app_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,15 @@ module PactBroker
187187
expect(last_response.status).to eq 404
188188
end
189189
end
190+
191+
describe "when a resource identifier contains a slash" do
192+
let(:path) { "/pacticipants/Foo/versions/1.2.3/tags/feat%2Fbar" }
193+
194+
subject { put path, nil, {'CONTENT_TYPE' => 'application/json'}; last_response }
195+
196+
it "returns a success status" do
197+
expect(subject.status).to eq 201
198+
end
199+
end
190200
end
191201
end

0 commit comments

Comments
 (0)