diff --git a/audit/README.md b/audit/README.md new file mode 100644 index 0000000..f0d46d3 --- /dev/null +++ b/audit/README.md @@ -0,0 +1,12 @@ +# Audit + +Actuellement, deux voies d'audit : +- liste des paquets Debian utilisés ; +- test vrms. + +# 2023 + +Résultat de l'audit du 04/01/2023 : +- les paquets : +- le test vrms : + diff --git a/audit/dopackagelist b/audit/dopackagelist new file mode 100644 index 0000000..dc5b49d --- /dev/null +++ b/audit/dopackagelist @@ -0,0 +1,63 @@ +#!/bin/bash + +# 2023-01-04 Cpm + +align_dpkgs() +{ + local source_file="$1" + local letter="$2" + + # Find the longest position. + local max=0 + while read -r line; do + if [[ $line =~ '||/ N' ]]; then + local pos=$(expr index "$line" "$letter") + if (( $pos > $max)); then + max=$pos + fi + fi + done < "$source_file" + + # Insert spaces. + local currentpos=0 + local middle="" + while read -r line; do + #echo -e "$line\n" + if [[ $line =~ '||/ N' ]]; then + local currentpos=$(expr index "$line" "$letter") + currentpos=$(($currentpos-1)) + local diff=$(($max-currentpos-1)) + middle=$(printf %${diff}s) + + local start=${line:0:currentpos} + local end=${line:currentpos} + echo "${start}${middle}${end}" + + elif [[ $line =~ 'ii ' ]]; then + local start=${line:0:currentpos} + local end=${line:currentpos} + echo "${start}${middle}${end}" + fi + done < "$source_file" +} + +# ############################################################################## + +# Put all dpkg -l output in one file. +dpkg -l --no-pager > tmp +for guest in $(cat machines.txt) ; +do + ssh -t admin666@$guest dpkg -l --no-pager >> tmp +done + +# Align the column Version. +align_dpkgs "tmp" "V" > tmp2 + +# Align the column Architecture. +align_dpkgs "tmp2" "A" > tmp + +# Output cleaned lines. +grep "^ii" tmp | sort | uniq + +# Clean temprary files. +rm tmp tmp2 diff --git a/audit/dovrmslist b/audit/dovrmslist new file mode 100644 index 0000000..934140e --- /dev/null +++ b/audit/dovrmslist @@ -0,0 +1,7 @@ +#!/bin/bash + +for guest in $(cat machines.txt) ; +do + echo "===== $guest =====" + ssh -t admin666@$guest vrms +done diff --git a/audit/machines.txt b/audit/machines.txt new file mode 100644 index 0000000..e998964 --- /dev/null +++ b/audit/machines.txt @@ -0,0 +1,3 @@ +alpha@foo.bar +bravo@foo.bar +charlie@foo.bar