File tree Expand file tree Collapse file tree
{{cookiecutter.project_name|replace(" ", "")}}/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff 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)
You can’t perform that action at this time.
0 commit comments