OpenCyber Academy
Rapid course · Lesson 5 · English
Course code: OCA-013Lesson 05: OCA-013-A005

The sharing print is one filter

Open, free learning for anyone who wants to protect people and technology. No account is required to read this text or its worked answers.

Lesson map

Lesson 05. Map, example, EX051.

flowchart TD
  T["Eight triples"] --> F["setting not in the allowed set"]
  T --> N["count of True flags"]
  F --> B["three names, list order"]
  N --> S["sensitive 5"]
  B --> Q{"Is the filter a later census?"}
  S --> Q
  Q -->|No| K["Keep the embedded print"]

One list. One membership test. Three printed numbers.

Logical drawing

items 8, sensitive 5, shared too widely 3
  patient-letters/: anyone-with-link
  invoices/: anyone-with-link
  old-backup.zip: anyone-with-link

Learning outcomes

After this chapter, you should be able to:

  1. Name the three reductions the sharing script actually computes.
  2. Keep list order distinct from the April incident.
  3. Refuse a note that replaces this export with a later folder state.

5.1 Three reductions, and no walk inside a folder.

lab_sharing.py stores eight triples. Each triple is a name, a setting string, and a Boolean. The names are the top-level storage items only. A file inside patient-letters/ is not a fourth field and cannot change len(items).

The Boolean sum is sum(1 for i in items if i[2]). Python counts True as one, so the five sensitive flags print as sensitive 5. That sum does not look at the setting string. referrals/ and booking-app-config contribute to the five and do not contribute to the failure list.

The failure list is a comprehension: keep the pair when the setting is absent from allowed[sens]. allowed[True] holds staff and admins. allowed[False] holds those two strings plus public. The comprehension does not sort. patient-letters/ is printed first because it is the first failing triple, not because a patient mentioned it. rota.xlsx, price-list.pdf, logo.png, referrals/, and booking-app-config are tested and kept out of bad.

A later staff-only change is a decision-log sentence. It is not a fourth run, and it does not edit these eight triples. Printing shared too widely 2 would require deleting a triple this file still contains.

5.2 Worked example

Lesson table; scroll horizontally to read all columns →

Offered result What produced it Decision
items 8, sensitive 5, shared too widely 3 Length, Boolean sum, filter length Keep
The three names in list order The comprehension, unsorted Keep
"The script now omits patient-letters." No edit of the eight triples Refuse
"The filter counted files inside the folders." The list has no child rows Refuse

Synthetic case. The eight triples are the only sharing output.

Errors and limits

Directory children stay uncounted. Do not repair the export so that it matches the afternoon change.

Apply

Worked answers

EX051. No. The eight triples stay. The Boolean sum stays 5. The filter stays 3, in list order: patient-letters, invoices, and old-backup.zip. A later staff-only change and any count of files inside folders stay outside the script.