From 8b61c26fd62a9f79f4416a9f1e9f6e1cc6e48065 Mon Sep 17 00:00:00 2001 From: robstoll <5557885+robstoll@users.noreply.github.com> Date: Mon, 4 Nov 2024 04:07:04 +0000 Subject: [PATCH] update files of remote tegonal-scripts to version v4.1.0 via gt --- .gt/remotes/tegonal-scripts/pulled.tsv | 38 ++-- .../src/ci/install-shellcheck.sh | 2 +- lib/tegonal-scripts/src/qa/run-shellcheck.sh | 2 +- lib/tegonal-scripts/src/setup.sh | 2 +- .../src/utility/array-utils.sh | 2 +- lib/tegonal-scripts/src/utility/ask.sh | 2 +- lib/tegonal-scripts/src/utility/checks.sh | 26 ++- lib/tegonal-scripts/src/utility/git-utils.sh | 2 +- lib/tegonal-scripts/src/utility/gpg-utils.sh | 192 ++++++++++++++++-- lib/tegonal-scripts/src/utility/io.sh | 2 +- lib/tegonal-scripts/src/utility/log.sh | 2 +- lib/tegonal-scripts/src/utility/parse-args.sh | 25 ++- .../src/utility/parse-commands.sh | 2 +- .../src/utility/parse-fn-args.sh | 2 +- .../src/utility/parse-utils.sh | 4 +- .../src/utility/recursive-declare-p.sh | 2 +- .../src/utility/replace-help-snippet.sh | 2 +- .../src/utility/replace-snippet.sh | 2 +- .../src/utility/source-once.sh | 2 +- .../src/utility/update-bash-docu.sh | 2 +- 20 files changed, 252 insertions(+), 63 deletions(-) diff --git a/.gt/remotes/tegonal-scripts/pulled.tsv b/.gt/remotes/tegonal-scripts/pulled.tsv index 019fd23..2424fa1 100644 --- a/.gt/remotes/tegonal-scripts/pulled.tsv +++ b/.gt/remotes/tegonal-scripts/pulled.tsv @@ -1,21 +1,21 @@ #@ Version: 1.1.0 tag file relativeTarget tagFilter sha512 -v3.5.0 src/setup.sh ../lib/tegonal-scripts/src/setup.sh .* c72440ceb9dfffca3feacb4d652f8b6ad1266277a1549b6271a47e1c0fdc0746994cf01a1a0335a95e1c7e93454a1fdade9007d7d2226f20e95e6f52ea0d0fa7 -v3.5.0 src/utility/io.sh ../lib/tegonal-scripts/src/utility/io.sh .* e905f8ec3c0ea6b5d3a3c3a295bab690cc2b9d42ec784d56ec525f24044490c216756e05f6d9312f6379821e3f7208d44990bd8c598e9b268f40cc933951dcc9 -v3.5.0 src/utility/array-utils.sh ../lib/tegonal-scripts/src/utility/array-utils.sh .* 357c47ad757cdd8be932f2c1b6c000c58e5b502fe1d19c921568d736355e04ff01b652b407a0f04664ccfc1c2cfbd8e0b3b8a695521ce0a3a88eb289c8cbaf38 -v3.5.0 src/utility/parse-utils.sh ../lib/tegonal-scripts/src/utility/parse-utils.sh .* 04164299e848f75681497284e5c9b358a62f98d213c60d9f2a576342f7a116a9b1a4acf6a591d1535dfc0351b2f656a3f8c4f838ec8e01611f94c3e0111e46d2 -v3.5.0 src/utility/git-utils.sh ../lib/tegonal-scripts/src/utility/git-utils.sh .* dcbf51d144a2e797df34862e495fcb1a8c0387990c7454158c40f5ebf38d1837a9c75fca09c5fa4ae88905b2d21ceafa3ee657bb6ab2cbc3924dea51e47393b3 -v3.5.0 src/utility/gpg-utils.sh ../lib/tegonal-scripts/src/utility/gpg-utils.sh .* ea15975b230cabcc1d75afea011270b4d5c03e2ea4dda8558bd2060b4a2b4f02d48022019c83b23d85f83fefc7de1a8a87318cda0af7e948c3912aa3d7cda8b7 -v3.5.0 src/utility/log.sh ../lib/tegonal-scripts/src/utility/log.sh .* 3fdea7b78d37c9424602c1d0ff90ff19b7e7d3674d8ad412777754221118851ebdab41c129fb9181110a3639a19712ebf81ed35d4b86314814a53d99bbb2b26f -v3.5.0 src/utility/parse-fn-args.sh ../lib/tegonal-scripts/src/utility/parse-fn-args.sh .* 64b8f1dac3ed9cf860719b40f6e9adfa973096a4754714de20bbb9f42ade1572a754eeea1495a12395529bd71f1d4b280e613a23d26edd7e5546486fe9b9cbb4 -v3.5.0 src/utility/update-bash-docu.sh ../lib/tegonal-scripts/src/utility/update-bash-docu.sh .* a2194e8afba6d70589d3f3aed954e303c956125746ddbdd97beaa0ef015d354ce08949c712cbb80e26a0da52399cb90d8551b9dc60ab2ac890c6d1e8b03318da -v3.5.0 src/utility/parse-args.sh ../lib/tegonal-scripts/src/utility/parse-args.sh .* 18a1b91f8e3aa6c61805ca8a9cf43ac87a817b61032297455aaff198a65b9d2fbfcb7bb3bdac9a940020129694ce2a7997d917e51413e8228dce4265df59a96a -v3.5.0 src/utility/checks.sh ../lib/tegonal-scripts/src/utility/checks.sh .* 1a25b07c8a19b93b5ca91582fb636e9273911fed455de2964a803ac09416201739bcd66eab39a94d9916f8d4a668c5c75bbd8f4b5bf6fb4fdc11b912d056b245 -v3.5.0 src/utility/parse-commands.sh ../lib/tegonal-scripts/src/utility/parse-commands.sh .* 9e2b1a685aa14c574e1421ba6e3155a112dc47c069a09d048ced9f22eb85b400c701239ae5c64f898c384df97d849a008925ca22b67cfba42e89a8c5fc09a16a -v3.5.0 src/utility/replace-snippet.sh ../lib/tegonal-scripts/src/utility/replace-snippet.sh .* 0eaf94a12decc88f3c905290da1b18d0037f6d9fb6908517d3d85ec48972e0ee0288e8de5e2b88fb36e4d24f5ebe8d9a5b819d0afe5c7f35ad778c41b1a3f1d5 -v3.5.0 src/utility/ask.sh ../lib/tegonal-scripts/src/utility/ask.sh .* 4678ad9224783ef52e49e6eb65c16eea902a1a22d28754fd70911b5bceb1810093e6942a57ed473c99a4ae8985b649b569444e16a549a80f102eff97a43d4691 -v3.5.0 src/utility/replace-help-snippet.sh ../lib/tegonal-scripts/src/utility/replace-help-snippet.sh .* 6fb6bd4aacc13cd02889b125642ceb0b7e3cf7032412d692f85fa412f9457873345aa49d53d98fefdd8056f84bc36d0dea4e8f1e6ee4d7adff3de67c23bccc40 -v3.5.0 src/utility/source-once.sh ../lib/tegonal-scripts/src/utility/source-once.sh .* f9464a208738c42754b316328586eb7a5c52cffddb57aa27ce15c4e67889667d4b7df6736a97df5ce0ca64ffe430151c6055f6e0cb53c0057f7111242895394c -v3.5.0 src/utility/recursive-declare-p.sh ../lib/tegonal-scripts/src/utility/recursive-declare-p.sh .* b48bd331c9d3300ab676e969fd8b51bffb409de15b5745f30a7f3867a1a14a50828c5f83e4bc104c5e481261508578903a579986b7e2b7b0f23fe0d5e1ead621 -v3.5.0 src/ci/install-shellcheck.sh ../lib/tegonal-scripts/src/ci/install-shellcheck.sh .* 5dd7f1e67ebe2c1c1ea2e51b6e42ace0cf9c2963781b873d223e279c0df03c64b2781bb67c2d8ad1630915f24145fda3a4ab965250be91f20f9cd0574654563e -v3.5.0 src/qa/run-shellcheck.sh ../lib/tegonal-scripts/src/qa/run-shellcheck.sh .* c4777d0e64ccfdfd96114227ca703668a9938d3c27cd7f931ef10b8eb7cd943c089dc1b83c4508c77fea275e656b0d9e548157b64f68fa55446a344443ef7cce +v4.1.0 src/setup.sh ../lib/tegonal-scripts/src/setup.sh .* 367096ca9ecf47b6362334adcef1854b61144583dd38366b62e33c8cb237566e37ccc257e151309ee3fe234d7a4f62b1b8eafb9523291ffcea37e5776e4535fb +v4.1.0 src/utility/io.sh ../lib/tegonal-scripts/src/utility/io.sh .* a2ad3a78707e0b2e526aff11dd1b6e638538e2ff166640e1c4fb4920631e545cab0c4ca2115fe1a84e73ec57af767fb7ce2ca6c490d9bdb2b7d20429c6dd5e23 +v4.1.0 src/utility/array-utils.sh ../lib/tegonal-scripts/src/utility/array-utils.sh .* 6dc55f7c5253487b639a27bf72d26be4fc0e2d5bd0992153eacaacfeba94ca48095ef813739fefb70f463e3f380b81dde2a69fe7d03c65594ee6a1d2e15768f7 +v4.1.0 src/utility/parse-utils.sh ../lib/tegonal-scripts/src/utility/parse-utils.sh .* 5fccddbda4693e8023b29bc6643e9b0007ac8d0fbcbc6ee7bec21e100a07b7494b9f2b859d8d3ec96f55d25c40c5e099ccccb70d2a3b59471ee4809c5d4aa7a4 +v4.1.0 src/utility/git-utils.sh ../lib/tegonal-scripts/src/utility/git-utils.sh .* bc0d26307b727bd9f57cbfd3e985ce03a5c35c8680e3a2e31232f0595ddba623d4bd4407f673726b3d72f794fd59ab7e366a1c61b3b7b019560cce53e8e27b45 +v4.1.0 src/utility/gpg-utils.sh ../lib/tegonal-scripts/src/utility/gpg-utils.sh .* 6285589a9d236d32d9b356cc6b6b2dd9500fb6c1953453037c6553420cc88ba034fc74dc09ba5883308fec20e1195966bf3d0ad434a7fc83a4b5f508377ea5d9 +v4.1.0 src/utility/log.sh ../lib/tegonal-scripts/src/utility/log.sh .* 46f93eb32ec5efa427eaf7123580252e8be1d6e35102bf2086d9029e9ce8710fa241cc92bf91c53468c2c76c0ff29c5925276a8251fa2c86e2307765de52e65f +v4.1.0 src/utility/parse-fn-args.sh ../lib/tegonal-scripts/src/utility/parse-fn-args.sh .* 6a7b9a1155ac735947287aba434a57aa7b7d9f03ed9fd1892534dd997a7bb1a47772aeaf4c3d03abeca6c5488474a98bf5c1ee0d132d54be94d7bcfeaf238166 +v4.1.0 src/utility/update-bash-docu.sh ../lib/tegonal-scripts/src/utility/update-bash-docu.sh .* 0d83945d75de6a5b3b3ebee075f7fc62672a4c3447c583343c14b51f228042ec26415d427ff4051d0d08a0819b203842093c143ab802b875f40c4f92287ebf1e +v4.1.0 src/utility/parse-args.sh ../lib/tegonal-scripts/src/utility/parse-args.sh .* 033fe2e847eddae72e801c5f3bc48f0533908b40ed82a5830be2b99b04d0e8449384db56581b20cc48b5508cb6b9e461ade4f42187dc95a28acdbf764d37f2db +v4.1.0 src/utility/checks.sh ../lib/tegonal-scripts/src/utility/checks.sh .* 51514ae334e1539f239ead23092b0b6232575987ef85b656630f5a4d0276465f8bde18dc7252a32bec524244dc1ba98a21a33b3a4c63c49ac7f4491b10fd767d +v4.1.0 src/utility/parse-commands.sh ../lib/tegonal-scripts/src/utility/parse-commands.sh .* ba03b365515a534d1e90c6e4399267d11c326344e1ca2aeaea2a147d5640c8fc24c758b6d3189871af74e42597941a0e8a9cb81a44969b5d3023dbb487ef2251 +v4.1.0 src/utility/replace-snippet.sh ../lib/tegonal-scripts/src/utility/replace-snippet.sh .* c897db71ec57f0a22af0c20bbcf88e276d960486270f1baaf0c2067fd3b808b21d9fdbc5e6892ac317014af46c353220ce6f7d6769e3d07092514a5c04077c43 +v4.1.0 src/utility/ask.sh ../lib/tegonal-scripts/src/utility/ask.sh .* 9aa040b6ba76226ae78a8fd1b1050a2f3b6a617b148d765fcaf7535d0427944467fbf78d8a5390f240d2277db0da588438209f29a47b2d4b71983907868e191f +v4.1.0 src/utility/replace-help-snippet.sh ../lib/tegonal-scripts/src/utility/replace-help-snippet.sh .* bea5c80ef818f6166c2a4e2fe9a60faf49c89180adcd1e050df847e3dee7ad2a97ccc0b2fc0791822f58b8a117cada7f1aa0a9d4f85063e423b67bf5fdeb4af7 +v4.1.0 src/utility/source-once.sh ../lib/tegonal-scripts/src/utility/source-once.sh .* 2ee912c2084b3a164782f433d99dbb24e58fd486530e4ea68e2ebc23a0e7b20d719bc406ad41e85eb5cd82b0a272beab5f5271a97330182ab779c92904506133 +v4.1.0 src/utility/recursive-declare-p.sh ../lib/tegonal-scripts/src/utility/recursive-declare-p.sh .* ae10280d370761efb5b8f6a8432d36b2416a424abe5396b1e76afc2db123b21fd496a4498882b58b9b68328b840aa93876de1821d898b29b29402d83c0a116bb +v4.1.0 src/ci/install-shellcheck.sh ../lib/tegonal-scripts/src/ci/install-shellcheck.sh .* 10c3afa100760db36340f63832fafd25413e71b57dd5209f83b721c656132216477dfa0067e51a3b20b27a9dc6ecfc3d25b852d5004e3180f14a620c5c70f346 +v4.1.0 src/qa/run-shellcheck.sh ../lib/tegonal-scripts/src/qa/run-shellcheck.sh .* 49974ff2aa3bf73d485e8f091a133689d54a81ae68cc968aa0b4b64dd65a28af5aa376243355537130c1fecb88f89ca1cb33cc4f8e48bdd1c1f2bebb38b76be5 diff --git a/lib/tegonal-scripts/src/ci/install-shellcheck.sh b/lib/tegonal-scripts/src/ci/install-shellcheck.sh index 4e12f8e..909073c 100755 --- a/lib/tegonal-scripts/src/ci/install-shellcheck.sh +++ b/lib/tegonal-scripts/src/ci/install-shellcheck.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # function which searches for *.sh files within defined paths (directories or a single *.sh) and diff --git a/lib/tegonal-scripts/src/qa/run-shellcheck.sh b/lib/tegonal-scripts/src/qa/run-shellcheck.sh index c446cc0..03f9e82 100755 --- a/lib/tegonal-scripts/src/qa/run-shellcheck.sh +++ b/lib/tegonal-scripts/src/qa/run-shellcheck.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # function which searches for *.sh files within defined paths (directories or a single *.sh) and diff --git a/lib/tegonal-scripts/src/setup.sh b/lib/tegonal-scripts/src/setup.sh index bcaa60f..776cfbe 100644 --- a/lib/tegonal-scripts/src/setup.sh +++ b/lib/tegonal-scripts/src/setup.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # script which should be sourced and sets up variables and functions for the scripts diff --git a/lib/tegonal-scripts/src/utility/array-utils.sh b/lib/tegonal-scripts/src/utility/array-utils.sh index 6beacb1..b6577f7 100644 --- a/lib/tegonal-scripts/src/utility/array-utils.sh +++ b/lib/tegonal-scripts/src/utility/array-utils.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # utility functions for dealing with arrays diff --git a/lib/tegonal-scripts/src/utility/ask.sh b/lib/tegonal-scripts/src/utility/ask.sh index 0dfce9d..d7c3db4 100644 --- a/lib/tegonal-scripts/src/utility/ask.sh +++ b/lib/tegonal-scripts/src/utility/ask.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Utility functions to ask the user something via input. diff --git a/lib/tegonal-scripts/src/utility/checks.sh b/lib/tegonal-scripts/src/utility/checks.sh index 6f6cdc0..5e97c03 100644 --- a/lib/tegonal-scripts/src/utility/checks.sh +++ b/lib/tegonal-scripts/src/utility/checks.sh @@ -7,7 +7,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Functions to check declarations @@ -74,6 +74,11 @@ # exitIfVariablesNotDeclared myVar4 myVar5 # would exit because myVar5 is not set # echo "myVar4 $myVar4" # +# declare currentDir +# currentDir=$(pwd) +# checkPathNamedIsInsideOf "$myVar4" "source directory" "$currentDir" # same as exitIfPathNamedIsOutsideOf if set -e has an effect on this line +# exitIfPathNamedIsOutsideOf "$myVar4/plugins.txt" "plugins" "$currentDir" +# ################################### set -euo pipefail shopt -s inherit_errexit @@ -310,3 +315,22 @@ function exitIfVariablesNotDeclared() { fi done } + +function checkPathNamedIsInsideOf() { + local path name parentDirectory + # shellcheck disable=SC2034 # is passed by name to parseFnArgs + local -ra params=(path name parentDirectory) + parseFnArgs params "$@" + + local pathAbsolute parentDirectoryAbsolute + pathAbsolute="$(realpath -m "$path")" + parentDirectoryAbsolute="$(realpath -m "$parentDirectory")" + if ! [[ "$pathAbsolute" == "$parentDirectoryAbsolute"* ]]; then + returnDying "the given \033[0;36m%s\033[0m %s is outside of %s" "$name" "$pathAbsolute" "$parentDirectory" || return $? + fi +} + +function exitIfPathNamedIsOutsideOf() { + # shellcheck disable=SC2310 # we are aware of that || will disable set -e for checkIfPathNamedIsOutsideOf + checkPathNamedIsInsideOf "$@" || exit $? +} diff --git a/lib/tegonal-scripts/src/utility/git-utils.sh b/lib/tegonal-scripts/src/utility/git-utils.sh index 17f68a3..07f1dde 100644 --- a/lib/tegonal-scripts/src/utility/git-utils.sh +++ b/lib/tegonal-scripts/src/utility/git-utils.sh @@ -5,7 +5,7 @@ # / __/ -_) _ `/ _ \/ _ \/ _ `/ / It is licensed under Apache License 2.0 # \__/\__/\_, /\___/_//_/\_,_/_/ Please report bugs and contribute back your improvements # /___/ -# Version: v3.5.0 +# Version: v4.1.0 # ####### Description ############# # diff --git a/lib/tegonal-scripts/src/utility/gpg-utils.sh b/lib/tegonal-scripts/src/utility/gpg-utils.sh index 56b355d..d81736e 100644 --- a/lib/tegonal-scripts/src/utility/gpg-utils.sh +++ b/lib/tegonal-scripts/src/utility/gpg-utils.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # utility functions for dealing with gpg @@ -22,18 +22,60 @@ # # sourceOnce "$dir_of_tegonal_scripts/utility/gpg-utils.sh" # -# # import public-key.asc into gpg store located at ~/.gpg but ask for confirmation first -# importGpgKey ~/.gpg ./public-key.asc --confirmation=true -# # # import public-key.asc into gpg store located at ~/.gpg and trust automatically -# importGpgKey ~/.gpg ./public-key.asc --confirmation=false +# importGpgKey ~/.gpg ./public-key.asc +# +# # import public-key.asc into gpg store located at ~/.gpg but ask given question first which needs to be answered with yes +# importGpgKey ~/.gpg ./public-key.asc "do you want to import the shown key(s)?" # -# # import public-key.asc into gpg store located at .gt/.gpg and trust automatically -# importGpgKey .gt/.gpg ./public-key.asc --confirmation=false +# # import public-key.asc into gpg store located at .gt/remotes/tegonal-scripts/public-keys/gpg +# # and trust automatically +# importGpgKey .gt/remotes/tegonal-scripts/public-keys/gpg ./public-key.asc # # # trust key which is identified via info@tegonal.com in gpg store located at ~/.gpg # trustGpgKey ~/.gpg info@tegonal.com # +# # get the gpg key data one can retrieve via --list-key --with-colons (pub or sub) for the key which signed the given file +# getSigningGpgKeyData "file.sig" +# +# # get the gpg key data one can retrieve via --list-key --with-colons (pub or sub) for the key which signed the given file +# # but searches the key not in the default gpg store but in .gt/remotes/tegonal-scripts/public-keys/gpg +# getSigningGpgKeyData "file.sig" .gt/remotes/tegonal-scripts/public-keys/gpg +# +# # returns the creation date of the signature +# getSigCreationDate "file.sig" +# +# keyData="sub:-:4096:1:4B78012139378220:..." +# +# # extract the key id from the given key data +# extractGpgKeyIdFromKeyData "$keyData" +# # extract the expiration timestamp from the given key data +# extractExpirationTimestampFromKeyData "$keyData" +# +# # returns with 0 if the given key data (the key respectively) is expired, non-zero otherwise +# isGpgKeyInKeyDataExpired "$keyData" +# # returns with 0 if the given key data (the key respectively) was revoked, non-zero otherwise +# isGpgKeyInKeyDataRevoked "$keyData" +# +# # returns the revocation data one can retrieve via --list-sigs --with-colons (rev) for the given key +# getRevocationData 4B78012139378220 +# +# # returns the revocation data one can retrieve via --list-sigs --with-colons (rev) for the given key +# # but searches the revocation not in the default gpg store but in .gt/remotes/tegonal-scripts/public-keys/gpg +# getRevocationData 4B78012139378220 .gt/remotes/tegonal-scripts/public-keys/gpg +# +# # extract the creation timestamp from the given revocation data +# extractCreationTimestampFromRevocationData +# +# # list all signatures of the given key and highlights it in the output (which especially useful if the key is a subkey +# # and there are other subkeys) +# listSignaturesAndHighlightKey 4B78012139378220 +# +# # list all signatures of the given key and highlights it in the output (which especially useful if the key is a subkey +# # and there are other subkeys) but searches the revocation not in the default gpg store but in +# # .gt/remotes/tegonal-scripts/public-keys/gpg +# listSignaturesAndHighlightKey 4B78012139378220 .gt/remotes/tegonal-scripts/public-keys/gpg +# ################################### set -euo pipefail shopt -s inherit_errexit @@ -55,26 +97,26 @@ function trustGpgKey() { } function importGpgKey() { - local gpgDir file withConfirmation + local gpgDir file confirmationQuestion # shellcheck disable=SC2034 # is passed by name to parseFnArgs - local -ra params=(gpgDir file withConfirmation) + local -ra params=(gpgDir file confirmationQuestion) parseFnArgs params "$@" local outputKey outputKey=$( gpg --homedir "$gpgDir" --no-tty --keyid-format LONG \ - --list-options show-user-notations,show-std-notations,show-usage,show-sig-expire \ + --list-options show-sig-expire,show-unusable-subkeys,show-unusable-uids,show-usage,show-user-notations \ --import-options show-only \ --import "$file" ) || die "not able to show the theoretical import of %s, aborting" "$file" - local isTrusting='y' - if [[ $withConfirmation != "--confirm=false" ]]; then + local isTrusting=y + if [[ -n $confirmationQuestion ]]; then echo "===========================================================================" echo "$outputKey" - if askYesOrNo "The above key(s) will be used to verify the files you will pull from this remote, do you trust them?"; then - isTrusting='y' + if askYesOrNo "%s" "$confirmationQuestion"; then + isTrusting=y else - isTrusting='n' + isTrusting=n fi echo "" echo "Decision: $isTrusting" @@ -93,3 +135,123 @@ function importGpgKey() { return 1 fi } + +function getSigningGpgKeyData() { + if (($# == 0)) || (($# > 2)); then + logError "You need to pass at least 1 and at max 2 arguments to getSigningGpgKeyData, given \033[0;36m%s\033[0m\n" "$#" + echo >&2 '1: sigFile the signature file' + echo >&2 "2: gpgDir (optional) the gpg-dir in which we shall search for the key -- default: use gpg's default" + printStackTrace + exit 9 + fi + local sigFile=$1 + local gpgDir=${2:-''} + + local sigPackets keyId + sigPackets=$(gpg --list-packets "$sigFile") || returnDying "could not list-packets for %s" "$sigFile" || return $? + keyId=$(grep -oE "keyid .*" <<<"$sigPackets" | cut -c7-) || returnDying "could not extract keyid from signature packets:\n%s" "$sigPackets" || return $? + + gpg --homedir "$gpgDir" --list-keys \ + --list-options show-sig-expire,show-unusable-subkeys,show-unusable-uids \ + --with-colons "$keyId" | grep -E "^(pub|sub).*$keyId" || returnDying "was not able to extract the key data for %s" "$keyId" || return $? +} + +function getSigCreationDate() { + local sigFile + # shellcheck disable=SC2034 # is passed by name to parseFnArgs + local -ra params=(sigFile) + parseFnArgs params "$@" + shift 1 || traceAndDie "could not shift by 1" + + local sigPackets keyId + sigPackets=$(gpg --list-packets "$sigFile") || returnDying "could not list-packets for %s" "$sigFile" || return $? + grep -oE "sig created [0-9-]+" <<<"$sigPackets" | cut -c13- || returnDying "was not able to extract the signature creation timestamp out of the signature packets:\n%s" "$sigPackets" || return $? +} + +function extractGpgKeyIdFromKeyData() { + local keyData + # shellcheck disable=SC2034 # is passed by name to parseFnArgs + local -ra params=(keyData) + parseFnArgs params "$@" + cut -d ':' -f5 <<<"$keyData" +} + +function extractExpirationTimestampFromKeyData() { + local keyData + # shellcheck disable=SC2034 # is passed by name to parseFnArgs + local -ra params=(keyData) + parseFnArgs params "$@" + cut -d ':' -f7 <<<"$keyData" +} + +function isGpgKeyInKeyDataExpired() { + local keyData + # shellcheck disable=SC2034 # is passed by name to parseFnArgs + local -ra params=(keyData) + parseFnArgs params "$@" + + grep -E '^(sub|pub):e:' <<<"$keyData" >/dev/null +} + +function isGpgKeyInKeyDataRevoked() { + local keyData + # shellcheck disable=SC2034 # is passed by name to parseFnArgs + local -ra params=(keyData) + parseFnArgs params "$@" + + grep -E '^(sub|pub):r:' <<<"$keyData" >/dev/null +} + +function getRevocationData() { + if (($# == 0)) || (($# > 2)); then + logError "You need to pass at least 1 and at max 2 arguments to getRevocationData, given \033[0;36m%s\033[0m\n" "$#" + echo >&2 '1: keyId the gpg keyId for which we shall print the revocation informatoin' + echo >&2 "2: gpgDir (optional) the gpg-dir in which we shall search for the key -- default: use gpg's default" + printStackTrace + exit 9 + fi + local keyId=$1 + local gpgDir=${2:-''} + shift 1 || traceAndDie "could not shift by 1" + + local sigs revData + sigs=$(gpg --homedir "$gpgDir" --list-sigs \ + --list-options show-sig-expire,show-unusable-subkeys,show-unusable-uids \ + --with-colons "$keyId") || returnDying "could not list signatures for key %s" "$keyId" || return $? + revData=$(perl -0777 -ne 'while (/(sub|pub):r:.*?:'"$keyId"':[\S\s]+?(rev:.*)/g) { print "$2\n"; }' <<<"$sigs") + [[ -n $revData ]] || returnDying "was not able to extract the revocation data from the signatures (maybe it was not revoked?):\n%" "$sigs" || return $? + echo "$revData" +} + +function extractCreationTimestampFromRevocationData() { + local revocationData + # shellcheck disable=SC2034 # is passed by name to parseFnArgs + local -ra params=(revocationData) + parseFnArgs params "$@" + cut -d ':' -f6 <<<"$revocationData" +} + +function listSignaturesAndHighlightKey() { + if (($# == 0)) || (($# > 2)); then + logError "You need to pass at least 1 and at max 2 arguments to listSignaturesAndHighlightKey, given \033[0;36m%s\033[0m\n" "$#" + echo >&2 '1: keyId the gpg keyId for which we shall display signatures' + echo >&2 "2: gpgDir (optional) the gpg-dir in which we shall search for the key -- default: use gpg's default" + printStackTrace + exit 9 + fi + local keyId=$1 + local gpgDir=${2:-''} + shift 1 || traceAndDie "could not shift by 1" + + local signatures + signatures=$( + gpg --homedir "$gpgDir" --list-sigs \ + --keyid-format LONG \ + --list-options show-sig-expire,show-unusable-subkeys,show-unusable-uids,show-usage,show-user-notations "$keyId" + ) || returnDying "could not list signatures for key %s" "$keyId" || return $? + + # using variable substitution in combination with ANSI colours does not seem to work properly + # hence we use sed and ignore SC2001 + # shellcheck disable=SC2001 + sed "s/$keyId/\x1b[0;31m&\x1b[0m/g" <<<"$signatures" +} diff --git a/lib/tegonal-scripts/src/utility/io.sh b/lib/tegonal-scripts/src/utility/io.sh index 612c887..d05f552 100644 --- a/lib/tegonal-scripts/src/utility/io.sh +++ b/lib/tegonal-scripts/src/utility/io.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # utility function dealing with Input/Ouput diff --git a/lib/tegonal-scripts/src/utility/log.sh b/lib/tegonal-scripts/src/utility/log.sh index e70124d..fc95842 100644 --- a/lib/tegonal-scripts/src/utility/log.sh +++ b/lib/tegonal-scripts/src/utility/log.sh @@ -7,7 +7,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Utility functions wrapping printf and prefixing the message with a coloured INFO, WARNING or ERROR. diff --git a/lib/tegonal-scripts/src/utility/parse-args.sh b/lib/tegonal-scripts/src/utility/parse-args.sh index 0cbf6f4..cbda5df 100644 --- a/lib/tegonal-scripts/src/utility/parse-args.sh +++ b/lib/tegonal-scripts/src/utility/parse-args.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Intended to parse command line arguments. Provides a simple way to parse named arguments including a documentation @@ -147,7 +147,7 @@ function parseArgumentsInternal { while (($# > 0)); do parseArguments_argName="$1" if [[ $parseArguments_argName == --help ]]; then - parse_args_printHelp parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version" + parse_args_printHelp parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version" 4 if ! ((parseArguments_numOfArgumentsParsed == 0)); then logWarning "there were arguments defined prior to --help, they were all ignored and instead the help is shown" elif (($# > 1)); then @@ -171,10 +171,10 @@ function parseArgumentsInternal { local parseArguments_regex="^($parseArguments_pattern)$" if [[ $parseArguments_argName =~ $parseArguments_regex ]]; then if (($# < 2)); then - logError "no value defined for parameter \033[1;36m%s\033[0m (pattern %s) in %s" "$parseArguments_paramName" "$parseArguments_pattern" "${BASH_SOURCE[1]}" + logError "no value defined for parameter \033[1;36m%s\033[0m (pattern %s) in %s" "$parseArguments_paramName" "$parseArguments_pattern" "${BASH_SOURCE[2]}" echo >&2 "following the help documentation:" echo >&2 "" - parse_args_printHelp >&2 parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version" + parse_args_printHelp >&2 parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version" 4 printStackTrace exit 9 fi @@ -193,7 +193,7 @@ function parseArgumentsInternal { logError "unknown argument \033[1;36m%s\033[0m" "$parseArguments_argName" fi if askYesOrNo "Shall I print the help for you?"; then - parse_args_printHelp >&2 parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version" + parse_args_printHelp >&2 parseArguments_paramArr "$parseArguments_examples" "$parseArguments_version" 4 fi exit 9 fi @@ -202,17 +202,20 @@ function parseArgumentsInternal { } function parse_args_printHelp { - if ! (($# == 3)); then + if ! (($# == 4)); then logError "Three arguments need to be passed to parse_args_printHelp, given \033[0;36m%s\033[0m\nFollowing a description of the parameters:" "$#" - echo >&2 '1: params the name of an array which contains the parameter definitions' - echo >&2 '2: examples a string containing examples (or an empty string)' - echo >&2 '3: version the version which shall be shown if one uses --version' + echo >&2 '1: params the name of an array which contains the parameter definitions' + echo >&2 '2: examples a string containing examples (or an empty string)' + echo >&2 '3: version the version which shall be shown if one uses --version' + echo >&2 '4: stackFrame number of frames to drop to determine the source of the call' printStackTrace exit 9 fi local -rn parse_args_printHelp_paramArr=$1 local -r examples=$2 local -r version=$3 + local -r stackFrame=$4 + shift 4 || traceAndDie "could not shift by 4" parse_args_exitIfParameterDefinitionIsNotTriple parse_args_printHelp_paramArr @@ -244,7 +247,7 @@ function parse_args_printHelp { echo "$examples" fi echo "" - printVersion "$version" 4 + printVersion "$version" "$stackFrame" } function exitIfNotAllArgumentsSet { @@ -287,7 +290,7 @@ function exitIfNotAllArgumentsSet { echo >&2 "" echo >&2 "following the help documentation:" echo >&2 "" - parse_args_printHelp >&2 exitIfNotAllArgumentsSet_paramArr "$exitIfNotAllArgumentsSet_examples" "$exitIfNotAllArgumentsSet_version" + parse_args_printHelp >&2 exitIfNotAllArgumentsSet_paramArr "$exitIfNotAllArgumentsSet_examples" "$exitIfNotAllArgumentsSet_version" 5 if ((${#FUNCNAME[@]} > printStackTraceIfMoreThan)); then printStackTrace fi diff --git a/lib/tegonal-scripts/src/utility/parse-commands.sh b/lib/tegonal-scripts/src/utility/parse-commands.sh index 1f2fffb..99ae297 100644 --- a/lib/tegonal-scripts/src/utility/parse-commands.sh +++ b/lib/tegonal-scripts/src/utility/parse-commands.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Intended to parse command line arguments of a script which uses commands and delegates accordingly. diff --git a/lib/tegonal-scripts/src/utility/parse-fn-args.sh b/lib/tegonal-scripts/src/utility/parse-fn-args.sh index 8e8a920..1fe17ca 100644 --- a/lib/tegonal-scripts/src/utility/parse-fn-args.sh +++ b/lib/tegonal-scripts/src/utility/parse-fn-args.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Intended to parse positional function parameters including assignment and check if there are enough arguments diff --git a/lib/tegonal-scripts/src/utility/parse-utils.sh b/lib/tegonal-scripts/src/utility/parse-utils.sh index a04b699..551382d 100644 --- a/lib/tegonal-scripts/src/utility/parse-utils.sh +++ b/lib/tegonal-scripts/src/utility/parse-utils.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Intended to parse command line arguments. Provides a simple way to parse named arguments including a documentation @@ -65,7 +65,7 @@ function printVersion() { if ! (($# == 1)) && ! (($# == 2)); then logError "One argument needs to be passed to printVersion, given \033[0;36m%s\033[0m\nFollowing a description of the parameters:" "$#" echo >&2 '1: version the version which shall be shown if one uses --version' - echo >&2 '1: stackFrame numberthe version which shall be shown if one uses --version' + echo >&2 '2: stackFrame number of frames to drop to determine the source of the call' printStackTrace exit 9 fi diff --git a/lib/tegonal-scripts/src/utility/recursive-declare-p.sh b/lib/tegonal-scripts/src/utility/recursive-declare-p.sh index 714bf64..60fa426 100644 --- a/lib/tegonal-scripts/src/utility/recursive-declare-p.sh +++ b/lib/tegonal-scripts/src/utility/recursive-declare-p.sh @@ -7,7 +7,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Utility function which returns the `declare` statement of a variable with given name where it recursively calls diff --git a/lib/tegonal-scripts/src/utility/replace-help-snippet.sh b/lib/tegonal-scripts/src/utility/replace-help-snippet.sh index ab06c21..c563272 100644 --- a/lib/tegonal-scripts/src/utility/replace-help-snippet.sh +++ b/lib/tegonal-scripts/src/utility/replace-help-snippet.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Helper script do capture the `--help` output of a script and replace a snippet in HTML based scripts (e.g. in a Markdown script). diff --git a/lib/tegonal-scripts/src/utility/replace-snippet.sh b/lib/tegonal-scripts/src/utility/replace-snippet.sh index dbe3603..9675f42 100644 --- a/lib/tegonal-scripts/src/utility/replace-snippet.sh +++ b/lib/tegonal-scripts/src/utility/replace-snippet.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Helper script do replace a snippet in HTML based files (e.g. in a Markdown file). diff --git a/lib/tegonal-scripts/src/utility/source-once.sh b/lib/tegonal-scripts/src/utility/source-once.sh index fd10b70..b0e59c7 100644 --- a/lib/tegonal-scripts/src/utility/source-once.sh +++ b/lib/tegonal-scripts/src/utility/source-once.sh @@ -7,7 +7,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 ####### Description ############# # # Utility functions wrapping printf and prefixing the message with a coloured INFO, WARNING or ERROR. diff --git a/lib/tegonal-scripts/src/utility/update-bash-docu.sh b/lib/tegonal-scripts/src/utility/update-bash-docu.sh index 6c6474b..f3ee650 100644 --- a/lib/tegonal-scripts/src/utility/update-bash-docu.sh +++ b/lib/tegonal-scripts/src/utility/update-bash-docu.sh @@ -6,7 +6,7 @@ # \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 # /___/ Please report bugs and contribute back your improvements # -# Version: v3.5.0 +# Version: v4.1.0 # ####### Description ############# #