From e5462afb159c3c9542d58248653634521fedd9c6 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Fri, 11 Oct 2024 11:14:31 +0000 Subject: [PATCH] Added support for blog posts and articles to support suggestions --- db/control-links.db | 4 ++++ include/report | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/control-links.db diff --git a/db/control-links.db b/db/control-links.db new file mode 100644 index 00000000..c2606e93 --- /dev/null +++ b/db/control-links.db @@ -0,0 +1,4 @@ +# Links for controls pointing to informational pages. Note: only links managed by the project are allowed (cisofy.com / linux-audit.com) +# Format: Control;Text;Link; +BOOT-5264;blog;Systemd features to secure service files;https://linux-audit.com/systemd/systemd-features-to-secure-units-and-services/; +# EOF diff --git a/include/report b/include/report index ec5f3f66..55791039 100644 --- a/include/report +++ b/include/report @@ -161,7 +161,8 @@ for SUGGESTION in ${SUGGESTIONS}; do SOLUTION="" SHOWSUGGESTION=$(echo ${SUGGESTION} | sed 's/!space!/ /g' | sed 's/^.* Suggestion: //' | sed 's/\[details:\(.*\)\] \[solution:\(.*\)\]//' | sed 's/test://') - ADDLINK=$(echo ${SUGGESTION} | sed 's/!space!/ /g' | sed 's/^.* Suggestion: \(.*\)\[test://' | sed 's/\]\(.*\)]//' | ${AWKBINARY} -F: '{print $1}') + RELATED_CONTROL=$(echo ${SUGGESTION} | sed 's/!space!/ /g' | sed 's/^.* Suggestion: \(.*\)\[test://' | sed 's/\]\(.*\)]//' | ${AWKBINARY} -F: '{print $1}') + ADDLINK="${RELATED_CONTROL}" DETAILS=$(echo ${SUGGESTION} | sed 's/!space!/ /g' | sed 's/^.* Suggestion: \(.*\)\[details://' | sed 's/\]\(.*\)]//') SUGGESTION_PIECES=$(echo ${SUGGESTION} | sed 's/\[/ [/g') for PIECE in ${SUGGESTION_PIECES}; do @@ -174,10 +175,15 @@ echo " ${YELLOW}*${NORMAL} ${SHOWSUGGESTION}" if [ ! "${DETAILS}" = "-" -a -n "${DETAILS}" ]; then echo " - Details : ${CYAN}${DETAILS}${NORMAL}"; fi if [ ${SHOW_REPORT_SOLUTION} -eq 1 -a ! "${SOLUTION}" = "-" ]; then echo " - Solution : ${SOLUTION}"; fi + # Show relevant articles if the database is available + if [ -f ${DBDIR}/control-links.db ]; then + echo " - Related resources:" + $AWKBINARY -F \; -v control=${RELATED_CONTROL} '{if($1==control && $2=="blog"){print " * Article - "$3": "$4}}' "${DBDIR}/control-links.db" + fi if [ -z "${IS_CUSTOM}" ]; then - echo " ${GRAY}${CONTROL_URL_PROTOCOL}://${CONTROL_URL_PREPEND}${ADDLINK}${CONTROL_URL_APPEND}${NORMAL}" + echo " * Website - ${GRAY}${CONTROL_URL_PROTOCOL}://${CONTROL_URL_PREPEND}${ADDLINK}${CONTROL_URL_APPEND}${NORMAL}" else - echo " ${GRAY}${CUSTOM_URL_PROTOCOL}://${CUSTOM_URL_PREPEND}${ADDLINK}${CUSTOM_URL_APPEND}${NORMAL}" + echo " * Details - ${GRAY}${CUSTOM_URL_PROTOCOL}://${CUSTOM_URL_PREPEND}${ADDLINK}${CUSTOM_URL_APPEND}${NORMAL}" fi echo "" done