|
| 1 | +name: CodeQL wrapper source hardening once |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - ".github/workflows/codeql-wrapper-source-fix-main-once.yml" |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + harden: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + timeout-minutes: 30 |
| 16 | + steps: |
| 17 | + - name: Checkout main |
| 18 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 19 | + with: |
| 20 | + ref: main |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Remove redundant P.A.C.K.E.R key escaping |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + set -euo pipefail |
| 27 | + python3 - <<'PY' |
| 28 | + from pathlib import Path |
| 29 | +
|
| 30 | + paths = [ |
| 31 | + Path('scripts/provider_patches/adaptive_runtime_recovery_v4.py'), |
| 32 | + Path('scripts/provider_patches/nuvio_tv_direct_media.py'), |
| 33 | + Path('scripts/provider_patches/nuvio_tv_direct_media_v2.py'), |
| 34 | + ] |
| 35 | + needle = 'key(i).replace(' |
| 36 | + for path in paths: |
| 37 | + text = path.read_text(encoding='utf-8') |
| 38 | + start = text.find(needle) |
| 39 | + if start < 0: |
| 40 | + raise SystemExit(f'{path}: packer key replacement not found') |
| 41 | + if text.find(needle, start + len(needle)) >= 0: |
| 42 | + raise SystemExit(f'{path}: multiple packer key replacements') |
| 43 | + end = text.find(')+"', start) |
| 44 | + if end < 0: |
| 45 | + raise SystemExit(f'{path}: packer key replacement terminator not found') |
| 46 | + before = text[start:end + 1] |
| 47 | + if '/g,' not in before or '$&' not in before: |
| 48 | + raise SystemExit(f'{path}: unexpected packer replacement shape') |
| 49 | + text = text[:start] + 'key(i)' + text[end + 1:] |
| 50 | + path.write_text(text, encoding='utf-8') |
| 51 | + print(f'FIELD_CODEQL_WRAPPER_SOURCE_FIXED path={path}') |
| 52 | + PY |
| 53 | +
|
| 54 | + - name: Verify affected generators |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + set -euo pipefail |
| 58 | + python3 tests/adaptive_runtime_repair_test.py |
| 59 | + python3 tests/override_net_noop_regression_test.py |
| 60 | + python3 tests/streamzo_target_media_profile_test.py |
| 61 | + python3 tests/french_manga_target_media_profile_test.py |
| 62 | + python3 tests/vf_recovery_profiles_test.py |
| 63 | + git diff --check |
| 64 | +
|
| 65 | + - name: Run deterministic repository tests |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + set -euo pipefail |
| 69 | + npm test |
| 70 | +
|
| 71 | + - name: Commit verified generator hardening |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + git config user.name "niakvio-security" |
| 76 | + git config user.email "actions@users.noreply.github.com" |
| 77 | + git add \ |
| 78 | + scripts/provider_patches/adaptive_runtime_recovery_v4.py \ |
| 79 | + scripts/provider_patches/nuvio_tv_direct_media.py \ |
| 80 | + scripts/provider_patches/nuvio_tv_direct_media_v2.py |
| 81 | + if git diff --cached --quiet; then |
| 82 | + echo "No wrapper source change required." |
| 83 | + exit 0 |
| 84 | + fi |
| 85 | + git commit -m "security: remove redundant packer regex sanitization" |
| 86 | + git push origin HEAD:main |
0 commit comments