Skip to content

Commit d36025c

Browse files
committed
Support Markdown reports
1 parent d075eaf commit d36025c

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

domains/anomaly-detection/anomalyDetectionCsv.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Pipeline that coordinates anomaly detection using the Graph Data Science Library of Neo4j.
44
# It requires an already running Neo4j graph database with already scanned and analyzed artifacts.
55
# The results will be written into the sub directory reports/anomaly-detection.
6+
# Dynamically triggered by "CsvReports.sh".
67

78
# Note that "scripts/prepareAnalysis.sh" is required to run prior to this script.
89

domains/anomaly-detection/anomalyDetectionPython.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Pipeline that coordinates anomaly detection using the Graph Data Science Library of Neo4j.
44
# It requires an already running Neo4j graph database with already scanned and analyzed artifacts.
55
# The results will be written into the sub directory reports/anomaly-detection.
6+
# Dynamically triggered by "PythonReports.sh".
67

78
# Note that "scripts/prepareAnalysis.sh" is required to run prior to this script.
89

scripts/reports/compilations/AllReports.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ echo "AllReports: REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DI
2626
source "${REPORT_COMPILATIONS_SCRIPT_DIR}/CsvReports.sh"
2727
source "${REPORT_COMPILATIONS_SCRIPT_DIR}/JupyterReports.sh"
2828
source "${REPORT_COMPILATIONS_SCRIPT_DIR}/PythonReports.sh"
29-
source "${REPORT_COMPILATIONS_SCRIPT_DIR}/VisualizationReports.sh"
29+
source "${REPORT_COMPILATIONS_SCRIPT_DIR}/VisualizationReports.sh"
30+
source "${REPORT_COMPILATIONS_SCRIPT_DIR}/MarkdownReports.sh"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
# Runs all Markdown report scripts (no Chromium required, no Python required).
4+
# It only considers scripts in the "reports" and "domains" directories and their sub directories (overridable with REPORTS_SCRIPT_DIR and DOMAINS_DIRECTORY).
5+
6+
# Requires reports/*.sh
7+
8+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
9+
set -o errexit -o pipefail
10+
11+
# Overrideable Constants (defaults also defined in sub scripts)
12+
LOG_GROUP_START=${LOG_GROUP_START:-"::group::"} # Prefix to start a log group. Defaults to GitHub Actions log group start command.
13+
LOG_GROUP_END=${LOG_GROUP_END:-"::endgroup::"} # Prefix to end a log group. Defaults to GitHub Actions log group end command.
14+
15+
## Get this "scripts/reports/compilations" directory if not already set.
16+
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
17+
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
18+
# This way non-standard tools like readlink aren't needed.
19+
REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )}
20+
echo "MarkdownReports: REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DIR}"
21+
22+
REPORTS_SCRIPT_DIR=${REPORTS_SCRIPT_DIR:-$(dirname -- "${REPORT_COMPILATIONS_SCRIPT_DIR}")}
23+
echo "MarkdownReports: REPORTS_SCRIPT_DIR=${REPORTS_SCRIPT_DIR}"
24+
25+
SCRIPTS_DIR=${SCRIPTS_DIR:-$(dirname -- "${REPORTS_SCRIPT_DIR}")}
26+
echo "MarkdownReports: SCRIPTS_DIR=${SCRIPTS_DIR}"
27+
28+
# Get the "domains" directory that contains analysis and report scripts by functionality.
29+
DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY:-"${REPORTS_SCRIPT_DIR}/../../domains"}
30+
echo "MarkdownReports: DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY}"
31+
32+
# Run all Markdown report scripts (filename ending with Markdown.sh or Summary.sh) in the REPORTS_SCRIPT_DIR and DOMAINS_DIRECTORY directories.
33+
for directory in "${REPORTS_SCRIPT_DIR}" "${DOMAINS_DIRECTORY}"; do
34+
if [ ! -d "${directory}" ]; then
35+
echo "MarkdownReports: Error: Directory ${directory} does not exist. Please check your REPORTS_SCRIPT_DIR and DOMAIN_DIRECTORY settings."
36+
exit 1
37+
fi
38+
39+
# Run all Python report scripts for the selected directory.
40+
find "${directory}" -type f \( -name "*Markdown.sh" -o -name "*Summary.sh" \) | sort | while read -r report_script_file; do
41+
report_script_filename=$(basename -- "${report_script_file}");
42+
report_script_filename="${report_script_filename%.*}" # Remove file extension
43+
44+
echo "${LOG_GROUP_START}Create Markdown Report ${report_script_filename}";
45+
echo "MarkdownReports: $(date +'%Y-%m-%dT%H:%M:%S%z') Starting ${report_script_filename}...";
46+
47+
source "${report_script_file}"
48+
49+
echo "MarkdownReports: $(date +'%Y-%m-%dT%H:%M:%S%z') Finished ${report_script_filename}";
50+
echo "${LOG_GROUP_END}";
51+
done
52+
done

0 commit comments

Comments
 (0)