Count the pagination gap in your own inventory script
Task
Write an inventory collector that reads one page, measure how wrong it is, then fix it and add the assertion that would have caught it.
Steps
- Write
lab/inventory.pythat fetches a list WITHOUT following continuation tokens and writes the count tolab/inv-page1.txt. - Obtain the true total by another route -- the console, a CLI with automatic paging, a count endpoint -- and record it in
lab/inv-true.txt. - Write
lab/inv-gap.mdstating both numbers and the percentage of the estate the first script would have placed outside every scope derived from it. - Fix pagination, re-run, and confirm the counts match.
- Add an assertion that fails LOUDLY if the count changes by more than a defined proportion between runs, then simulate a drop by limiting the query and confirm the assertion fires.
Verify
cat lab/inv-page1.txt lab/inv-true.txt
grep -Ec '[0-9]+%' lab/inv-gap.md
python lab/inventory.py; echo "fixed exit=$?"
Two different counts recorded, the gap expressed as a percentage, and the assertion observed firing. Pagination failure is the worst possible shape for a control -- confident, wrong and reassuring -- because the report covers what was fetched and says nothing about what was not.
This is an independent study companion for CompTIA SecurityX CAS-005 and is not produced by or endorsed by CompTIA.