Skip to content

improvement(packages): Migrate CLI package publishing to per-arch RPM layout and add Cloudsmith backfill pipeline#260

Open
victorvhs017 wants to merge 3 commits into
mainfrom
feature/backfill-old-releases-to-aws
Open

improvement(packages): Migrate CLI package publishing to per-arch RPM layout and add Cloudsmith backfill pipeline#260
victorvhs017 wants to merge 3 commits into
mainfrom
feature/backfill-old-releases-to-aws

Conversation

@victorvhs017

@victorvhs017 victorvhs017 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description 📣

We're migrating the Infisical CLI package repository from Cloudsmith to a self-hosted AWS setup (S3 + CloudFront) to reduce third-party dependency and gain full control over package distribution. New releases already publish to the AWS repo, but all historical versions still only exist on Cloudsmith. This PR adds the tooling to backfill those old versions into the new repo, so that existing users pinned to older CLI versions continue to resolve packages seamlessly once we sunset the Cloudsmith repo, and fixes the RPM layout to use per-architecture directories, which is required for multi-arch support with mkrepo.

  • Per-arch RPM repo layout: upload_to_s3.sh now publishes RPM packages to rpm/<arch>/Packages/ (one directory per architecture) instead of a single flat rpm/Packages/. This prevents mkrepo from collapsing multi-arch versions into a single entry. setup.rpm.sh is updated to use baseurl=.../rpm/$basearch so clients resolve the correct arch directory.
  • Backfill script (scripts/backfill_from_cloudsmith.sh): One-time migration tool that copies all historical deb/rpm/apk packages from the legacy Cloudsmith repo into the AWS-hosted repo. Idempotent, resumable, supports dry-run, and signs packages with the same keys the release workflow uses.
  • Validation script (scripts/validate_backfill.sh): Spins up deb/rpm/apk containers, configures them via the real setup scripts, and verifies each backfilled version installs and runs correctly through CloudFront.
  • Backfill GitHub Action (.github/workflows/backfill-cloudsmith.yml): Manual-trigger workflow that runs the backfill with auditable CI, supports test/prod target selection, and optionally runs validation after publishing.
  • Release workflow fixes: Pinned mkrepo, boto3, and univers versions; replaced pip-installed AWS CLI v1 with bundled v2 to avoid dependency conflicts with boto3; updated CloudFront invalidation paths to match the new per-arch layout.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Victor Hugo dos Santos added 2 commits June 12, 2026 20:21
…d add backfill workflow for historical packages from Cloudsmith

