Merge pull request #161 from ChainSafe/fix/update-fix-NU6 #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Enforce Snap allowedOrigins | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'packages/snap/snap.manifest.json' | |
| - '.github/workflows/check-snap-allowed-origins.yml' | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'packages/snap/snap.manifest.json' | |
| jobs: | |
| check-allowed-origins: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Verify allowedOrigins in snap manifest | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if ! command -v jq >/dev/null 2>&1; then | |
| echo "Installing jq..." | |
| sudo apt-get update -y | |
| sudo apt-get install -y jq | |
| fi | |
| expected='["https://webzjs.chainsafe.dev"]' | |
| MANIFEST="packages/snap/snap.manifest.json" | |
| if [ ! -f "$MANIFEST" ]; then | |
| echo "::error title=Missing file::$MANIFEST not found" | |
| exit 1 | |
| fi | |
| actual=$(jq -c '.initialPermissions["endowment:rpc"].allowedOrigins' "$MANIFEST") | |
| echo "allowedOrigins in $MANIFEST: $actual" | |
| if [ "$actual" != "$expected" ]; then | |
| echo "::error title=Invalid allowedOrigins::For merges to main, allowedOrigins must be $expected. Found: $actual" | |
| exit 1 | |
| fi | |
| echo "allowedOrigins are valid." |