Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows: fix usage of untrusted input in check links #3029

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build-images-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:

- name: Getting image tag
id: tag
env:
REF_NAME: ${{ github.ref_name }}
run: |
if [ ${{ github.event.pull_request.head.sha }} != "" ]; then
echo "tag=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
Expand All @@ -66,7 +68,7 @@ jobs:
if [ ${{ github.ref_name }} == "main" ]; then
echo "name=latest" | tee -a $GITHUB_OUTPUT
else
echo "name=${{ github.ref_name }}" | tee -a $GITHUB_OUTPUT
echo "name=$REF_NAME" | tee -a $GITHUB_OUTPUT
fi
fi

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check-links-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
env:
ISSUE_NAME: 'Documentation: broken links automatic report'
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -21,9 +23,7 @@ jobs:

- name: Links Checker
id: lychee
uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # v1.10.0
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
uses: lycheeverse/lychee-action@7cd0af4c74a61395d455af97419279d86aafaede # v2.0.2
with:
args: --config .github/lychee.toml --base https://tetragon.io docs/content README.md

Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/check-links-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
jobs:
links-checker:
runs-on: ubuntu-latest
permissions: {} # lychee uses the GITHUB_TOKEN for authentication only
env:
PATCH_FILE: "additions.patch"
steps:
Expand All @@ -28,10 +29,10 @@ jobs:

- name: Retrieve additions and replace GitHub main links with local branch
shell: bash
env:
REPO: ${{ github.event.pull_request.head.repo.full_name }}
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
REPO=${{ github.event.pull_request.head.repo.full_name }}
BRANCH=${{ github.event.pull_request.head.ref }}

git diff -U0 origin/${{ github.base_ref }} -- docs/content README.md | { grep ^\+[^+] || true; } > $PATCH_FILE

sed -i "s#/cilium/tetragon/tree/main#/$REPO/tree/$BRANCH#g" $PATCH_FILE
Expand All @@ -57,9 +58,7 @@ jobs:

- name: Check new links
id: lychee
uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # v1.10.0
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
uses: lycheeverse/lychee-action@7cd0af4c74a61395d455af97419279d86aafaede # v2.0.2
with:
args: --config .github/lychee.toml --base http://localhost:1313 $PATCH_FILE
fail: true
failIfEmpty: false # this can happen as we are checking diffs
Loading