From f554f50058fceeb10a763b54cdc1e8dc981e270b Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Mon, 26 Nov 2018 15:06:13 +0900 Subject: [PATCH] new: [doc] Added script to generate galaxy section from repo --- galaxy/README.md | 2 ++ galaxy/gen-doc.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 galaxy/gen-doc.sh diff --git a/galaxy/README.md b/galaxy/README.md index a5bfc42..a74c802 100644 --- a/galaxy/README.md +++ b/galaxy/README.md @@ -68,6 +68,8 @@ Clicking on the addition symbol on the left of Beijing Group extends the module. ### Available Galaxies + + #### Clusters [Android](https://github.com/MISP/misp-galaxy/blob/master/clusters/android.json) - Android malware galaxy based on multiple open sources. diff --git a/galaxy/gen-doc.sh b/galaxy/gen-doc.sh new file mode 100755 index 0000000..c91af8b --- /dev/null +++ b/galaxy/gen-doc.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# This generates some of the sections of the Galaxy Documentation +# Dependencies: git, jq, bash + +if [[ ! -d "misp-galaxy" ]]; then + git clone https://github.com/MISP/misp-galaxy.git + cd misp-galaxy +else + cd misp-galaxy + git pull +fi + +FOLDERS='clusters vocabularies/common vocabularies/threat-actor' + +for folder in ${FOLDERS}; do + cd $folder + + for file in $(ls |grep -v README); do + Name=$(echo ${file} |cut -f 1 -d.| tr '-' ' '| tr '_' ' ') + Name=$(tr '[:lower:]' '[:upper:]' <<< ${Name:0:1})${Name:1} + Description=$(jq -r .description ${file}) + + echo "[${Name}](https://github.com/MISP/misp-galaxy/blob/master/${folder}/${file}) - ${Description}" + echo "" + done + echo "------------------------------------------------------------------------------------" + echo "$folder done" + echo "------------------------------------------------------------------------------------" + # This is ugly, but works... fix it if you do not like it. + if [[ $folder == *'/'* ]]; then + cd ../.. + else + cd .. + fi +done