サンプル
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
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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
コントラクト
- 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
ソース
source 'https://rubygems.org'
gem 'sinatra', '4.2.1'
gem 'rack-test', '2.2.0'
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
{"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"}
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