Skip to content

Commit 5042a4c

Browse files
committed
Fix YAML syntax error and security issue in stale-hip-management workflow
- Fix YAML syntax error on line 94 by using heredoc for multi-line comment - Add input validation to prevent code injection attacks - Move workflow inputs to environment variables with validation - Replace backtick quotes with single quotes for better YAML compatibility Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
1 parent 1690a0f commit 5042a4c

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

.github/workflows/stale-hip-management.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,21 @@ jobs:
3939
- name: Process Stale PRs
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
INACTIVITY_DAYS_INPUT: ${{ github.event.inputs.inactivity_days || '60' }}
43+
WARNING_DAYS_INPUT: ${{ github.event.inputs.warning_days || '14' }}
4244
run: |
43-
# Use workflow_dispatch inputs if available, otherwise use defaults
44-
INACTIVITY_DAYS=${{ github.event.inputs.inactivity_days || '60' }}
45-
WARNING_DAYS=${{ github.event.inputs.warning_days || '14' }}
45+
# Validate inputs to prevent code injection
46+
if ! [[ "$INACTIVITY_DAYS_INPUT" =~ ^[0-9]+$ ]]; then
47+
echo "Error: inactivity_days must be a positive integer"
48+
exit 1
49+
fi
50+
if ! [[ "$WARNING_DAYS_INPUT" =~ ^[0-9]+$ ]]; then
51+
echo "Error: warning_days must be a positive integer"
52+
exit 1
53+
fi
54+
55+
INACTIVITY_DAYS="$INACTIVITY_DAYS_INPUT"
56+
WARNING_DAYS="$WARNING_DAYS_INPUT"
4657
CURRENT_TIME=$(date +%s)
4758
4859
echo "Configuration:"
@@ -89,9 +100,12 @@ jobs:
89100
echo " Posting warning for PR #$PR_NUMBER (inactive for $DAYS_INACTIVE days)"
90101
91102
# Post warning comment (no label yet)
92-
gh pr comment $PR_NUMBER --body "This HIP appears to have been inactive for $DAYS_INACTIVE days. If there is no activity or response within $WARNING_DAYS days, it will be marked as Stagnant and closed.
103+
gh pr comment $PR_NUMBER --body "$(cat <<EOF
104+
This HIP appears to have been inactive for $DAYS_INACTIVE days. If there is no activity or response within $WARNING_DAYS days, it will be marked as Stagnant and closed.
93105

94-
To prevent automatic closure, simply add a comment with an update, make a commit, or react to this message. Maintainers can also add a \`keep-open\` label to exempt this HIP."
106+
To prevent automatic closure, simply add a comment with an update, make a commit, or react to this message. Maintainers can also add a 'keep-open' label to exempt this HIP.
107+
EOF
108+
)"
95109

96110
echo " Warning posted for PR #$PR_NUMBER"
97111

0 commit comments

Comments
 (0)