2
0

container-environment-bootstrap.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. #################
  4. # Prerequisites #
  5. #################
  6. for cmd in python3 git wget rsync; do
  7. command -v "$cmd" >/dev/null 2>&1 || {
  8. printf '[%s] Required command %s not found, exiting.\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$cmd" >&2
  9. exit 1
  10. }
  11. done
  12. SEED_DATA_DIR="$SRC/seed_data"
  13. mkdir -p "$SEED_DATA_DIR"
  14. #############
  15. # Functions #
  16. #############
  17. download_and_concatenate_common_dictionaries() {
  18. # Assign the first argument as the target file where all contents will be concatenated
  19. target_file="$1"
  20. # Shift the arguments so the first argument (target_file path) is removed
  21. # and only URLs are left for the loop below.
  22. shift
  23. for url in "$@"; do
  24. wget -qO- "$url" >>"$target_file"
  25. # Ensure there's a newline between each file's content
  26. echo >>"$target_file"
  27. done
  28. }
  29. fetch_seed_data() {
  30. rsync -avc "$SRC/dulwich/fuzzing/dictionaries/" "$SEED_DATA_DIR/"
  31. }
  32. ########################
  33. # Main execution logic #
  34. ########################
  35. fetch_seed_data
  36. download_and_concatenate_common_dictionaries "$SEED_DATA_DIR/__base.dict" \
  37. "https://raw.githubusercontent.com/google/fuzzing/master/dictionaries/utf8.dict" \
  38. "https://raw.githubusercontent.com/google/fuzzing/master/dictionaries/url.dict"
  39. # The OSS-Fuzz base image has outdated dependencies by default so we upgrade them below.
  40. python3 -m pip install --upgrade pip
  41. # Upgrade to the latest versions known to work at the time the below changes were introduced:
  42. python3 -m pip install 'setuptools~=69.0' 'pyinstaller~=6.0'