Skip to content

fix(tools): harden link redirects, CFF sync guards, release regex, and CLI import validation - #437

Open
aghassemlouei wants to merge 1 commit into
mainfrom
fix/tools-cli-security-hardening
Open

aghassemlouei wants to merge 1 commit into
mainfrom
fix/tools-cli-security-hardening

Conversation

@aghassemlouei

Copy link
Copy Markdown
Member

Description

Hardens five self-contained repository maintenance tools and CLI validation helpers so each check can be reviewed and exercised locally via unit tests:

  • cli/src/stellar_engine/config/validate.py: Restricts quoted string index keys in _INDEX (import_address_problems) to printable characters and valid HCL string escapes (\\, \", \n, \r, \t) while rejecting HCL template interpolation and directive prefixes (${, %{) and raw control characters (\x00–\x1f, \x7f).
  • tools/check_links.py: Disables automatic requests.get redirect following (allow_redirects=False) and validates URL scheme (http/https) and resolved IP addresses against private, loopback, link-local, reserved, multicast, and unspecified ranges across each redirect hop up to MAX_REDIRECTS = 5.
  • tools/cff-sync-pr.sh: Resolves the target repository owner from GITHUB_REPOSITORY (falling back to gh repo view) and passes --head "${REPO_OWNER}:${SYNC_BRANCH}" so open branches named chore/cff-sync on external forks cannot match NUMBER.
  • tools/sync-from-cff.sh: Adds check_safe_path before creating directories, writing files, or deleting paths so sync writes reject .. components and symlinked parent directories, and verifies [[ ! -L "${root}/versions.tf" ]] before running sed -E -i.bak on versions.tf.
  • tools/release_please.py: Replaces unanchored <!--\s*(?:breaking|release)-note:\s*(.*?)\s*--> regexes with linear-time _extract_comment_note() scanning and single-line [ \t]*([^\r\n]+)$ trailer matching, eliminating polynomial backtracking on unclosed HTML comments.

Fixes #436

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Deployment & Compliance Impact

  • Applicable Regimes:
    • US Region Restricted (e.g., Access Policy constraint)
    • FedRAMP Moderate
    • FedRAMP High
    • DoD IL4
    • DoD IL5
    • General / All
  • NIST 800-53r5 Controls: Supports SI-10 (Information Input Validation) and CM-3 (Configuration Change Control) across CLI rendering and CI maintenance scripts.

Checklist

Code Quality & Reusability

  • My code adheres to the Maximize Reusability principle. I have not redefined common elements and have reused existing base configurations and modules where possible.
  • I have checked that no existing module or configuration in modules/ or fast/stages-aw/ can be leveraged for this change.
  • My code follows the established naming conventions outlined in docs/naming-convention.md.

Documentation

  • I have updated the README.md of the modified module or blueprint.
  • I have added/updated documentation for inputs (variables) and outputs.

Security

  • My change adheres to GCP security best practices and the principle of least privilege.
  • I have ensured compliance with the targeted regime (FedRAMP Moderate, FedRAMP High, IL4, IL5, etc.).

Testing

  • I have tested my changes locally.
  • I have included details of my testing in this PR.

Testing Performed

  • Ran root Python unit tests, Ruff lint/format checks (--config ruff.toml), and Apache 2.0 header checks (tests/test_check_links.py, tests/test_release_please.py, and full pytest suite).
  • Ran shell unit and syntax suites (bash tests/test_cff_sync_pr.sh, bash tests/test_sync_from_cff.sh, bash tests/test_shell_syntax.sh, and shellcheck).
  • Ran cli Ruff lint/format, pyright, and pytest (tests/test_config_validate.py and tests/test_render_imports.py, including terraform validate and terraform fmt -check workspace checks).

@aghassemlouei aghassemlouei added Bug Something isn't working Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Scope - Fast Related to Fabric FAST deployment stages in the fast directory Security Something is insecure or can be secured labels Nov 17, 2026
@aghassemlouei aghassemlouei self-assigned this Nov 17, 2026
@aghassemlouei aghassemlouei changed the title fix(tools,cli): harden link redirects, CFF sync guards, release regex, and CLI import validation fix(tools): harden link redirects, CFF sync guards, release regex, and CLI import validation Nov 17, 2026
@aghassemlouei
aghassemlouei marked this pull request as ready for review November 17, 2026 18:39
@aghassemlouei aghassemlouei removed their assignment Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Scope - Fast Related to Fabric FAST deployment stages in the fast directory Security Something is insecure or can be secured

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] tools, cli: harden check_links redirect validation, CFF sync symlink/PR guards, release_please regex, and CLI import addresses

1 participant