#!/usr/bin/env bash # JSON for the CI steps, without third-party programs (no jq, no Node; decision of Alberto of 18 November 2026): # reads with json.awk and json-campi.awk, writes strings with json-stringa.awk. POSIX awk, no network. # # json.sh campi ... for each object at that place, one line with the fields # separated by a TAB (json-campi.awk): empty path for # the root object, «*» for every element of a list, # for example «Results/*/Vulnerabilities/*» # json.sh stringa the text as a JSON string, quotes included # # A file that is not valid JSON: no output, the reason on stderr, exit status 2. PipelineTests tests it. set -euo pipefail qui="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export LC_ALL=C uso() { echo "Uso: json.sh campi ... | stringa " >&2 exit 2 } modo="${1:-}" (($# > 0)) && shift case "$modo" in campi) (($# >= 3)) || uso percorso="$1" campi="$2" shift 2 nome='[A-Za-z_][A-Za-z0-9_.-]*' passo='([A-Za-z0-9_.-]+|[*])' [[ "$campi" =~ ^$nome(,$nome)*$ ]] || uso [[ -z "$percorso" || "$percorso" =~ ^$passo(/$passo)*$ ]] || uso for file in "$@"; do [[ -f "$file" ]] || { echo "json.sh: manca il file $file" >&2; exit 2; } done exec awk -v percorso="$percorso" -v campi="$campi" -f "$qui/json.awk" -f "$qui/json-campi.awk" "$@" ;; stringa) (($# == 1)) || uso printf '%s' "$1" | awk -f "$qui/json-stringa.awk" ;; *) uso ;; esac