Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to display control status summarized by family #49

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions scripts/control-status
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ $0: Get rough list of implementation statuses from control markdown files

Usage:
$0 -h
$0 [-s INCLUDE_STATUS_LIST] [-i IGNORED_STATUS_LIST] [-m MARKDOWN_DIR]
$0 [-s INCLUDE_STATUS_LIST] [-i IGNORED_STATUS_LIST] [-m MARKDOWN_DIR] [-f]

Options:
-h: show help and exit
-s: status names to include, given as comma separated list. Defaults to all controls
-i: status names to ignore, given as comma separated list.
-m: Directory containing markdown files. Defaults to 'markdown' value in config, or 'control-statements'
-f: Summarize counts by control family

Notes:
* passing '-s' will take precedence over '-i'
Expand All @@ -23,9 +24,13 @@ source /app/bin/functions.sh
markdown=$(yaml_parse_value 'trestle-config.yaml' 'markdown' 'control-statements')
ignored=""
status=""
summarize_by_family="false"

while getopts "hs:i:m:" opt; do
while getopts "hfs:i:m:" opt; do
case "$opt" in
f)
summarize_by_family="true"
;;
s)
status=`sed s/,/"\\\\\|"/g <<< ${OPTARG}`
;;
Expand All @@ -52,8 +57,11 @@ if [ "$status" != "" ]; then
elif [ "$ignored" != "" ]; then
result=`grep -v $ignored <<< $result`
fi

cat <<< $result

if [ "$summarize_by_family" = "true" ]; then
result=`awk -F'[-:]' '{print $1 $3}' <<< $result`
fi
echo "==========================================================================="
echo "$(wc -l <<< $result) controls found"
cut -d':' -f2 <<< $result | sort | uniq -c
Expand Down