From e722eb16678e642450e03bb5cd321391bb0f1df4 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 18 Aug 2024 08:49:32 -0300 Subject: [PATCH 1/4] fix: make sure the root of created tarball artifacts are go+rx The code is using mktmpdir to create the folder, which makes it 0700. The resulting tarball has a root folder with the same permissions, which breaks a system for all users except root when unpacked. --- lib/autoproj/cli/standalone_ci.rb | 2 ++ test/autoproj/cli/standalone_ci_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/autoproj/cli/standalone_ci.rb b/lib/autoproj/cli/standalone_ci.rb index 54bea77..22c6f62 100644 --- a/lib/autoproj/cli/standalone_ci.rb +++ b/lib/autoproj/cli/standalone_ci.rb @@ -19,6 +19,8 @@ class StandaloneCI < Thor type: :string, default: nil def rebuild_root(config_dir, cache_root, output) dir = Dir.mktmpdir + FileUtils.chmod 0755, dir + Autoproj::CI::Rebuild.prepare_synthetic_buildroot( File.join(config_dir, "installation-manifest"), File.join(config_dir, "versions.yml"), diff --git a/test/autoproj/cli/standalone_ci_test.rb b/test/autoproj/cli/standalone_ci_test.rb index 1b01c0d..1135d3a 100644 --- a/test/autoproj/cli/standalone_ci_test.rb +++ b/test/autoproj/cli/standalone_ci_test.rb @@ -30,6 +30,17 @@ module Autoproj::CLI # rubocop:disable Style/ClassAndModuleChildren assert File.file?(iodrivers_base_file) end + it "sets the tarball's root folder permissions to be 0755" do + output = File.join(make_tmpdir, "output.tar.gz") + StandaloneCI.start(["rebuild-root", @fixtures_path, @cache_root, output]) + + contents = `tar tvf "#{output}"`.split("\n").map(&:strip) + root_folder = contents.find { %r{\./$}.match?(_1) } + assert root_folder, "cannot find the root folder in created tarball" + assert root_folder.start_with?("drwxr-xr-x"), + "expected #{root_folder} to have r-x permission for group and user" + end + it "handles relative paths" do out_dir = make_tmpdir output = "output.tar.gz" From 36320e7f7fa2a2b0ec7386a6e5b67713f24ced1d Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 18 Aug 2024 17:39:46 -0300 Subject: [PATCH 2/4] chore: fix ffi version to <= 1.16.3 for older rubygems compatibility --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 346b99c..b809afe 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ source "https://rubygems.org" gem "autoproj", git: "https://github.com/rock-core/autoproj" group :vscode do gem "debase", ">= 0.2.2.beta10" + gem "ffi", "<= 1.16.3" gem "pry" gem "pry-byebug" gem "rubocop" From 2fdfa22a711001c1544adc150f0fec5b4b870440 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 18 Aug 2024 17:39:58 -0300 Subject: [PATCH 3/4] fix: rubocop offenses --- lib/autoproj/cli/ci.rb | 6 ++++-- lib/autoproj/cli/main_ci.rb | 2 +- lib/autoproj/cli/standalone_ci.rb | 2 +- test/autoproj/cli/ci_test.rb | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/autoproj/cli/ci.rb b/lib/autoproj/cli/ci.rb index 33826f9..30d7fde 100644 --- a/lib/autoproj/cli/ci.rb +++ b/lib/autoproj/cli/ci.rb @@ -341,8 +341,10 @@ def cleanup_build_cache(dir, size_limit) total_size -= stat.size end - Autoproj.message format("current build cache size: %.1f GB", - Float(total_size) / 1_000_000_000) + Autoproj.message( + format("current build cache size: %.1f GB", + size: Float(total_size) / 1_000_000_000) + ) total_size end diff --git a/lib/autoproj/cli/main_ci.rb b/lib/autoproj/cli/main_ci.rb index 15ac2c7..99a4878 100644 --- a/lib/autoproj/cli/main_ci.rb +++ b/lib/autoproj/cli/main_ci.rb @@ -177,7 +177,7 @@ def cache_pull(dir, ignore: []) # options[:ignore] is not set if we call from another # command, e.g. build - ignore += (options.delete(:ignore) || []) + ignore += options.delete(:ignore) || [] results = cli.cache_pull(*dir, ignore: ignore) if report && !report.empty? diff --git a/lib/autoproj/cli/standalone_ci.rb b/lib/autoproj/cli/standalone_ci.rb index 22c6f62..758969b 100644 --- a/lib/autoproj/cli/standalone_ci.rb +++ b/lib/autoproj/cli/standalone_ci.rb @@ -19,7 +19,7 @@ class StandaloneCI < Thor type: :string, default: nil def rebuild_root(config_dir, cache_root, output) dir = Dir.mktmpdir - FileUtils.chmod 0755, dir + FileUtils.chmod 0o755, dir Autoproj::CI::Rebuild.prepare_synthetic_buildroot( File.join(config_dir, "installation-manifest"), diff --git a/test/autoproj/cli/ci_test.rb b/test/autoproj/cli/ci_test.rb index ff206fc..f36cee3 100644 --- a/test/autoproj/cli/ci_test.rb +++ b/test/autoproj/cli/ci_test.rb @@ -495,10 +495,10 @@ def self.consolidated_report_single_behavior( # rubocop:disable Metrics/AbcSize end consolidated_report_single_behavior( - "import", report_path_accessor: ->(ws) { ws.import_report_path } + "import", report_path_accessor: lambda(&:import_report_path) ) consolidated_report_single_behavior( - "build", report_path_accessor: ->(ws) { ws.build_report_path } + "build", report_path_accessor: lambda(&:build_report_path) ) consolidated_report_single_behavior( "test", report_path_accessor: ->(ws) { ws.utility_report_path("test") } From e902f4c32c60e19db0a248aa0238e638c0551a4d Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 18 Aug 2024 20:08:17 -0300 Subject: [PATCH 4/4] fix: compatibility with ruby < 2.7 --- test/autoproj/cli/standalone_ci_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/autoproj/cli/standalone_ci_test.rb b/test/autoproj/cli/standalone_ci_test.rb index 1135d3a..31d9405 100644 --- a/test/autoproj/cli/standalone_ci_test.rb +++ b/test/autoproj/cli/standalone_ci_test.rb @@ -35,7 +35,7 @@ module Autoproj::CLI # rubocop:disable Style/ClassAndModuleChildren StandaloneCI.start(["rebuild-root", @fixtures_path, @cache_root, output]) contents = `tar tvf "#{output}"`.split("\n").map(&:strip) - root_folder = contents.find { %r{\./$}.match?(_1) } + root_folder = contents.find { |line| %r{\./$}.match?(line) } assert root_folder, "cannot find the root folder in created tarball" assert root_folder.start_with?("drwxr-xr-x"), "expected #{root_folder} to have r-x permission for group and user"