-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Security fix for self-comment-ci.yml
#35548
base: main
Are you sure you want to change the base?
Conversation
…)" This reverts commit ccc4a5a.
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
id: get_sha | ||
env: | ||
PR_NUMBER: ${{ needs.get-pr-number.outputs.PR_NUMBER }} | ||
COMMENT_DATE: ${{ github.event.comment.created_at }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMMENT_DATE: ${{ github.event.comment.created_at }}
new for security
git fetch origin refs/pull/$PR_NUMBER/merge:refs/remotes/pull/$PR_NUMBER/merge | ||
git checkout refs/remotes/pull/$PR_NUMBER/merge | ||
PR_MERGE_COMMIT_TIMESTAMP=$(git log -1 --date=unix --format=%cd) | ||
echo "PR_MERGE_COMMIT_TIMESTAMP: $PR_MERGE_COMMIT_TIMESTAMP" | ||
COMMENT_TIMESTAMP=$(date -d "${COMMENT_DATE}" +"%s") | ||
echo "PR_HEAD_SHA: $COMMENT_DATE" | ||
echo "COMMENT_TIMESTAMP: $COMMENT_TIMESTAMP" | ||
if [ $COMMENT_TIMESTAMP -le $PR_MERGE_COMMIT_TIMESTAMP ]; then | ||
echo "Last commit on the pull request is newer than the issue comment triggering this run! Abort!"; | ||
exit -1; | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new for security
from the line git fetch origin refs/pull/$PR_NUMBER/merge:refs/remotes/pull/$PR_NUMBER/merge
to here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently I am using the merge commit.
(merge commit = PR head commit merged with main
)
Merge commit might change if there is a push or merge to the main
branch. So it would be better to use the head commit of the PR instead.
a failing run looks like this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.