From 11ae695a495a6315884d263c9a208fba316a8d2b Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 23 Oct 2026 18:52:18 -0600 Subject: [PATCH 1/3] ci(runners): route owner PR validation through JIT --- .github/workflows/ci.yml | 181 +++++++++++++++++++++++++++-- .github/workflows/release-aur.yml | 7 +- .github/workflows/release-copr.yml | 2 +- .github/workflows/release-ppa.yml | 53 ++++++++- memory-bank/current_task.md | 22 ++-- memory-bank/work_breakdown.md | 10 ++ packaging/scripts/setup-aur-ssh.sh | 40 ++++--- 7 files changed, 272 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d566c1b..5f6e9a7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,9 @@ # Go version from go.mod to avoid runner drift. name: CI +run-name: >- + ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' && + format('owner-pr:{0}:{1}:{2}', inputs.pr_number, inputs.pr_sha, inputs.target_run_id) || github.workflow }} on: push: @@ -10,6 +13,23 @@ on: pull_request: branches: [main, master] + pull_request_target: + branches: [main] + types: [opened, reopened, synchronize, ready_for_review, edited] + workflow_dispatch: + inputs: + pr_number: + description: Trusted owner PR number (set only by the metadata dispatcher) + required: false + type: string + pr_sha: + description: Exact owner PR head SHA + required: false + type: string + target_run_id: + description: Successful metadata-only pull_request_target run ID + required: false + type: string permissions: contents: read @@ -19,34 +39,81 @@ concurrency: jobs: verify: - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + permissions: + contents: read + pull-requests: read + if: >- + ((github.event_name == 'workflow_dispatch' && + (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && + inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && + github.ref == 'refs/heads/main')) || ((github.event_name != 'pull_request_target' && + (github.event_name != 'pull_request' || github.actor != 'snapetech' || + github.event.pull_request.user.login != 'snapetech' || + github.event.pull_request.head.repo.full_name != github.repository || + github.event.pull_request.head.repo.id != github.repository_id || + github.event.pull_request.base.ref != 'main') && + (github.event_name != 'workflow_dispatch' || + (inputs.pr_number == '' && inputs.pr_sha == '' && inputs.target_run_id == '')))) + runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-verify"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest')) }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false + ref: ${{ inputs.pr_sha != '' && inputs.pr_sha || (github.sha) }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: + package-manager-cache: ${{ inputs.pr_number == '' }} node-version: '22.23.4' - name: Set up Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: + cache: ${{ inputs.pr_number == '' }} go-version-file: go.mod - name: Install verification tools run: bash scripts/install-ci-tools.sh ripgrep + - name: Resolve current trusted PR metadata + id: owner-pr + if: inputs.pr_number != '' + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ inputs.pr_number }} + PR_SHA: ${{ inputs.pr_sha }} + REPOSITORY: ${{ github.repository }} + run: | + python3 - <<'PY' + import json,os,re + from pathlib import Path + from urllib.request import Request,urlopen + repo=os.environ['REPOSITORY'];number=os.environ['PR_NUMBER'];expected=os.environ['PR_SHA'].lower() + if repo.lower()!='snapetech-org/iptvtunerr' or not re.fullmatch(r'[1-9][0-9]*',number) or not re.fullmatch(r'[0-9a-f]{40}',expected):raise SystemExit('invalid trusted PR claim') + req=Request(f'https://api.github.com/repos/{repo}/pulls/{number}',headers={'Accept':'application/vnd.github+json','Authorization':f"Bearer {os.environ['GH_TOKEN']}",'X-GitHub-Api-Version':'2022-11-28'}) + with urlopen(req,timeout=20) as response:pr=json.load(response) + base=pr.get('base') or {};head=pr.get('head') or {};br=base.get('repo') or {};hr=head.get('repo') or {};sha=(head.get('sha') or '').lower() + if pr.get('state')!='open' or ((pr.get('user') or {}).get('login') or '').lower()!='snapetech' or base.get('ref')!='main' or sha!=expected or (br.get('full_name') or '').lower()!=repo.lower() or (hr.get('full_name') or '').lower()!=repo.lower() or br.get('id')!=hr.get('id'):raise SystemExit('PR changed or is not trusted') + base_sha=(base.get('sha') or '').lower() + if not re.fullmatch(r'[0-9a-f]{40}',base_sha):raise SystemExit('invalid PR base') + body=Path(os.environ['RUNNER_TEMP'])/'release-note-context.md';body.write_text(pr.get('body') or '',encoding='utf-8') + with open(os.environ['GITHUB_OUTPUT'],'a') as out:out.write(f'base_sha={base_sha}\n');out.write(f'body_file={body}\n') + PY - name: Release-note gate env: - BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} - HEAD_SHA: ${{ github.sha }} + BODY_FILE: ${{ inputs.pr_number != '' && steps.owner-pr.outputs.body_file || '' }} + BASE_SHA: ${{ inputs.pr_number != '' && steps.owner-pr.outputs.base_sha || (github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before) }} + HEAD_SHA: ${{ inputs.pr_sha != '' && inputs.pr_sha || github.sha }} PR_BODY: ${{ github.event_name == 'pull_request' && github.event.pull_request.body || github.event.head_commit.message || '' }} run: | set -euo pipefail - body_file="$RUNNER_TEMP/release-note-context.md" - printf '%s' "$PR_BODY" > "$body_file" + if [[ -n "${BODY_FILE:-}" ]]; then + body_file="$BODY_FILE" + else + body_file="$RUNNER_TEMP/release-note-context.md" + printf '%s' "$PR_BODY" > "$body_file" + fi validation_args=() if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then validation_args+=(--allow-mixed-push-batch) @@ -63,34 +130,62 @@ jobs: run: ./scripts/verify smoke: - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + if: >- + ((github.event_name == 'workflow_dispatch' && + (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && + inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && + github.ref == 'refs/heads/main')) || ((github.event_name != 'pull_request_target' && + (github.event_name != 'pull_request' || github.actor != 'snapetech' || + github.event.pull_request.user.login != 'snapetech' || + github.event.pull_request.head.repo.full_name != github.repository || + github.event.pull_request.head.repo.id != github.repository_id || + github.event.pull_request.base.ref != 'main') && + (github.event_name != 'workflow_dispatch' || + (inputs.pr_number == '' && inputs.pr_sha == '' && inputs.target_run_id == '')))) + runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-smoke"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest')) }} needs: verify steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + ref: ${{ inputs.pr_sha != '' && inputs.pr_sha || (github.sha) }} - name: Set up Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: + cache: ${{ inputs.pr_number == '' }} go-version-file: go.mod - name: Binary smoke run: bash ./scripts/ci-smoke.sh release-assets: + if: >- + ((github.event_name == 'workflow_dispatch' && + (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && + inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && + github.ref == 'refs/heads/main')) || ((github.event_name != 'pull_request_target' && + (github.event_name != 'pull_request' || github.actor != 'snapetech' || + github.event.pull_request.user.login != 'snapetech' || + github.event.pull_request.head.repo.full_name != github.repository || + github.event.pull_request.head.repo.id != github.repository_id || + github.event.pull_request.base.ref != 'main') && + (github.event_name != 'workflow_dispatch' || + (inputs.pr_number == '' && inputs.pr_sha == '' && inputs.target_run_id == '')))) # The JIT broker preinstalls RPM and Debian tools for this job; CI keeps # its existing no-sudo guest policy. Hosted runners install them below. - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-release-assets"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest')) }} needs: verify steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + ref: ${{ inputs.pr_sha != '' && inputs.pr_sha || (github.sha) }} - name: Set up Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: + cache: ${{ inputs.pr_number == '' }} go-version-file: go.mod - name: Install Linux package tools @@ -104,3 +199,75 @@ jobs: - name: Verify release asset set run: ./scripts/verify-release-assets.sh v0.0.0 dist + + dispatch-owner-pr: + name: Dispatch trusted owner PR validation + if: >- + github.event_name == 'pull_request_target' && + github.actor == 'snapetech' && + github.event.pull_request.user.login == 'snapetech' && + github.event.pull_request.head.repo.full_name == github.repository && + github.event.pull_request.head.repo.id == github.repository_id && + github.event.pull_request.base.ref == 'main' + runs-on: ${{ (github.event_name == 'pull_request_target' && github.actor == 'snapetech' && github.event.pull_request.user.login == 'snapetech' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.repo.id == github.repository_id && github.event.pull_request.base.ref == 'main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-owner-pr-dispatcher"]}}', github.run_id)) }} + permissions: + actions: write + contents: none + steps: + - name: Dispatch PR-head validation from main + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_SHA: ${{ github.event.pull_request.head.sha }} + TARGET_RUN_ID: ${{ github.run_id }} + GITHUB_REPOSITORY: ${{ github.repository }} + run: | + python3 - <<'PY' + import json,os,re + from urllib.request import Request,urlopen + expected='snapetech-org/iptvtunerr' + repository=os.environ['GITHUB_REPOSITORY'];number=os.environ['PR_NUMBER'];sha=os.environ['PR_SHA'].lower();target=os.environ['TARGET_RUN_ID'];token=os.environ['GH_TOKEN'] + if repository.lower()!=expected.lower() or not re.fullmatch(r'[1-9][0-9]*',number) or not re.fullmatch(r'[0-9a-f]{40}',sha) or not re.fullmatch(r'[1-9][0-9]*',target):raise SystemExit('invalid PR claim') + payload=json.dumps({"ref": "main", "inputs": {"pr_number": number, "pr_sha": sha, "target_run_id": target}}).encode() + request=Request( + 'https://api.github.com/repos/snapetech-org/iptvtunerr/actions/workflows/ci.yml/dispatches', + data=payload,headers={'Accept':'application/vnd.github+json','Authorization':f'Bearer {token}','Content-Type':'application/json','X-GitHub-Api-Version':'2022-11-28'},method='POST') + with urlopen(request,timeout=20) as response: + if response.status!=204:raise SystemExit(f'dispatch HTTP {response.status}') + PY + + report-owner-pr-check: + name: Report trusted owner PR validation + needs: [verify, smoke, release-assets] + if: >- + always() && + github.event_name == 'workflow_dispatch' && + (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && + inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && + github.ref == 'refs/heads/main' + runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-owner-pr-reporter"]}}', github.run_id)) }} + permissions: + checks: write + contents: none + steps: + - name: Attach validation result to the PR head + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ inputs.pr_number }} + PR_SHA: ${{ inputs.pr_sha }} + VALIDATION_RUN_ID: ${{ github.run_id }} + VALIDATION_RESULTS: '{"verify":"${{ needs.verify.result }}","smoke":"${{ needs.smoke.result }}","release-assets":"${{ needs.release-assets.result }}"}' + run: | + python3 - <<'PY' + import json,os,re + from urllib.request import Request,urlopen + number=os.environ['PR_NUMBER'];sha=os.environ['PR_SHA'].lower();results=json.loads(os.environ['VALIDATION_RESULTS']) + if not re.fullmatch(r'[1-9][0-9]*',number) or not re.fullmatch(r'[0-9a-f]{40}',sha) or not results:raise SystemExit('invalid PR check claim') + conclusion='success' if all(v=='success' for v in results.values()) else 'failure' + summary='Main-pinned, no-secret owner PR validation:\n'+'\n'.join(f'- {n}: {v}' for n,v in results.items()) + run_id=os.environ['VALIDATION_RUN_ID'] + payload=json.dumps({"name": "IPTV Tunerr owner PR validation", "head_sha": sha, "external_id": run_id, "status": "completed", "conclusion": conclusion, "details_url": "https://github.com/snapetech-org/iptvtunerr/actions/runs/" + run_id, "output": {"title": "Owner PR validation " + conclusion, "summary": summary}}).encode() + request=Request('https://api.github.com/repos/snapetech-org/iptvtunerr/check-runs',data=payload,headers={'Accept':'application/vnd.github+json','Authorization':f"Bearer {os.environ['GH_TOKEN']}",'Content-Type':'application/json','X-GitHub-Api-Version':'2022-11-28'},method='POST') + with urlopen(request,timeout=20) as response: + if response.status not in {201,202}:raise SystemExit(f'check HTTP {response.status}') + PY diff --git a/.github/workflows/release-aur.yml b/.github/workflows/release-aur.yml index 7e0ac31b..b9570e78 100644 --- a/.github/workflows/release-aur.yml +++ b/.github/workflows/release-aur.yml @@ -18,7 +18,7 @@ concurrency: jobs: publish-aur: - runs-on: ubuntu-latest + runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} steps: - name: Resolve version id: version @@ -131,7 +131,10 @@ jobs: tmp_key="$(mktemp)" trap 'rm -f "$tmp_key"' EXIT printf '%s\n' "$AUR_SSH_KEY" > "$tmp_key" - bash packaging/scripts/setup-aur-ssh.sh "$tmp_key" + git fetch --no-tags origin '+refs/heads/main:refs/remotes/origin/main' + git show origin/main:packaging/scripts/setup-aur-ssh.sh > "$RUNNER_TEMP/setup-aur-ssh.sh" + chmod 0700 "$RUNNER_TEMP/setup-aur-ssh.sh" + bash "$RUNNER_TEMP/setup-aur-ssh.sh" "$tmp_key" - name: Push iptvtunerr-bin to AUR env: diff --git a/.github/workflows/release-copr.yml b/.github/workflows/release-copr.yml index 878ae66a..3c96b8d1 100644 --- a/.github/workflows/release-copr.yml +++ b/.github/workflows/release-copr.yml @@ -18,7 +18,7 @@ concurrency: jobs: publish-copr: - runs-on: ubuntu-latest + runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} steps: - name: Resolve version id: version diff --git a/.github/workflows/release-ppa.yml b/.github/workflows/release-ppa.yml index 3ffcfd66..55c2a3c2 100644 --- a/.github/workflows/release-ppa.yml +++ b/.github/workflows/release-ppa.yml @@ -13,7 +13,7 @@ permissions: jobs: publish-ppa: - runs-on: ubuntu-latest + runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} timeout-minutes: 120 concurrency: group: release-ppa-${{ matrix.ubuntu_series }} @@ -132,18 +132,65 @@ jobs: mv "${changes}.asc" "$changes" gpg --batch --verify "$changes" - - name: Upload to Launchpad PPA + - name: Upload to Launchpad PPA over pinned SFTP env: TAG: ${{ steps.version.outputs.tag }} + LAUNCHPAD_SFTP_KEY: ${{ secrets.LAUNCHPAD_SFTP_KEY }} + LAUNCHPAD_SFTP_USER: ${{ secrets.LAUNCHPAD_SFTP_USER }} run: | set -euo pipefail git fetch --quiet origin main --tags RELEASE_REPO_DIR="$PWD" RELEASE_TAG_MAIN_MODE=latest \ bash -c "$(git show origin/main:scripts/ensure-release-tag-on-main.sh)" release-tag-guard "$TAG" + if [[ -z "${LAUNCHPAD_SFTP_KEY:-}" ]]; then + echo "::error::LAUNCHPAD_SFTP_KEY is required for private-runner PPA uploads." + exit 1 + fi + user="${LAUNCHPAD_SFTP_USER:-keefshape}" + [[ "$user" =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$ ]] || { + echo 'Invalid Launchpad SFTP username.' >&2 + exit 1 + } + install -d -m 0700 ~/.ssh + printf '%s\n' "$LAUNCHPAD_SFTP_KEY" > ~/.ssh/launchpad_ppa + chmod 0600 ~/.ssh/launchpad_ppa + cat > ~/.ssh/known_hosts <<'EOF' + ppa.launchpad.net ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw== + EOF + expected_fingerprint='SHA256:MGq+4hxD7RduVTcfwlwwboZnsgJC6SL/NltM8ye+gNg' + actual_fingerprint="$(ssh-keygen -lf ~/.ssh/known_hosts -E sha256 | awk '{print $2}')" + [[ "$actual_fingerprint" == "$expected_fingerprint" ]] || { + echo 'Pinned Launchpad SSH host key fingerprint mismatch.' >&2 + exit 1 + } + cat > ~/.ssh/config < ~/.dput.cf <` tag convention to start new product-release builds across all nine runner-using applications; keep PR/main validation separate and limit manual recovery to already-published outputs. -- **Story IDs:** RELEASE-TAG-001 and RELEASE-TAG-002 in [work_breakdown.md](work_breakdown.md). -- **Scope:** review nine application repositories plus Packer, close manual release-build bypasses, retain existing release assets and channel recovery, and preserve runner trust and platform boundaries. -- **Status:** focused changes are pushed to the matching draft PRs: BookshelfNG #193, SeerrNG #395, QuestarrNG #140, SlskR #194, IPTV Tunerr #61, and TorrentNG #232. All nine application PRs remain drafts. Their latest exact-head checks are pending; Packer #2's CI was rejected by the organization billing/spending cap before a job started. No fix was merged or deployed. -- **Verification:** BookshelfNG 6 workflow-policy tests and release-readiness gate; SeerrNG 36 release-workflow tests plus Prettier; QuestarrNG manual-builder structure check; SlskR release-policy check; TorrentNG 7 runner-policy and 5 release-note tests; IPTV Tunerr 5 dispatcher/release-policy tests, release-channel wiring, 58 action-pin checks, YAML parsing, and embedded Bash syntax. `git diff --check` and YAML parsing pass for changed workflows. -- **Next step:** inspect exact-head checks as they complete; keep PRs draft pending required checks and infrastructure readiness. Broker deployment, runner-group reconciliation, and live release canaries remain separate outstanding work. -- **Assumptions:** IPTV Tunerr’s tester ZIPs are user-facing release assets, so the tester workflow now runs as a reusable job after the `v*` release is published; it has no standalone manual build trigger. -- **Limits:** do not merge PRs, deploy/restart runners, or create a release tag. Preserve existing published tags and native platform requirements. -- **Rollback:** revert the repository-specific workflow changes; preserve shared broker configuration and retry state. +# Current task: Route trusted owner PR validation through private JIT (2026-10-23) + +- **Goal:** let billing-blocked, same-repository owner PR validation run on a disposable private JIT guest across all nine apps, with Packer independently checking the workflow, PR, actor, head SHA, and run-scoped labels. +- **Story ID:** JIT-OWNER-PR-001 in [work_breakdown.md](work_breakdown.md). +- **Scope:** add a main-pinned metadata-only dispatcher and no-secret, read-only validation run to each app's primary Linux CI workflow; preserve hosted execution for forks, bots, secret-bearing jobs, and unsupported platforms. Keep product release builds tied to the shared `v` tag. +- **Status:** implementation is being added to the existing draft PR branches and Packer #3. The active JIT guest and both host drain gates remain untouched; no live rollout or canary has happened. +- **Verification:** pending final workflow parsing, broker route tests, and focused CI workflow checks. +- **Next step:** finish the PR dispatch/report contracts, verify that the selected job sets contain no publisher permissions or secrets, then push reviewable changes. Deploy only after the active guest drains and the broker update is approved. +- **Assumptions:** only the current core Linux CI job set is dispatched to JIT. Windows/ARM and hosted-only security or metadata checks keep their existing route; none are silently represented as passing by the custom JIT check. +- **Limits:** do not merge PRs, deploy/restart runners, clear drain markers, or create a release tag in this change. Preserve published tags and the active guest. +- **Rollback:** revert the repository-specific dispatcher/checkout/report changes and Packer allowlist changes; preserve broker backups and queue state. --- diff --git a/memory-bank/work_breakdown.md b/memory-bank/work_breakdown.md index ca2adeb9..c533b668 100644 --- a/memory-bank/work_breakdown.md +++ b/memory-bank/work_breakdown.md @@ -1,5 +1,15 @@ # Work breakdown +## 2026-10-23 - Billing-blocked trusted owner PR validation + +Objective: let trusted same-repository owner PR checks use the private JIT pool when GitHub-hosted capacity is blocked, without exposing secrets or executing pull-request code from the privileged metadata workflow. + +| Story ID | Scope | Status | +| --- | --- | --- | +| JIT-OWNER-PR-001 | Extend Packer's exact-workflow broker authorization and add a main-pinned metadata dispatcher plus read-only, no-secret Linux CI validation run for each of the nine application repositories. Keep forks, bots, publishing permissions, Windows/ARM, and hosted-only checks outside the JIT route. | In progress. Packer's source policy and exact repo/workflow/check allowlist are being extended. App workflow edits, focused validation, PR pushes, and live deployment remain outstanding. | + +Guardrail: do not checkout or execute PR code in `pull_request_target`; bind the dispatch to the current open owner-authored PR and exact SHA in the broker; keep `contents: read`, disable persisted checkout credentials, and give write permissions only to metadata dispatch and check reporting. Keep the existing active guest and host drain gates intact. + ## 2026-10-23 - Standardize release tags and review runner PRs Objective: make pushed `v` tags the only source of new application diff --git a/packaging/scripts/setup-aur-ssh.sh b/packaging/scripts/setup-aur-ssh.sh index 71c8482c..c01d680e 100755 --- a/packaging/scripts/setup-aur-ssh.sh +++ b/packaging/scripts/setup-aur-ssh.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -euo pipefail +umask 077 if [[ $# -ne 1 ]]; then echo "Usage: $0 " >&2 @@ -7,31 +8,32 @@ if [[ $# -ne 1 ]]; then fi key_file="$1" +[[ -f "$key_file" && ! -L "$key_file" ]] || { + echo "ERROR: private key must be a regular, non-symlink file." >&2 + exit 1 +} -mkdir -p ~/.ssh -cp "$key_file" ~/.ssh/aur -chmod 600 ~/.ssh/aur - +install -d -m 0700 ~/.ssh +install -m 0600 "$key_file" ~/.ssh/aur +cat > ~/.ssh/known_hosts <<'EOF' +aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN +EOF +actual_fingerprint="$(ssh-keygen -lf ~/.ssh/known_hosts -E sha256 | awk '{print $2}')" +[[ "$actual_fingerprint" == "SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4" ]] || { + echo "ERROR: pinned AUR host key fingerprint mismatch." >&2 + exit 1 +} cat > ~/.ssh/config <<'EOF' Host aur.archlinux.org HostName aur.archlinux.org User aur IdentityFile ~/.ssh/aur IdentitiesOnly yes + UserKnownHostsFile ~/.ssh/known_hosts + GlobalKnownHostsFile /dev/null StrictHostKeyChecking yes + BatchMode yes + PasswordAuthentication no + ProxyCommand nc -X connect -x 10.0.2.100:3128 %h %p EOF - -for attempt in 1 2 3 4 5; do - if ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null; then - exit 0 - fi - - if [[ "$attempt" -eq 5 ]]; then - echo "ERROR: failed to collect aur.archlinux.org host keys after ${attempt} attempts." >&2 - exit 1 - fi - - sleep_seconds=$((attempt * 2)) - echo "ssh-keyscan failed; retrying in ${sleep_seconds}s..." >&2 - sleep "$sleep_seconds" -done +chmod 0600 ~/.ssh/config ~/.ssh/known_hosts From dfec7ed775d1d4776e2810aa6b554fcf2876848a Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 23 Oct 2026 20:41:10 -0600 Subject: [PATCH 2/3] ci(runners): bind JIT labels to exact jobs --- .github/workflows/ci.yml | 6 +++--- .github/workflows/codeql.yml | 2 +- .github/workflows/docker.yml | 2 +- .github/workflows/gitleaks.yml | 2 +- .github/workflows/local-identity-leaks.yml | 2 +- .github/workflows/release-aur.yml | 2 +- .github/workflows/release-copr.yml | 2 +- .github/workflows/release-ppa.yml | 2 +- .github/workflows/release.yml | 6 +++--- .github/workflows/semgrep-community.yml | 2 +- .github/workflows/trivy-filesystem.yml | 2 +- memory-bank/current_task.md | 23 +++++++++++----------- memory-bank/known_issues.md | 5 +++++ memory-bank/recurring_loops.md | 11 +++++++++++ memory-bank/work_breakdown.md | 10 ++++++++++ 15 files changed, 52 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f6e9a7a..6c7ca6c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: github.event.pull_request.base.ref != 'main') && (github.event_name != 'workflow_dispatch' || (inputs.pr_number == '' && inputs.pr_sha == '' && inputs.target_run_id == '')))) - runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-verify"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest')) }} + runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-verify"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-verify"]}}', github.run_id)) || 'ubuntu-latest')) }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -142,7 +142,7 @@ jobs: github.event.pull_request.base.ref != 'main') && (github.event_name != 'workflow_dispatch' || (inputs.pr_number == '' && inputs.pr_sha == '' && inputs.target_run_id == '')))) - runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-smoke"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest')) }} + runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-smoke"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-smoke"]}}', github.run_id)) || 'ubuntu-latest')) }} needs: verify steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -174,7 +174,7 @@ jobs: (inputs.pr_number == '' && inputs.pr_sha == '' && inputs.target_run_id == '')))) # The JIT broker preinstalls RPM and Debian tools for this job; CI keeps # its existing no-sudo guest policy. Hosted runners install them below. - runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-release-assets"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest')) }} + runs-on: ${{ (github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-release-assets"]}}', github.run_id)) || (!(github.event_name == 'workflow_dispatch' && (github.actor == 'snapetech' || github.actor == 'github-actions[bot]') && inputs.pr_number != '' && inputs.pr_sha != '' && inputs.target_run_id != '' && github.ref == 'refs/heads/main') && ((vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-release-assets"]}}', github.run_id)) || 'ubuntu-latest')) }} needs: verify steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 67a06740..d8a373ff 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -18,7 +18,7 @@ concurrency: jobs: analyze: - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-analyze"]}}', github.run_id)) || 'ubuntu-latest' }} permissions: security-events: write actions: read diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a3e46260..03e8996e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,7 +29,7 @@ concurrency: jobs: build: - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-build"]}}', github.run_id)) || 'ubuntu-latest' }} permissions: contents: read packages: write diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml index baffc534..68eb1e99 100644 --- a/.github/workflows/gitleaks.yml +++ b/.github/workflows/gitleaks.yml @@ -19,7 +19,7 @@ concurrency: jobs: scan: - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-scan"]}}', github.run_id)) || 'ubuntu-latest' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/.github/workflows/local-identity-leaks.yml b/.github/workflows/local-identity-leaks.yml index a9fa6ae0..97e1b538 100644 --- a/.github/workflows/local-identity-leaks.yml +++ b/.github/workflows/local-identity-leaks.yml @@ -53,7 +53,7 @@ jobs: trusted-ref-scan: if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) }} - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-trusted-ref-scan"]}}', github.run_id)) || 'ubuntu-latest' }} permissions: contents: read steps: diff --git a/.github/workflows/release-aur.yml b/.github/workflows/release-aur.yml index b9570e78..4144ddfb 100644 --- a/.github/workflows/release-aur.yml +++ b/.github/workflows/release-aur.yml @@ -18,7 +18,7 @@ concurrency: jobs: publish-aur: - runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-publish-aur"]}}', github.run_id)) || 'ubuntu-latest' }} steps: - name: Resolve version id: version diff --git a/.github/workflows/release-copr.yml b/.github/workflows/release-copr.yml index 3c96b8d1..b5427d53 100644 --- a/.github/workflows/release-copr.yml +++ b/.github/workflows/release-copr.yml @@ -18,7 +18,7 @@ concurrency: jobs: publish-copr: - runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-publish-copr"]}}', github.run_id)) || 'ubuntu-latest' }} steps: - name: Resolve version id: version diff --git a/.github/workflows/release-ppa.yml b/.github/workflows/release-ppa.yml index 55c2a3c2..4fdf3be9 100644 --- a/.github/workflows/release-ppa.yml +++ b/.github/workflows/release-ppa.yml @@ -13,7 +13,7 @@ permissions: jobs: publish-ppa: - runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-{1}-publish-ppa"]}}', github.run_id, strategy.job-index)) || 'ubuntu-latest' }} timeout-minutes: 120 concurrency: group: release-ppa-${{ matrix.ubuntu_series }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cca74cce..04c4e6d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: release: - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-release"]}}', github.run_id)) || 'ubuntu-latest' }} permissions: contents: write outputs: @@ -117,7 +117,7 @@ jobs: announce-discord: name: Announce Release to Discord needs: [release] - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-announce-discord"]}}', github.run_id)) || 'ubuntu-latest' }} env: DISCORD_RELEASE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} RELEASE_URL: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }} @@ -308,7 +308,7 @@ jobs: dispatch-package-channels: name: Publish Release Channels needs: [release] - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (contains(fromJSON('["push","workflow_dispatch","schedule","release","repository_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')))) && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-dispatch-package-channels"]}}', github.run_id)) || 'ubuntu-latest' }} timeout-minutes: 240 permissions: actions: write diff --git a/.github/workflows/semgrep-community.yml b/.github/workflows/semgrep-community.yml index 80c2283c..b01c221b 100644 --- a/.github/workflows/semgrep-community.yml +++ b/.github/workflows/semgrep-community.yml @@ -21,7 +21,7 @@ concurrency: jobs: semgrep: name: Semgrep CE (community rules) - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-semgrep"]}}', github.run_id)) || 'ubuntu-latest' }} timeout-minutes: 30 steps: - name: Checkout diff --git a/.github/workflows/trivy-filesystem.yml b/.github/workflows/trivy-filesystem.yml index 4bf6a89e..22b97c4e 100644 --- a/.github/workflows/trivy-filesystem.yml +++ b/.github/workflows/trivy-filesystem.yml @@ -22,7 +22,7 @@ jobs: name: Trivy source, dependency, and configuration scan env: TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db:2 - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}"]}}', github.run_id)) || 'ubuntu-latest' }} + runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-trivy"]}}', github.run_id)) || 'ubuntu-latest' }} timeout-minutes: 30 steps: - name: Checkout diff --git a/memory-bank/current_task.md b/memory-bank/current_task.md index 3c67a379..0089cf6f 100644 --- a/memory-bank/current_task.md +++ b/memory-bank/current_task.md @@ -1,15 +1,14 @@ -# Current task: Route trusted owner PR validation through private JIT (2026-10-23) - -- **Goal:** let billing-blocked, same-repository owner PR validation run on a disposable private JIT guest across all nine apps, with Packer independently checking the workflow, PR, actor, head SHA, and run-scoped labels. -- **Story ID:** JIT-OWNER-PR-001 in [work_breakdown.md](work_breakdown.md). -- **Scope:** add a main-pinned metadata-only dispatcher and no-secret, read-only validation run to each app's primary Linux CI workflow; preserve hosted execution for forks, bots, secret-bearing jobs, and unsupported platforms. Keep product release builds tied to the shared `v` tag. -- **Status:** implementation is being added to the existing draft PR branches and Packer #3. The active JIT guest and both host drain gates remain untouched; no live rollout or canary has happened. -- **Verification:** pending final workflow parsing, broker route tests, and focused CI workflow checks. -- **Next step:** finish the PR dispatch/report contracts, verify that the selected job sets contain no publisher permissions or secrets, then push reviewable changes. Deploy only after the active guest drains and the broker update is approved. -- **Assumptions:** only the current core Linux CI job set is dispatched to JIT. Windows/ARM and hosted-only security or metadata checks keep their existing route; none are silently represented as passing by the custom JIT check. -- **Limits:** do not merge PRs, deploy/restart runners, clear drain markers, or create a release tag in this change. Preserve published tags and the active guest. -- **Rollback:** revert the repository-specific dispatcher/checkout/report changes and Packer allowlist changes; preserve broker backups and queue state. - +# Current task: Bind each JIT runner to its exact workflow job (2026-10-24) + +- **Goal:** prevent GitHub from assigning an unrelated queued job to a JIT guest. Packer verifies a unique label derived from the exact workflow source, including the matrix index, and rechecks uniqueness before dispatch. +- **Story ID:** JIT-QUEUE-001 in [work_breakdown.md](work_breakdown.md). +- **Scope:** update the Packer broker and all nine application workflow branches; preserve hosted fallback, owner-PR trust policy, runner groups, and resource gates. +- **Status:** Packer commit `45140cc` is pushed to PR #3. Workflow changes are staged in the nine app worktrees. Three JIT guest units remain active on the primary host; no pool pause or admission marker change was made. +- **Verification:** 187 focused Packer policy tests pass. All 165 application/Packer workflow files parse, and the label audit verifies 216 exact job contracts, including 25 matrix jobs. Live run evidence confirmed SeerrNG's Cypress job ran on the VM requested for TypeScript tests. +- **Next step:** commit and push each application workflow update, inspect PR checks and live job assignments, then deploy the broker after active guests finish and validate a live queue canary. +- **Assumptions:** a trusted-main job label is `gha--`; matrix children add zero-based `strategy.job-index`. Owner-PR-specific labels remain as configured. +- **Limits:** keep active guests running; do not pause admission, clear gates, or restart the broker while a guest is active. Do not merge draft PRs before required checks and review. +- **Rollback:** revert the per-job workflow labels and Packer broker commit together; preserve queued runs and active guests. --- ## Prior runner deployment session (historical; live state not reverified) diff --git a/memory-bank/known_issues.md b/memory-bank/known_issues.md index 24716dd5..f6f60379 100644 --- a/memory-bank/known_issues.md +++ b/memory-bank/known_issues.md @@ -52,3 +52,8 @@ do not mark builds or releases successful from source checks alone. - **Pre-release Local Identity Leak Check matched existing dependency-update co-author trailers.** Five commit-message lines matched the private identity denylist before `v0.1.86` was tagged. Post-release main checks pass because the latest-tag scan baseline advanced; the historical lines remain in their original commits. Preserve history as directed and do not weaken the scanner. - **GitLab mirror ref listing currently fails, and its cached `main` contains an extra donation-links commit.** The GitLab SSH service reports a multi-pack-index signature error during ref listing and rejected a normal push of verified merge candidate `4b5d293` with an index-pack error. The candidate retains the GitLab-only commit; no remote ref changed. Repair the server-side repository index, read current refs, and retry only as a normal fast-forward. Never force-push this branch. - **The pushed `v0.1.94` tag has no GitHub Release.** Its Release workflow stopped at the changelog-history gate before verification or asset generation because the candidate removed entries from published sections `v0.1.74`, `.75`, and `.77`. Keep the tag immutable; `v0.1.95` is the published successor after restoring those sections exactly from `v0.1.93`. See the release-history recovery loop in [recurring_loops.md](recurring_loops.md). + + +## 2026-10-24 — GitHub Actions can assign the wrong queued job to a JIT guest + +A shared run-scoped label is not an exact job assignment. GitHub can select any queued job in the same run that matches the runner labels, even when the broker chose a different job. The Packer source fix now requires a unique workflow-source-derived job label, includes `strategy.job-index` for matrices, and rechecks same-label uniqueness before dispatch. App workflow fixes are staged in draft PRs; the running broker and live queue still require a safe post-drain deployment and canary. diff --git a/memory-bank/recurring_loops.md b/memory-bank/recurring_loops.md index b8fe530b..60b445be 100644 --- a/memory-bank/recurring_loops.md +++ b/memory-bank/recurring_loops.md @@ -657,3 +657,14 @@ proof that artifacts or package publications completed. Live activation remains - `scripts/check-changelog-tags.mjs` - `scripts/check-changelog-tags.test.mjs` - `internal/tuner/m3u_test.go` + + +### Loop: run-scoped labels do not bind a guest to the broker's selected job + +**Symptom:** the runner name or broker candidate points to one Actions job, but GitHub assigns a different queued job from that run. This can make a build fail or appear to validate the wrong check. + +**Why it is tricky:** GitHub schedules by matching the complete `runs-on` label set. A candidate job ID in the broker or runner name is not part of that scheduling decision when multiple jobs share the same run label. + +**What works:** require an exact label generated by the job's YAML ID; add the zero-based `strategy.job-index` for each matrix child; verify the workflow source at the run SHA; and reject any label shared by more than one queued or running job both before and after runner creation. Diagnose from live GitHub job IDs, names, status, and runner assignments. + +**Where it's documented:** Packer `scripts/shared-jit-runner-pool/gha-runner-broker.py`; application workflows under `.github/workflows/`. diff --git a/memory-bank/work_breakdown.md b/memory-bank/work_breakdown.md index c533b668..73108cb1 100644 --- a/memory-bank/work_breakdown.md +++ b/memory-bank/work_breakdown.md @@ -1,5 +1,15 @@ # Work breakdown +## 2026-10-24 - Prevent cross-assignment between queued workflow jobs + +Objective: ensure each disposable JIT runner can match only the exact trusted workflow job selected by the broker, without pausing admission or interrupting active builds. + +| Story ID | Scope | Status | +| --- | --- | --- | +| JIT-QUEUE-001 | Derive a unique run/job/matrix label from the workflow source in Packer, reject missing or duplicate matches at discovery and immediately before dispatch, and add that label to trusted Linux JIT paths across all nine application repositories. | Packer tests pass and Packer PR #3 is updated; app workflow changes are being pushed to their existing draft PRs. Live deployment and canary remain open until active guests drain. | + +Guardrail: do not pause or restart the live broker while a guest is active; keep all host pressure and capacity gates; inspect actual GitHub job records to verify assignments. + ## 2026-10-23 - Billing-blocked trusted owner PR validation Objective: let trusted same-repository owner PR checks use the private JIT pool when GitHub-hosted capacity is blocked, without exposing secrets or executing pull-request code from the privileged metadata workflow. From bdc737c10a975660778a44ca48135a8269454dd1 Mon Sep 17 00:00:00 2001 From: snapetech Date: Fri, 30 Oct 2026 22:09:37 -0600 Subject: [PATCH 3/3] ci: remove CodeQL workflow per org policy --- .github/workflows/codeql.yml | 47 ------------------------------------ 1 file changed, 47 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index d8a373ff..00000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,47 +0,0 @@ -# ng-runner-policy: hosted-first-v1 -# CodeQL: basic code scanning for security and quality. -# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors - -name: CodeQL - -on: - push: - branches: [main] - pull_request: - branches: [main, master] - schedule: - - cron: "0 0 * * 1" # weekly Monday - -concurrency: - group: ng-scan-codeql-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - analyze: - runs-on: ${{ (vars.NG_HOSTED_FIRST != 'true' || vars.NG_FORCE_JIT == 'true' || github.run_attempt > 1) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && fromJSON(format('{{"group":"ng-shared-main-jit","labels":["self-hosted","linux","x64","ng-shared-main-iptvtunerr","ng-main-run-{0}","gha-{0}-analyze"]}}', github.run_id)) || 'ubuntu-latest' }} - permissions: - security-events: write - actions: read - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - name: Set up Go - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: - go-version-file: go.mod - - - name: Initialize CodeQL - uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 - with: - languages: go - build-mode: manual - - - name: Build for CodeQL - run: go build ./... - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 -