Bug reports, ideas and pull requests are welcome. This page explains how to work on the scripts and what every change must respect.
- Setup
- Running the checks
- Secure coding rules
- Rules for each tool
- Pull request checklist
- Reporting bugs and vulnerabilities
You need Git, ShellCheck, bats-core 1.5 or newer, ExifTool, qpdf and mat2. Without mat2, its two tests are skipped.
# Debian/Ubuntu
sudo apt install shellcheck bats libimage-exiftool-perl qpdf mat2shellcheck -x ./*/*.sh life-game/modules/*.sh
shellcheck -s bash tests/*.bats tests/test_helper.bash
bats tests/The scripts must keep working with Bash 4.4, the version of RHEL 8. CI runs the suite with the Bash of Ubuntu; to test another interpreter locally:
BASH_UNDER_TEST=/path/to/bash-4.4 bats tests/- Never use
eval, neversourcedata files and never build commands as strings. Run commands as argument arrays:"$@",git push origin "$branch". - Quote every expansion. Pass file names as arguments, never inside code
given to
bash -c,perl -e,python -corawk; useawk -vfor values. - Validate input before using it: numbers with a regular expression before any arithmetic, URLs and names against an allow-list pattern.
- End option parsing with
--before file names, and prefix relative paths that may start with-with./. - Do not follow symbolic links when modifying files. Let helper programs
write into a private folder made with
mktemp -d, never next to the user's files, and copy the result back into the original file. - Print names that come from files or from the file system through
printable, so control characters cannot reach the terminal. - Ask for confirmation before destructive actions and require
--yeswhen there is no terminal. Offer--dry-run. - Create private files with
umask 077. Never print or log secrets. - Keep
set -euo pipefailand handle the errors you expect explicitly. - Run
awkand other number formatting withLC_ALL=C.
- Metadata Cleaner: workers receive file names as arguments through
xargs -0; never build code from a file name. Helpers write their result into the private folder of the file and onlycopy_backchanges the original. Count a file as cleaned only when its content changed. - Publish Repository: every command that changes the repository or the
remote goes through
runas separate arguments, so--dry-runprints it, shell-quoted, instead of executing it. The secret scan covers staged, modified and new files and stops the script when it cannot run. New secret patterns need a test that builds the fake secret at run time, so the test file never contains one. - Life Game: keep the data file plain text, with its
format=1line. Neversourceorevalit; add new settings to thecaseinload_datawith a validation rule. Validate every number typed by the user withis_uintbefore arithmetic. Interactive helpers must not run inside$(...); they return values throughCHOSEN, so the end of input can stop the game.
- ShellCheck reports nothing.
-
bats tests/passes, also withBASH_UNDER_TESTset to Bash 4.4. - New behaviour and every security check have a test.
- README, help text and CHANGELOG are updated.
Open an issue with the command you ran, the output and your Linux distribution. Report security problems privately as described in SECURITY.md.