-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(action, workflows): optimize known hosts handling and remove…
… noop script action.sh: • Improved SSH keyscan logic to filter comments from known hosts. • Removed redundant chmod as it’s handled implicitly. • Ensured unset for SSH_KNOWN_HOSTS_FILE for cleanup. post_action.sh: • Introduced logic to clean up the last entry in known_hosts. • Improved clarity and consistency with explicit unset for temporary variables. post_check.sh: • Added a check to validate known_hosts does not retain specific SSH fingerprints post-execution. • pull_request.yml: • Simplified steps by merging noop logic into the post-check script. • Removed noop.sh, ensuring streamlined workflow execution. These updates enhance security, maintain clean execution contexts, and reduce redundant scripting.
- Loading branch information
Showing
5 changed files
with
30 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
#!/usr/bin/env sh | ||
|
||
if [ -z "${SSH_KNOWN_HOSTS_FILE}" ]; then | ||
echo "::error file=$(basename "$0"),line=${LINENO},endLine=${LINENO},title=Notice::\ | ||
${SSH_KNOWN_HOSTS_FILE} environment variable must be set." | ||
#else | ||
# rm -rf "${SSH_KNOWN_HOSTS_FILE}" | ||
#echo "::notice file=$(basename "$0"),line=${LINENO},endLine=${LINENO},title=Notice::\ | ||
#${SSH_KNOWN_HOSTS_FILE} has been removed." | ||
fi | ||
TEMP_FILE="/tmp/718f4157-5493-43b2-837b-3ccb27f78e7b" | ||
|
||
head --lines=-1 "${SSH_KNOWN_HOSTS_FILE}" > "${TEMP_FILE}" | ||
cat "${TEMP_FILE}" > "${SSH_KNOWN_HOSTS_FILE}" | ||
rm -rf "${TEMP_FILE}" | ||
|
||
echo "::notice file=$(basename "$0"),line=${LINENO},endLine=${LINENO},title=Notice::\ | ||
${SSH_KNOWN_HOSTS_FILE} has been cleaned." | ||
Check notice on line 10 in post_action.sh GitHub Actions / test (macos-15)Notice
|
||
|
||
unset TEMP_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
#!/usr/bin/env sh | ||
|
||
if [ -s "${HOME}/.ssh/known_hosts" ]; then | ||
echo "ok" | ||
#echo "::error file=$(basename "$0"),line=${LINENO},endLine=${LINENO},title=Assertion Error::\ | ||
#~/.ssh/known_hosts file should not exist after the job." | ||
#exit 1 | ||
fi | ||
SSH_KNOWN_HOSTS_FILE="${HOME}/.ssh/known_hosts" | ||
|
||
if ! grep -q "${SSH_KNOWN_HOSTS}" "${SSH_KNOWN_HOSTS_FILE}" ; then | ||
echo "::error file=$(basename "$0"),line=${LINENO},endLine=${LINENO},title=Assertion Error::\ | ||
${SSH_KNOWN_HOSTS_FILE} file should not contain the ssh fingerprint after the job." | ||
exit 1 | ||
fi | ||
|
||
unset SSH_KNOWN_HOSTS_FILE |