Skip to content
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
8 changes: 3 additions & 5 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ jobs:
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
env:
GIT_CHECK_EXCLUDE: "./vendor"
# Base commit sha that we use the lint the commit from
EPOCH_TEST_COMMIT: "${{ github.event.pull_request.base.sha }}"
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -85,10 +86,7 @@ jobs:
# See comment on lint task
cache-dependency-path: "**/go.sum"
- name: run git-validation

# We validate all commits as we only fetched the number of commits in the PR above,
# by default git-validation has some special github action handling but that seems broken.
run: make .install.gitvalidation && git-validation -no-github
run: make .install.gitvalidation && make git-validation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I’d be inclined to do make git-validation EPOCH_TEST_COMMIT=… to make the consumer and option passing explicit, but the comment + unique variable name work perfectly fine as is.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I explicitly made the decision to do it that way because github actions is full of fotguns.

${{ github.event.pull_request.base.sha }} is resolved before it get passes to the shell if we do it in the shell line. That means if an attacker controls the value they can inject custom code, i.e. just end the quote in the value.

Now of course none of this applies here as, a) this is a pull request target where users can just modify the code anyway and b) it should be somewhat safe that we always get a hash there that an attcker can not swap. That said I think it is best practise to avoid the ${{ }} block inside the script section for this reason.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means if an attacker controls the value they can inject custom code, i.e. just end the quote in the value

Oh… now I remember that coming up :) Thanks for the reminder.


go-vendor:
runs-on: ubuntu-24.04
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ install.tools: .install.gitvalidation .install.golangci-lint .install.md2man

.PHONY: git-validation
git-validation: .install.gitvalidation
GIT_CHECK_EXCLUDE="./vendor" git-validation -q -run DCO,short-subject,dangling-whitespace -range "$(EPOCH_TEST_COMMIT)..HEAD"
ifndef EPOCH_TEST_COMMIT
$(error EPOCH_TEST_COMMIT is empty)
endif
GIT_CHECK_EXCLUDE="./vendor" git-validation $(if $(CI),,-q) -run DCO,short-subject,dangling-whitespace -range "$(EPOCH_TEST_COMMIT)..HEAD"

.PHONY: lint
lint: .install.golangci-lint
Expand Down