Logs, Reports, and Evidence Files

Preserve originals, describe collection, and verify derived results.

A report needs an explicit contract

Record the input source, method, timestamp convention, result status, derived filenames, and limitations.

A nonempty output file does not prove collection completed. The lesson's collector prints partial data and returns 3; the resulting state is incomplete.

Keep data and diagnostics separate before building a presentation.

Timestamps describe a clock observation

timestamp=$(date -u '+%Y-%m-%dT%H:%M:%SZ') || exit 1

UTC Z makes the convention explicit. The lesson saves and checks the actual value's format.

A valid shape does not establish that the clock was synchronized or that a reported event happened at collection time. Fixed fixture timestamps are labeled as synthetic values.

Encode JSON rather than interpolate it

host='east "lab"'
jq -cn --arg host "$host" --argjson count 3 '{host:$host,count:$count}'

Jq handles quotation marks and escaping. Arbitrary string interpolation through printf does not automatically produce valid JSON.

Pass data as data; validate external numeric values before using --argjson.

Delimiter quoting controls shell expansion

label='east host'
cat <<'LITERAL'
label=$label
LITERAL
cat <<EXPANDED
label=$label
EXPANDED

Expected: literal label=$label, then expanded label=east host.

This mechanism does not escape HTML, JSON, or configuration syntax.

Input mechanisms can change bytes

Mechanism Important behavior
Quoted here-document Literal body
Unquoted here-document Shell expansion
<<- Strips leading tabs, not spaces
Here-string Adds a newline
Command substitution Removes trailing newlines

The lesson verifies two bytes for printf of ok without newline and three for a here-string containing ok.

Hash the bytes, check the command

The supplied sha256_value function checks sha256sum on Linux or shasum -a 256 on macOS before extracting the digest.

A copied fixture has the same digest. A modified copy has a different digest. Preserve both the baseline and the comparison result.

A matching hash supports an integrity comparison. It does not identify an author, establish truthful contents, or attribute an incident.

Originals and derivatives have different roles

originals/events.txt  ->  derived/reviewed.txt
        |                        |
   original hash            derived hash
        +---- collection record --+

A restrictive mode reduces accidental edits; owners and privileged processes can still change permissions. Verify the original hash before and after deriving a view.

Make the collection record unambiguous

The lesson uses JSON for filenames, source description, collected_at, method, status, digest, and limitations.

Verify the recorded digest against the current original. Change a copied derivative and demonstrate mismatch without overwriting the original manifest.

Then complete the graded lab on your VM. Institutional evidence procedures remain a separate operational requirement.

Source context: Linuxize here-documents, jq manual, and SHA-2 utility references linked in the lessons. All fixture data and exercises are original.