| 1 |
#!/bin/cat |
| 2 |
|
| 3 |
#? NAME |
| 4 |
#? usage_examples - examples for advanced usage of o-saft.pl |
| 5 |
#? |
| 6 |
#? DESCRIPTION |
| 7 |
#? This file just contains examples and hints for advanced usage of |
| 8 |
#? o-saft.pl. |
| 9 |
#? |
| 10 |
|
| 11 |
|
| 12 |
############################################################################### |
| 13 |
### |
| 14 |
### Command completion |
| 15 |
### |
| 16 |
|
| 17 |
# Command and parameter completion exists for following shells: |
| 18 |
# |
| 19 |
# shell file to be used |
| 20 |
# -------+------------------------- |
| 21 |
# bash bash_completion_o-saft |
| 22 |
# fish fish_completion_o-saft |
| 23 |
# tcsh tcsh_completion_o-saft |
| 24 |
# -------+------------------------- |
| 25 |
# |
| 26 |
# These files are located in the contrib/ directory. For installing and using |
| 27 |
# them, please see the files itself and the shell's manual pages. |
| 28 |
|
| 29 |
|
| 30 |
############################################################################### |
| 31 |
### |
| 32 |
### Postprocessing output |
| 33 |
### |
| 34 |
|
| 35 |
# All output is designed to be easily parsed by postprocessors. For details |
| 36 |
# please see: |
| 37 |
|
| 38 |
o-saft.pl --help=OUTPUT |
| 39 |
o-saft.pl --help=RESULTS |
| 40 |
|
| 41 |
# For converting (postprocessing) the results to other formats, some filter |
| 42 |
# scripts are provided in the contrib/ directory. The usage i.g. is like: |
| 43 |
# o-saft.pl ... | contrib/filter-script |
| 44 |
# for example: |
| 45 |
|
| 46 |
o-saft.pl +cipher --header --enabled your.tld | contrib/HTML-table.awk |
| 47 |
|
| 48 |
# If you write your own filter script, it's probably best to use o-saft.pl's |
| 49 |
# --legacy=quick option, which separates label and value by a TAB character. |
| 50 |
# However, it should be still possible to parse the default format of the |
| 51 |
# results, which is: |
| 52 |
# Text of label: TABvalue |
| 53 |
# Where the : (colon) terminates the label text, which is followed by spaces |
| 54 |
# to align in columns, followed by a TAB character (aka \t aka 0x09) followed |
| 55 |
# by the value (the result). |
| 56 |
# |
| 57 |
# For practical examples, please see contrib/filter_examples . |
| 58 |
|
| 59 |
|
| 60 |
############################################################################### |
| 61 |
### |
| 62 |
### Postprocessing output with colours |
| 63 |
### |
| 64 |
|
| 65 |
# To colourize the results, the script contrib/bunt.pl (or contrib/bunt.sh) |
| 66 |
# can be used. It generates ANSI codes for the termnal. Example: |
| 67 |
|
| 68 |
o-saft.pl some.tld +check | contrib/bunt.pl |
| 69 |
|
| 70 |
# Sometimes colours need to be adapted, i.e. for red-green visual impairments |
| 71 |
# or when a light background is used. |
| 72 |
|
| 73 |
o-saft.pl some.tld +check | contrib/bunt.pl --blind |
| 74 |
o-saft.pl some.tld +check | contrib/bunt.pl --purple |
| 75 |
|
| 76 |
# If the "aha - Ansi HTML Adapter" (from https://github.com/theZiz/aha) is |
| 77 |
# available, the output can be converted to an HTML page: |
| 78 |
|
| 79 |
o-saft.pl some.tld +check | contrib/bunt.pl | aha -w -b -t "some.tld +check" > some.tld_check.html |
| 80 |
|
| 81 |
# If "ansi2html" is availabe (sometimes in package colorized-logs), output |
| 82 |
# can be converted to an HTML page: |
| 83 |
|
| 84 |
o-saft.pl some.tld +check | contrib/bunt.pl | ansi2html > some.tld_check.html |
| 85 |
|
| 86 |
|
| 87 |
############################################################################### |
| 88 |
### |
| 89 |
### Beautify output |
| 90 |
### |
| 91 |
|
| 92 |
# Replace values yes and no by character symbols. |
| 93 |
|
| 94 |
o-saft.pl some.tld +check | contrib/symbol.pl |
| 95 |
|
| 96 |
# Just print data from certificate |
| 97 |
|
| 98 |
o-saft.pl some.tld +info | contrib/Cert-beautify.pl |
| 99 |
|
| 100 |
|
| 101 |
############################################################################### |
| 102 |
### |
| 103 |
### Generating a list with all possible commands |
| 104 |
### |
| 105 |
|
| 106 |
o-saft.pl --help=cmd |
| 107 |
|
| 108 |
# same, but one command per line: |
| 109 |
|
| 110 |
o-saft.pl --help=cmd --norc | awk 'BEGIN{i=4}{while (i<NF){print $i;i++}}' |
| 111 |
|
| 112 |
# or more lazy: |
| 113 |
|
| 114 |
o-saft.pl --help=cmd | tr ' ' '\012' |
| 115 |
|
| 116 |
# list all commands with brief description |
| 117 |
|
| 118 |
o-saft.pl --help=commands |
| 119 |
|
| 120 |
|
| 121 |
############################################################################### |
| 122 |
### |
| 123 |
### Redefine label texts in output |
| 124 |
### |
| 125 |
|
| 126 |
# generate list with --cfg-data=CMD= options, which can be used to rewite |
| 127 |
# the labels for output (the old way without --help=cfg-data ): |
| 128 |
|
| 129 |
o-saft.pl --help=cmd --norc \ |
| 130 |
| awk 'BEGIN{i=4}{while (i<NF){sub(/+/,"",$i);print "--cfg-data="$i"="i;i++}}' |
| 131 |
|
| 132 |
# To change the label (text) of a command, the option --cfg-data=CMD=TEXT or |
| 133 |
# --cfg-check=CMD=TEXT can be used: |
| 134 |
|
| 135 |
o-saft.pl --help=cfg-data --norc |
| 136 |
o-saft.pl --help=cfg-check --norc |
| 137 |
|
| 138 |
# This will generate one line --cfg-data=COMMAND= foreach command. Simply |
| 139 |
# redirect this to for example ./my-info-labels.txt then add your new texts |
| 140 |
# to each line in that file and use the file like: |
| 141 |
|
| 142 |
o-saft.pl some.tld +info --rc=./my-info-labels.txt |
| 143 |
|
| 144 |
# This feature can be used to translate the labels in other languages. There- |
| 145 |
# for add the modified ./my-info-labels.txt to .o-saft.pl (which will be |
| 146 |
# read automatically by o-saft.pl). |
| 147 |
|
| 148 |
|
| 149 |
############################################################################### |
| 150 |
### |
| 151 |
### Adding additional information (text) to the results |
| 152 |
### |
| 153 |
|
| 154 |
# o-saft.pl writes a "hint" text for each +check and for each +info (data) |
| 155 |
# command. This is initially intended to give additional informations about |
| 156 |
# the performed checks. Each such hint is written in a separate line behind |
| 157 |
# the corresponding info or check line. |
| 158 |
# This feature can also be (mis-)used to add your own description to whatever |
| 159 |
# check you want, simply by using the option --cfg-hint=CMD=TEXT . |
| 160 |
# A template file with all options for all possible commands can be generated |
| 161 |
# as follows: |
| 162 |
|
| 163 |
o-saft.pl --help=cmd --norc \ |
| 164 |
| awk 'BEGIN{i=4}{while (i<NF){sub(/+/,"",$i);print "--cfg-hint="$i"="i;i++}}' |
| 165 |
|
| 166 |
# Then proceed as describe for "Redefine label texts" above. |
| 167 |
|
| 168 |
# Take care that this may overwrite existing hint texts. Existing texts will |
| 169 |
# be shown with: |
| 170 |
|
| 171 |
o-saft.pl --help=cfg-hint --norc |
| 172 |
|
| 173 |
############################################################################### |
| 174 |
### |
| 175 |
### Reading parameters from file or STDIN |
| 176 |
### |
| 177 |
|
| 178 |
# o-saft.pl does not support reading parameters (arguments and options) from |
| 179 |
# STDIN, here-documents or redirected from a file. This behaviour is reserved |
| 180 |
# for future functionality (reading data from STDIN etc.). |
| 181 |
# However, o-saft.pl supports reading parameters from its RC-FILE ,see |
| 182 |
# o-saft.pl --help=CUSTOMIZATION |
| 183 |
# this can be used to tweak reading prepared file. |
| 184 |
# |
| 185 |
# Example: file host-list.txt which contains host:port one per line: |
| 186 |
|
| 187 |
o-saft.pl +cipher `awk -F: '/:/{print "--port="$2" --host="$1}' host-list.txt` |
| 188 |
|
| 189 |
|
| 190 |
|