mirror of
https://github.com/drwetter/testssl.sh.git
synced 2024-11-22 11:01:36 +01:00
Updated Coding Style (markdown)
parent
a91cc8c8fd
commit
6f7d756e9c
@ -4,44 +4,54 @@
|
|||||||
|
|
||||||
* PR *
|
* PR *
|
||||||
* you make the life of the maintainer easier if it's only **one** patch w/ **one** functional change per PR
|
* you make the life of the maintainer easier if it's only **one** patch w/ **one** functional change per PR
|
||||||
|
* document your PR -- in the comment field and also comment your code. We need to maintain this
|
||||||
|
|
||||||
* Global variables
|
* Global variables
|
||||||
* use them only when necessary
|
* use them only when necessary
|
||||||
* in CAPS
|
* Please you CAPS
|
||||||
* initialize them
|
* initialize them
|
||||||
* use ``readonly`` and variable types
|
* make use ``readonly`` if possible and indicate variable types (-i stands e.g. for integer)
|
||||||
* if it's going to be a cmd line switch, there has to be also a global ENV variable which can be used without the switch (see e.g. SNEAKY or SSL_NATIVE)
|
* if it's going to be a cmd line switch, there has to be also a global ENV variable which can be used without the switch (see e.g. SNEAKY or SSL_NATIVE)
|
||||||
|
|
||||||
* local variables (all_lower_case)
|
* local variables (lower case!)
|
||||||
* declare them before usage
|
* declare them before usage
|
||||||
* if unclear initialize them
|
* if unclear initialize them
|
||||||
|
* indicate variable types (-i stands e.g. for integer)
|
||||||
|
|
||||||
* use "speaking variables" but don't overdo it with the length
|
* use "speaking variables" and method names but don't overdo it with the length
|
||||||
|
|
||||||
* test before doing a PR! If it's a check best you check with two bad and two good examples which should work as expected (compare results e.g. with SSLlabs)
|
* do testing before doing a PR!
|
||||||
|
* Check all changes you did in different scenarios
|
||||||
|
* if it's an additional check confirm that it works with two bad and two good examples (maybe compare results e.g. with SSLlabs)
|
||||||
|
* write a unit test (see directory ~/t/ for examples)
|
||||||
|
|
||||||
* don't use backticks anymore, use ``$(..)`` instead
|
* don't use backticks anymore, use ``$(..)`` instead
|
||||||
* use double square instead of single square brackets
|
* use ``[[`` instead of ``[`
|
||||||
|
* the right hand side within ``[[ ]]`` only needed to be quoted if there's a reason
|
||||||
* mind: http://mywiki.wooledge.org/BashPitfalls
|
* mind: http://mywiki.wooledge.org/BashPitfalls
|
||||||
|
|
||||||
* use [shellcheck](https://github.com/koalaman/shellcheck) if possible
|
* use [shellcheck](https://github.com/koalaman/shellcheck) if possible
|
||||||
|
|
||||||
* don't use additional binaries
|
* don't use additional binaries: testssl.sh runs on more than just your platform
|
||||||
* if you really, really need to use an additional one make sure it's available on the system before calling it
|
* if you really, really need to use an additional binary
|
||||||
* don't use highly system depended binaries (rpm, ipconfig, ..) as it is not portable or requires lot's of efforts to be portable and the code gets ugly.
|
* first clarify with us
|
||||||
|
* make sure in the code it's available on the system before calling it
|
||||||
|
* never use highly system depended binaries (rpm, ipconfig, ..) as it is not portable or requires lot's of efforts to be portable and the code gets ugly.
|
||||||
|
|
||||||
|
* Don't use internal checks for features by determining the OS. Rather check whether the binary supports what you are looking for and set global vars (see HAS_* variable).
|
||||||
|
|
||||||
* If it's an openssl feature you want to use and it could be not available for older openssl versions testssl.sh needs to find out whether openssl has that feature. Best do this with openssl itself and not by checking the version as some vendors do backports. See the examples for HAS_SSL2 or proxy option check of openssl in check_proxy().
|
* If it's an openssl feature you want to use and it could be not available for older openssl versions testssl.sh needs to find out whether openssl has that feature. Best do this with openssl itself and not by checking the version as some vendors do backports. See the examples for HAS_SSL2 or proxy option check of openssl in check_proxy().
|
||||||
|
|
||||||
* If a feature of openssl is not available you need to tell this by using pr_warning*() -- or accordingly with fatal() if a continuation of the program doesn't make sense anymore.
|
* If a feature of openssl is not available you need to tell this by using pr_warning*() -- or accordingly with fatal() if a continuation of the program doesn't make sense anymore.
|
||||||
|
|
||||||
* every operation (string, etc.) which works with bash internal functions: use them whenever possible (replacing tr/sed/awk), see e.g. http://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html
|
* every operation (string, etc.) which works with bash internal functions: use them whenever possible (replacing tr/sed/awk), see e.g. http://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html
|
||||||
* avoid a mix of several external binaries e.g. (sed and grep and tr) if you can achieve the same with e.g. awk.
|
* avoid a mix of several external binaries e.g. (sed and grep and tr) if you can achieve the same with a single binary e.g. awk.
|
||||||
* be careful with very advanced bash features. Mac OS X is still using bash version 3 ([http://tldp.org/LDP/abs/html/bashver4.html](differences))
|
* be careful with very advanced bash features. Mac OS X is still using bash version 3 ([http://tldp.org/LDP/abs/html/bashver4.html](differences))
|
||||||
* especially with ``sed`` you need to be careful as GNU sed is only 80% compatible with BSD sed (`sed -i`,` \n`, `\t`, etc.).
|
* especially with ``sed`` you need to be careful as GNU sed is only 80% compatible with BSD sed (`sed -i`,` \n`, `\t`, etc.).
|
||||||
|
|
||||||
* always use a return value for a function/method
|
* always use a return value for a function/method
|
||||||
|
|
||||||
* make use the short functions / methods (code starts from ``###### helper function definitions``) like
|
* make use of the short functions / methods (code starts from ``###### helper function definitions``) like
|
||||||
* count_words() / count_lines() / count_ciphers()
|
* count_words() / count_lines() / count_ciphers()
|
||||||
* strip_lf() / strip_spaces()
|
* strip_lf() / strip_spaces()
|
||||||
* toupper()
|
* toupper()
|
||||||
|
Loading…
Reference in New Issue
Block a user