Projects
openEuler:24.03:SP1:Everything:64G
rubygem-activesupport
_service:tar_scm:CVE-2023-38037.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:CVE-2023-38037.patch of Package rubygem-activesupport
From a21d6edf35a60383dfa6c4da49e4b1aef5f00731 Mon Sep 17 00:00:00 2001 From: Aaron Patterson <aaron@rubyonrails.org> Date: Tue, 22 Aug 2023 09:58:43 -0700 Subject: [PATCH] Use a temporary file for storing unencrypted files while editing Origin: https://github.com/rails/rails/commit/a21d6edf35a60383dfa6c4da49e4b1aef5f00731 When we're editing the contents of encrypted files, we should use the `Tempfile` class because it creates temporary files with restrictive permissions. This prevents other users on the same system from reading the contents of those files while the user is editing them. [CVE-2023-38037] --- .../lib/active_support/encrypted_file.rb | 17 ++++++++--------- activesupport/test/encrypted_file_test.rb | 8 ++++++++ railties/lib/rails/secrets.rb | 18 ++++++++++-------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/activesupport/lib/active_support/encrypted_file.rb b/activesupport/lib/active_support/encrypted_file.rb index d2c9e624ccdbc..aac3dea4d8baa 100644 --- a/activesupport/lib/active_support/encrypted_file.rb +++ b/activesupport/lib/active_support/encrypted_file.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "pathname" -require "tmpdir" +require "tempfile" require "active_support/message_encryptor" module ActiveSupport @@ -81,17 +81,16 @@ def change(&block) private def writing(contents) - tmp_file = "#{Process.pid}.#{content_path.basename.to_s.chomp('.enc')}" - tmp_path = Pathname.new File.join(Dir.tmpdir, tmp_file) - tmp_path.binwrite contents + Tempfile.create(["", "-" + content_path.basename.to_s.chomp(".enc")]) do |tmp_file| + tmp_path = Pathname.new(tmp_file) + tmp_path.binwrite contents - yield tmp_path + yield tmp_path - updated_contents = tmp_path.binread + updated_contents = tmp_path.binread - write(updated_contents) if updated_contents != contents - ensure - FileUtils.rm(tmp_path) if tmp_path&.exist? + write(updated_contents) if updated_contents != contents + end end
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2