Skip to content

Overall optimization and modernization#442

Merged
nodeg merged 1 commit into
uyuni-project:masterfrom
nodeg:rubocop_performance
Jan 17, 2026
Merged

Overall optimization and modernization#442
nodeg merged 1 commit into
uyuni-project:masterfrom
nodeg:rubocop_performance

Conversation

@nodeg

@nodeg nodeg commented Jan 16, 2026

Copy link
Copy Markdown
Member

This PR improves the following:

Core Modernization

  • Better Ruby 3.4 Compatibility: Added frozen_string_literal: true throughout the project.
  • Core Library Updates: Replaced deprecated URI methods and modernized file path logic using __dir__ and File.join for better cross-environment reliability.
  • Encoding Safety: Switched to binary-safe IO operations (File.binread) to handle non-UTF-8 characters in bundled Ant/Maven metadata, preventing crashes during installation and documentation generation.
  • Gemspec & Linter: Resolved some more RuboCop offenses. Modernized the gemspec with MFA requirements and optimized extra_rdoc_files to exclude binary-heavy bundled templates (which still does not work ATM; the warning when installing the gem still occurrs).
  • Addressed performance issues found by rubocop-performance.

Security Hardening

  • Shell Injection Prevention: Replaced all backticks and string-interpolated shell calls with safe, array-based system and exec calls in the Tar, Unzip, and Bash facades. This mitigates risks associated with malicious filenames or project paths.
  • Safe Execution: Hardened the ProcessRunner to ensure cleaner handling of external build tools.

RPM Workflow & Templates

  • Nil-Safe Templates: Updated the ERB spec templates with safe navigation operators (&.) to handle cases where source archives are absent.

Tests

  • Improved test cases
  • Added tests for the new unzip functionality

Packaging Logic:

  • Automatically adds BuildRequires: unzip if the source is a .zip file. Fixes Missing BuildRequires unzip #10
  • Updated %patch syntax and Python shebang handling to modern standards, e.g. Python 2 to Python 3
  • Removed deprecated Group and BuildRoot tags.
  • Build Reliability: Fixed relative path resolution for Ant, Maven, and Gradle wrappers to ensure build.sh works seamlessly in restricted build environments (chroots).

@nodeg nodeg self-assigned this Jan 16, 2026
Comment thread lib/tetra/packages/package.rb Fixed
Comment thread lib/tetra/version_matcher.rb Fixed
@codecov

codecov Bot commented Jan 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (583e51b) to head (fdcf925).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #442   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          783       839   +56     
=========================================
+ Hits           783       839   +56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodeg nodeg changed the title Fix performance issues detected by RuboCop Overall optimization and modernization Jan 17, 2026
@nodeg
nodeg force-pushed the rubocop_performance branch from 9cf2729 to a1953ff Compare January 17, 2026 16:26
@nodeg
nodeg marked this pull request as ready for review January 17, 2026 16:26
@nodeg
nodeg requested a review from Copilot January 17, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the tetra codebase for Ruby 3.4 compatibility and hardens security through several key improvements. The changes include adding frozen_string_literal: true throughout the project, replacing deprecated URI methods, switching to binary-safe IO operations, and most importantly, replacing shell string interpolation with array-based command execution to prevent shell injection vulnerabilities.

Changes:

  • Added Ruby 3.4 compatibility with frozen string literals and modernized file path handling
  • Hardened security by replacing shell string interpolation with array-based command execution in Tar, Unzip, Bash, Git, and ProcessRunner facades
  • Added automatic BuildRequires: unzip for .zip source archives (fixes issue #10)
  • Updated RPM spec templates with modern %patch syntax, removed deprecated tags, and changed Python 2 to Python 3 shebangs
  • Improved test coverage with new tests for unzip functionality and cleanup_description method

Reviewed changes

Copilot reviewed 65 out of 67 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tetra.gemspec Added frozen_string_literal, MFA requirements, rubocop-performance dependency, modernized path handling
spec/**/*.rb Added frozen_string_literal to all spec files, improved test descriptions, added unzip tests
lib/tetra/version_matcher.rb Optimized version matching algorithm, improved regex patterns, added performance improvements
lib/tetra/facades/* Replaced shell string interpolation with array-based execution for security (tar, unzip, bash, git, ant, mvn, gradle)
lib/tetra/facades/process_runner.rb Complete rewrite using Open3 instead of open4, improved thread-safe output capture
lib/tetra/pom.rb Refactored to use REXML::XPath correctly, added safe navigation operators
lib/tetra/pom_getter.rb Added Zip Slip protection, performance improvements with SHA1 file streaming
lib/tetra/maven_website.rb Added retry logic, timeout handling, and proper redirect support
lib/tetra/packages/package.rb Fixed ReDoS vulnerability in cleanup_description with iterative chomp
lib/template/package.spec Added conditional BuildRequires: unzip, modernized %patch syntax, updated Python shebangs
lib/template/kit.spec Removed deprecated RPM tags, updated Python 2 to Python 3
lib/template/bashrc Replaced non-portable escape sequences, added tput availability check
.rubocop.yml Enabled NewCops, added rubocop-performance plugin, enforced frozen_string_literal

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/lib/fine/package_spec.rb Outdated
Comment thread spec/lib/fine/pom_spec.rb Outdated
Comment thread lib/tetra/facades/git.rb Outdated
Comment thread lib/tetra/facades/tar.rb Outdated
Comment thread spec/lib/fine/project_spec.rb Outdated
Comment thread spec/lib/fine/project_spec.rb Outdated
Comment thread spec/lib/fine/package_spec.rb Outdated
@nodeg
nodeg force-pushed the rubocop_performance branch from a1953ff to 60ddc84 Compare January 17, 2026 16:53
@nodeg
nodeg requested a review from Copilot January 17, 2026 16:54
@nodeg nodeg added this to the 2.0.8 milestone Jan 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 65 out of 67 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/tetra/facades/git.rb Outdated
Comment thread lib/tetra/ui/init_subcommand.rb Outdated
Comment thread spec/lib/coarse/init_subcommand_spec.rb Outdated
Comment thread spec/lib/coarse/init_subcommand_spec.rb Outdated
- Patched shell injection vulnerabilities in Tar, Unzip, and Bash facades
- Use `Dir.glob` instead of slower `Find.find`
- Added `frozen_string_literal` headers and fixed Ruby 3.4 deprecations
- Improved RPM spec templates with nil-safety and modern packaging standards
- Cleaned up entire test suite and fixed some RuboCop offenses
- Enabled all RuboCop cops and recreated the TODO filename
- Extended the test cases (e.g. for unzip dependency in spec file)
- Fixed uyuni-project#10

Signed-off-by: Dominik Gedon <dominik.gedon@suse.com>
@nodeg
nodeg force-pushed the rubocop_performance branch from 60ddc84 to fdcf925 Compare January 17, 2026 17:18
@sonarqubecloud

Copy link
Copy Markdown

@nodeg
nodeg merged commit 3a97549 into uyuni-project:master Jan 17, 2026
11 checks passed
@nodeg
nodeg deleted the rubocop_performance branch January 17, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing BuildRequires unzip

3 participants