I am working with bash and gh cli to create a table for a summarized report that goes into a newly created issue. I am stuck on 2 problems:
Severity | Type | Issue URL |
---|
But, the special characters do not turn into a table in the issue body. instead I get the raw input. maybe it is because I used <br>
to go down a line? <br>
was the only thing that worked, \n
\n\r
and other options didn't do it. This is a screenshot of the issue created:
2. I have to run over many scans and I want to gather each alert severity into a group and at the end of the code to append them all together for better readability. My idea was that by knowing what is the SEVERITY
I'll append it into the proper *_alerts
var. I need help making these lines functional:
"${SEVERITY}_Alerts"="${${SEVERITY}_Alerts} | $SEVERITY | $alertType | URL |<br>"
REPORT="${REPORT}${High_Alerts}${Medium_Alerts}${Low_Alerts}${Informational_Alerts}"
For a better context, this is what I came up with so far:
SEVERITY="High"
High_Alerts=''
Medium_Alerts=''
Low_Alerts=''
Informational_Alerts=''
REPORT=$"###Unified zap-scan report ran at $(date) <br><br> | Severity | Type | Issue URL | <br> | ----------- | ----------- | ----------- |<br>"
for ((i = 0; i < ${#BODY[@]}; i++)); do
line=${BODY[$i]}
if [[ $line =~ "Alert\nAlert" ]]; then
line=${line##*#}
line=${line%%A*}
SEVERITY=$line
i=$i+1
line=${BODY[$i]}
alertType="${line%%\\*}"
i=$i+2
REPORT=$"${REPORT} | $SEVERITY | ${alertType} | URL |<br>"
#"${SEVERITY}_Alerts"="${${SEVERITY}_Alerts} | $SEVERITY | $alertType | URL |<br>"
elif [[ $line =~ "\nAlert" ]]; then
i=$i+1
line=${BODY[$i]}
alertType="${line%%\\*}"
i=$i+2
REPORT=$"${REPORT} | $SEVERITY | ${alertType} | URL |<br>"
#"${SEVERITY}_Alerts"="${${SEVERITY}_Alerts} | $SEVERITY | $alertType | URL |<br>"
fi
done
#REPORT="${REPORT}${High_Alerts}${Medium_Alerts}${Low_Alerts}${Informational_Alerts}"
the command to create the issue works perfect, it's the input to the body of the issue that is wrong.
<br>
into $'\r\n'
accordingly.jq
to query and get the value itself. On the same note, the value will be with double quotes and therefore I used substitution operators as such: URL=${URL%\"} #remove last double quote
URL=${URL#\"} #remove first double quote
Those double quotes broke the symlinks I tried to create so better watch out from them