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

Use the correct base commit for change determination #16857

Merged
merged 2 commits into from
Mar 20, 2025
Merged

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Mar 19, 2025

base.sha appears to be the commit of the base branch when the pull request was opened, not the base commit that's used to construct the test merge commit — which can lead to incorrect "determine changes" results where commits made to the base ref since the pull request are opened are included in the results.

We use git merge-base to find the correct sha, as I don't think that GitHub provides this. They provide merge_commit_sha but my understanding is that is equivalent to the actual merge commit we're testing in CI.

I tested this locally on an example pull request. I don't think it's worth trying to reproduce a specific situation here.

@zanieb zanieb added the ci Related to internal CI tooling label Mar 19, 2025
@zanieb zanieb force-pushed the zb/test-merge-base branch from a4f99f9 to afe3fe2 Compare March 19, 2025 20:12
Copy link
Contributor

github-actions bot commented Mar 19, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@zanieb
Copy link
Member Author

zanieb commented Mar 20, 2025

Huh how does this fix the possible injection? It doesn't seem any safer as written now.

@AlexWaygood
Copy link
Member

AlexWaygood commented Mar 20, 2025

GitHub's template strings expand differently to standard shell quoting: https://woodruffw.github.io/zizmor/audits/#template-injection

@AlexWaygood
Copy link
Member

see also https://securitylab.github.com/resources/github-actions-untrusted-input/, which suggests this strategy as a remediation to avoid template strings being able to expand into code

@zanieb
Copy link
Member Author

zanieb commented Mar 20, 2025

I see using ${VAR} relies on the shell escaping, this makes sense. Thanks!

@zanieb zanieb marked this pull request as ready for review March 20, 2025 13:02
@zanieb zanieb merged commit 9d72685 into main Mar 20, 2025
22 checks passed
@zanieb zanieb deleted the zb/test-merge-base branch March 20, 2025 13:03
zanieb added a commit to astral-sh/python-build-standalone that referenced this pull request Mar 20, 2025
dcreager added a commit that referenced this pull request Mar 21, 2025
* main: (26 commits)
  Use the common `OperatorPrecedence` for the parser (#16747)
  [red-knot] Check subtype relation between callable types (#16804)
  [red-knot] Check whether two callable types are equivalent (#16698)
  [red-knot] Ban most `Type::Instance` types in type expressions (#16872)
  Special-case value-expression inference of special form subscriptions (#16877)
  [syntax-errors] Fix star annotation before Python 3.11 (#16878)
  Recognize `SyntaxError:` as an error code for ecosystem checks (#16879)
  [red-knot] add test cases result in false positive errors (#16856)
  Bump 0.11.1 (#16871)
  Allow discovery of venv in VIRTUAL_ENV env variable (#16853)
  Split git pathspecs in change determination onto separate lines (#16869)
  Use the correct base commit for change determination (#16857)
  Separate `BitXorOr` into `BitXor` and `BitOr` precedence (#16844)
  Server: Allow `FixAll` action in presence of version-specific syntax errors (#16848)
  [`refurb`] Fix starred expressions fix (`FURB161`) (#16550)
  [`flake8-executable`] Add pytest and uv run to help message for `shebang-missing-python` (`EXE003`) (#16855)
  Show more precise messages in invalid type expressions (#16850)
  [`flake8-executables`] Allow `uv run` in shebang line for `shebang-missing-python` (`EXE003`) (#16849)
  Add `--exit-non-zero-on-format` (#16009)
  [red-knot] Ban list literals in most contexts in type expressions (#16847)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Related to internal CI tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants