Merge pull request #13434 from mkllnk/private-address-test

Provide open port for private address test
This commit is contained in:
David Cook
2025-07-28 09:27:07 +10:00
committed by GitHub

View File

@@ -43,15 +43,18 @@ RSpec.describe WebhookDeliveryJob do
# update this to confirm the response isn't exposed.
describe "server side request forgery" do
describe "private addresses" do
before(:all) do
# Open port to await connections.
# Will free port when process ends. Can't free it before.
TCPServer.new(3001)
end
private_addresses = [
"http://127.0.0.1/all_the_secrets",
"http://localhost/all_the_secrets",
"http://127.0.0.1:3001/all_the_secrets",
"http://localhost:3001/all_the_secrets",
]
private_addresses.each do |url|
it "rejects private address #{url}" do
# Github Actions doesn't allow local connections.
pending if ENV["CI"]
expect {
WebhookDeliveryJob.perform_now(url, event, data)
}.to raise_error(PrivateAddressCheck::PrivateConnectionAttemptedError)