CodeSampleX

샘플

sinatra 4.2.1: Show that Sinatra does not automatically delete uploaded tempfile after request

검증된 샘플 — gem sinatra 4.2.1: Show that Sinatra does not automatically delete uploaded tempfile after request. ruby 3 · linux debian/x64 · docker에서 contract를…

sha256:642785541c948ed29ed0bfef28fd354b3908b3e42d5b60ff220ab91e5a7a7f29

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
2
선언된 환경 ruby linux x64 ruby ruby bundler

검증 실행 환경

환경 컨트랙트 단계 실행일
ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-17
ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-18

케이스

HOW
목표
Show that Sinatra does not automatically delete uploaded tempfile after request
패키지
심벌
  • Sinatra::Base#post
  • Rack::Test::UploadedFile
환경
ruby
생성일
2026-08-17T02:47:53Z

컨트랙트

  1. A multipart upload sent with an allowed localhost Host reaches the Sinatra route, and the received tempfile still exists after the request returns.

파일

  • Gemfile
  • Gemfile.lock
  • csx.json
  • test/contract.rb

소스 아티팩트 내려받기 (tar.gz)

소스

Gemfile
source 'https://rubygems.org'

gem 'sinatra', '4.2.1'

gem 'rack-test', '2.2.0'
Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    base64 (0.3.0)
    logger (1.7.0)
    mustermann (3.1.1)
    rack (3.2.7)
    rack-protection (4.2.1)
      base64 (>= 0.1.0)
      logger (>= 1.6.0)
      rack (>= 3.0.0, < 4)
    rack-session (2.1.2)
      base64 (>= 0.1.0)
      rack (>= 3.0.0)
    rack-test (2.2.0)
      rack (>= 1.3)
    sinatra (4.2.1)
      logger (>= 1.6.0)
      mustermann (~> 3.0)
      rack (>= 3.0.0, < 4)
      rack-protection (= 4.2.1)
      rack-session (>= 2.0.0, < 3)
      tilt (~> 2.0)
    tilt (2.8.0)

PLATFORMS
  ruby
  x64-mingw-ucrt

DEPENDENCIES
  rack-test (= 2.2.0)
  sinatra (= 4.2.1)

CHECKSUMS
  base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
  bundler (4.0.18) sha256=02d9a17429de1847b4e0c9f27a9ee4b20c0a74c0a641b4e77195d6019e3618ac
  logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
  mustermann (3.1.1) sha256=4c6170c7234d5499c345562ba7c7dfe73e1754286dcc1abb053064d66a127198
  rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7
  rack-protection (4.2.1) sha256=cf6e2842df8c55f5e4d1a4be015e603e19e9bc3a7178bae58949ccbb58558bac
  rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8
  rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463
  sinatra (4.2.1) sha256=b7aeb9b11d046b552972ade834f1f9be98b185fa8444480688e3627625377080
  tilt (2.8.0) sha256=ba472eb2716fe1e04112d6d219a9dae938ec09a6a1e2ad3ecc7922e79bde3721

BUNDLED WITH
  4.0.18
csx.json
{"case":{"believed":"Sinatra automatically removes uploaded file temporary files after the request completes","caseId":"case:sha256:4a183035c75b11ded0bb15404c4d06083538d3496a44ed979aec41f59b29061e","contract":["A multipart upload sent with an allowed localhost Host reaches the Sinatra route, and the received tempfile still exists after the request returns."],"goal":"Show that Sinatra does not automatically delete uploaded tempfile after request","kind":"HOW","packages":["pkg:gem/sinatra@4.2.1","pkg:gem/rack-test@2.2.0"],"schemaVersion":1,"symbols":["Sinatra::Base#post","Rack::Test::UploadedFile"]},"contractCommand":["ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"bundler","runtime":"ruby","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/sinatra@4.2.1","pkg:gem/rack-test@2.2.0"],"schemaVersion":1,"symbols":["Sinatra::Base#post","Rack::Test::UploadedFile"],"verifierAdapter":"rubygems@1"}
test/contract.rb
require 'sinatra/base'
require 'rack/test'
require 'tempfile'

# Simple Sinatra app that accepts file upload
class UploadApp < Sinatra::Base
  post '/upload' do
    # params[:file] is a hash with :filename and :tempfile (Tempfile instance)
    uploaded = params[:file][:tempfile]
    # Store the path in a global for later inspection
    $temp_path = uploaded.path
    "ok"
  end
end

# Rack::Test integration
include Rack::Test::Methods

def app
  UploadApp
end

# Create a temporary file to upload
temp = Tempfile.new('sample')
temp.write('hello')
temp.rewind

# Perform the upload request
header 'Host', 'localhost'
post '/upload', { 'file' => Rack::Test::UploadedFile.new(temp.path, 'text/plain') }

raise "upload request failed with status #{last_response.status}" unless last_response.status == 200
raise "upload route did not receive a tempfile" unless $temp_path

# After request, check if the tempfile still exists on the filesystem
if File.exist?($temp_path)
  puts 'TEMPFILE EXISTS'
else
  raise 'Tempfile was removed after request'
end

오리진 시더

csx-seed