-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Fix: Fix for GHSL-2024-277 #36836
Fix: Fix for GHSL-2024-277 #36836
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -256,16 +256,18 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Set Commit Message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
EVENT_COMMITS: ${{ toJson(github.event.commits[0].message) }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
COMMIT_INFO_AUTHOR: ${{ github.event.commits[0].author.name }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ ${{ inputs.pr }} -ne 0 && ${{github.event_name}} == 'repository_dispatch' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "COMMIT_INFO_MESSAGE=${{ env.COMMIT_INFO_MESSAGE }}" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elif [[ ${{ inputs.pr }} -ne 0 && ${{github.event_name}} == 'workflow_dispatch' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ ${{ inputs.pr }} -ne 0 && ${{ github.event_name }} == 'repository_dispatch' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "COMMIT_INFO_MESSAGE=$COMMIT_INFO_MESSAGE" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elif [[ ${{ inputs.pr }} -ne 0 && ${{ github.event_name }} == 'workflow_dispatch' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "COMMIT_INFO_MESSAGE=Workflow run on PR# ${{ inputs.pr }}" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ '${{env.EVENT_COMMITS}}' == 'null' ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "COMMIT_INFO_MESSAGE=${{ github.event_name }} by ${{ env.COMMIT_INFO_AUTHOR }}" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ "$EVENT_COMMITS" == "null" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "COMMIT_INFO_MESSAGE=${{ github.event_name }} by $COMMIT_INFO_AUTHOR" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "COMMIT_INFO_MESSAGE=$(echo \"${{ env.EVENT_COMMITS }}\" | awk -F '\\\\n' '{print $1}' | sed 's/^\"//')" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
COMMIT_FIRST_LINE=$(echo "$EVENT_COMMITS" | awk -F '\\\\n' '{print $1}' | sed 's/^\"//') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "COMMIT_INFO_MESSAGE=$COMMIT_FIRST_LINE" >> $GITHUB_ENV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+259
to
271
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Class, let's examine the changes in our "Set Commit Message" step. I'm pleased to see improvements in how we're handling our commit messages. However, there are a few areas where we can make our code even better:
However, there are a few areas where we need to make corrections:
-if [[ ${{ inputs.pr }} -ne 0 && ${{ github.event_name }} == 'repository_dispatch' ]]; then
+if [[ "${{ inputs.pr }}" != "0" && "${{ github.event_name }}" == 'repository_dispatch' ]]; then -elif [[ ${{ inputs.pr }} -ne 0 && ${{ github.event_name }} == 'workflow_dispatch' ]]; then
+elif [[ "${{ inputs.pr }}" != "0" && "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
-echo "COMMIT_INFO_MESSAGE=$COMMIT_INFO_MESSAGE" >> $GITHUB_ENV
+echo "COMMIT_INFO_MESSAGE=${COMMIT_INFO_MESSAGE}" >> $GITHUB_ENV
-if [[ "$EVENT_COMMITS" == "null" ]]; then
+if [[ "${EVENT_COMMITS}" == "null" ]]; then
-echo "COMMIT_INFO_MESSAGE=${{ github.event_name }} by $COMMIT_INFO_AUTHOR" >> $GITHUB_ENV
+echo "COMMIT_INFO_MESSAGE=${{ github.event_name }} by ${COMMIT_INFO_AUTHOR}" >> $GITHUB_ENV
-echo "COMMIT_INFO_MESSAGE=$COMMIT_FIRST_LINE" >> $GITHUB_ENV
+echo "COMMIT_INFO_MESSAGE=${COMMIT_FIRST_LINE}" >> $GITHUB_ENV Make these changes, and your code will be much more robust and follow best practices. Any questions, class? 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Let's improve our commit message handling, shall we?
Class, you've made a commendable effort in updating the commit message handling. It's like you're writing a more detailed entry in our class journal. However, we need to make a few corrections:
On lines 271 and 273, we're using
-ne
for string comparison. In bash, we should use!=
for comparing strings. It's like using the correct comparison operator in our math class!We need to put our variables in double quotes to prevent any unexpected word splitting. It's similar to putting quotation marks around a direct quote in our English essays.
Let's fix these issues:
These changes will make our code more robust, just like double-checking our work in class!
📝 Committable suggestion
🧰 Tools
🪛 actionlint