Skip to content

Commit 28b209b

Browse files
committed
good bot
1 parent 76b9a2f commit 28b209b

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

scripts/scan_workflow_logs.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,18 @@ find . -type f -name "*.txt" | while IFS= read -r logfile; do
7979
line_num=$(echo "$line" | cut -d: -f2)
8080
content=$(echo "$line" | cut -d: -f3-)
8181

82+
# Sanitize content to prevent command injection and log poisoning
83+
sanitized_content=$(echo "$content" | tr -d '\n\r' | head -c 200)
84+
8285
# Determine the type of issue and output both annotation and count
8386
if echo "$content" | grep -qiE '\berror\b'; then
84-
echo "::error file=$job_name,line=$line_num::$content"
87+
echo "::error file=$job_name,line=$line_num::$sanitized_content"
8588
echo "error" >> "$results_file"
8689
elif echo "$content" | grep -qiE '\bwarning:'; then
87-
echo "::warning file=$job_name,line=$line_num::$content"
90+
echo "::warning file=$job_name,line=$line_num::$sanitized_content"
8891
echo "warning" >> "$results_file"
8992
elif echo "$content" | grep -qiE '\bdeprecated\b'; then
90-
echo "::warning file=$job_name,line=$line_num::$content"
93+
echo "::warning file=$job_name,line=$line_num::$sanitized_content"
9194
echo "deprecated" >> "$results_file"
9295
fi
9396
done < <(grep -niE '(\berror\b|warning:|deprecated)' "$logfile" 2>/dev/null || true)

{{cookiecutter.project_name|replace(" ", "")}}/scripts/scan_

Whitespace-only changes.

{{cookiecutter.project_name|replace(" ", "")}}/scripts/scan_workflow_logs.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,18 @@ find . -type f -name "*.txt" | while IFS= read -r logfile; do
7979
line_num=$(echo "$line" | cut -d: -f2)
8080
content=$(echo "$line" | cut -d: -f3-)
8181

82+
# Sanitize content to prevent command injection and log poisoning
83+
sanitized_content=$(echo "$content" | tr -d '\n\r' | head -c 200)
84+
8285
# Determine the type of issue and output both annotation and count
8386
if echo "$content" | grep -qiE '\berror\b'; then
84-
echo "::error file=$job_name,line=$line_num::$content"
87+
echo "::error file=$job_name,line=$line_num::$sanitized_content"
8588
echo "error" >> "$results_file"
8689
elif echo "$content" | grep -qiE '\bwarning:'; then
87-
echo "::warning file=$job_name,line=$line_num::$content"
90+
echo "::warning file=$job_name,line=$line_num::$sanitized_content"
8891
echo "warning" >> "$results_file"
8992
elif echo "$content" | grep -qiE '\bdeprecated\b'; then
90-
echo "::warning file=$job_name,line=$line_num::$content"
93+
echo "::warning file=$job_name,line=$line_num::$sanitized_content"
9194
echo "deprecated" >> "$results_file"
9295
fi
9396
done < <(grep -niE '(\berror\b|warning:|deprecated)' "$logfile" 2>/dev/null || true)

0 commit comments

Comments
 (0)