- Updated `upload_to_s3.sh` to upload RPM packages to architecture-specific directories on S3, preventing package collapse across architectures.
- Introduced a new GitHub Actions workflow `backfill-cloudsmith.yml` for backfilling historical CLI packages from Cloudsmith to the AWS package repository.
- Added `backfill_from_cloudsmith.sh` script to facilitate the migration of old packages, ensuring they are signed with the same keys as current releases.
- Created `validate_backfill.sh` to validate the installation of backfilled packages from the new AWS repo.
- Adjusted `setup.rpm.sh` to support architecture-specific base URLs for RPM repositories.
@infisical-review-police

Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-cli-260-improvement-packages-migrate-cli-package-publishing-to-per-arc

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR migrates RPM package publishing from a single flat rpm/Packages/ directory to per-architecture subdirectories (rpm/<arch>/Packages/), updates the yum repo config to use $basearch, and adds a one-time backfill pipeline for copying all historical Cloudsmith packages into the AWS-hosted repo.

  • Per-arch RPM layout: upload_to_s3.sh and setup.rpm.sh updated together so new releases land in rpm/<arch>/Packages/ and clients resolve the right directory via $basearch; CloudFront invalidation widened to /rpm/* to cover all arch subdirs.
  • Backfill tooling: backfill_from_cloudsmith.sh is a well-structured, idempotent script that reuses the same signing keys and deb-s3/mkrepo tooling as the release workflow; the companion validate_backfill.sh runs container-based installs to confirm each version installs cleanly through CloudFront.
  • Release workflow hardening: Python dependencies are now pinned and the pip-installed AWS CLI v1 is replaced with the bundled v2 to avoid boto3 version conflicts.

Confidence Score: 3/5

The new backfill workflow needs hardening before it is used against the production bucket — shell injection and unverified installer download are present.

The inputs.version string is interpolated directly into shell in the backfill workflow, allowing any contributor who can trigger workflow_dispatch to inject commands that run with prod AWS credentials. The backfill script also follows arbitrary URLs from the Cloudsmith API without host validation, and the AWS CLI installer runs without GPG signature verification. The actual RPM layout migration and release workflow fixes are sound.

.github/workflows/backfill-cloudsmith.yml (shell injection, unverified AWS CLI install) and scripts/backfill_from_cloudsmith.sh (SSRF in download_file, uncleaned legacy S3 objects)

Security Review

  • Shell injection (backfill-cloudsmith.yml lines 134-135, 172): the free-text inputs.version is interpolated directly into run: shell scripts via ${{ inputs.version }}, allowing any workflow-dispatch caller to inject arbitrary shell commands.
  • SSRF (backfill_from_cloudsmith.sh download_file()): cdn_url values returned by the Cloudsmith API are fetched by curl without validating the hostname, enabling server-side request forgery if the API response is tampered with.
  • Unverified binary installation (both workflows): the AWS CLI v2 zip is downloaded and executed without checking the AWS-published GPG signature, leaving a supply-chain gap if the CDN is compromised.

Important Files Changed

Filename Overview
.github/workflows/backfill-cloudsmith.yml New manual-trigger workflow for backfilling Cloudsmith packages; contains shell injection risk via free-text inputs.version interpolated directly in run steps, and downloads the AWS CLI installer without signature verification.
scripts/backfill_from_cloudsmith.sh Large new backfill script; well-structured and idempotent, but fetches arbitrary Cloudsmith cdn_url values without host validation (SSRF), and the legacy flat-layout migration does not clean up source objects after copying.
.github/workflows/release_build_infisical_cli.yml Pins mkrepo/boto3/univers versions, replaces pip-installed AWS CLI v1 with bundled v2, and widens CloudFront invalidation to /rpm/*; the AWS CLI install lacks checksum verification, otherwise changes are correct.
upload_to_s3.sh Correct migration from flat rpm/Packages/ to per-arch rpm/<arch>/Packages/ with per-arch mkrepo runs; logic is sound and mirrors the backfill script's approach.
scripts/setup/setup.rpm.sh One-line change updates baseurl to use $basearch so yum/dnf resolves the correct per-arch directory; the \$basearch escaping is correct for the generated repo file.
scripts/validate_backfill.sh New validation script that runs container-based installs for deb/rpm/apk to verify backfilled packages; straightforward and well-guarded, but inputs.version injection risk is inherited from the calling workflow.

Comments Outside Diff (1)

  1. scripts/backfill_from_cloudsmith.sh, line 660-694 (link)

    P2 Legacy flat rpm/Packages/ objects are never cleaned up after migration

    rpm_migrate_flat_layout() copies files from the old flat rpm/Packages/ path to the new per-arch directories, but leaves the original objects in S3. Clients that still have the old flat baseurl will keep resolving from rpm/Packages/. Consider deleting or documenting the need to delete the source objects after a successful copy.

Reviews (1): Last reviewed commit: "Remove environment protection for produc..." | Re-trigger Greptile

Comment thread .github/workflows/backfill-cloudsmith.yml
Comment thread scripts/backfill_from_cloudsmith.sh
Comment thread .github/workflows/backfill-cloudsmith.yml
@linear

linear Bot commented Jun 12, 2026

Copy link
Copy Markdown

ENG-5136

Comment thread .github/workflows/backfill-cloudsmith.yml Outdated
@veria-ai

veria-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 2 · PR risk: 0/10

…r inputs, improving readability and maintainability. Updated echo statements and condition checks to utilize new variable references.
Comment thread .github/workflows/backfill-cloudsmith.yml
@victorvhs017 victorvhs017 requested a review from PrestigePvP June 13, 2026 00:05

@PrestigePvP PrestigePvP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The bash scripts are really hard to review - I'm going to assume you know how they work and what they do.

I left a couple comments

run: sudo apt-get update && sudo apt-get install -y rpm unzip
# AWS CLI v2 (pinned), kept outside the pip env: awscli (pip, v1) cannot
# coexist with mkrepo's boto3 1.17.5 (different s3transfer). v2 is bundled.
- name: Install AWS CLI v2 (pinned)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why we using v2?

APK_PRIVATE_KEY_PATH: /tmp/infisical-apk.rsa
- name: Invalidate Cloudfront cache
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run)
run: aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths '/rpm/Packages/*' '/rpm/repodata/*' '/deb/dists/stable/*' '/apk/stable/main/*'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we removing this path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants