Foundations / Security governance and compliance
Security governance and compliance cheat sheet
Set up (lesson 0)
| Task | Command or code |
|---|---|
| Make the lab folder | mkdir -p ~/krlab/security-governance |
| Build the lab from the zip, as it stands after a lesson | sh kr-lab.sh <lesson folder> ~/krlab/security-governance |
| Prove that the lab works | python3 labcheck.py |
| End a checker with a count and an exit code | finish(problems) from grc.py |
| The fixed date of every check | TODAY in grc.py (2026-11-21) |
| Read the exit code of the last command | echo "exit code $?" |
Policy set (lesson 1)
| Task | Command or code |
|---|---|
| Check a policy set and its document register | python3 policy_check.py policies |
| What management wants, in a few rules | Policy |
| An exact requirement that can be tested | Standard |
| The steps and who does them | Procedure |
| Advice, not mandatory | Guideline |
| Who runs, who challenges, who audits | The three lines model: first, second, third line |
| Copy a folder, change text in a file | cp -r a b, sed -i 's/old/new/' file |
ISO/IEC 27001 (lesson 2)
| Task | Command or code |
|---|---|
| Check the map from clauses to records | python3 isms_check.py isms_map.csv |
| List the records that are not on file | python3 isms_check.py isms_map.csv . strict |
| Find the theme of an Annex A control number | python3 annex_a.py 8.13 |
| The clauses with requirements | 4 Context, 5 Leadership, 6 Planning, 7 Support, 8 Operation, 9 Performance evaluation, 10 Improvement |
| Annex A of the 2022 edition | 93 controls: 37 organisational, 8 people, 14 physical, 34 technological |
| Guidance for the same controls | ISO/IEC 27002 (nobody is certified against it) |
Scope and assets (lesson 3)
| Task | Command or code |
|---|---|
| Check the inventory against the scope | python3 assets_check.py assets.csv scope.md |
| Sections of a scope statement | Context, Interested parties, In scope, Out of scope (with a reason) |
| Classes of this course | public, internal, confidential, restricted |
| Add a line to a file, drop lines with a word | echo "text" >> file, grep -v word file > copy |
Risk register (lesson 4)
| Task | Command or code |
|---|---|
| Report and check the register | python3 risks.py risks.csv |
| Score | likelihood x impact, each 1 to 5: critical from 15, high from 10, medium from 5 |
| Treatment options | reduce, avoid, transfer, accept |
| Risk appetite of this course | A residual score of 15 or more is not acceptable |
| Change only the lines that start with an id | sed -i '/^R3/s/old/new/' file |
Statement of applicability (lesson 5)
| Task | Command or code |
|---|---|
| Check the statement against the register | python3 soa_check.py soa.csv risks.csv |
| Walk from a risk to its control | grep "R1" soa.csv | cut -d, -f1,4,7,9 |
| A decision for each control | applicable yes or no, a justification, a status, the evidence |
Evidence (lesson 6)
| Task | Command or code |
|---|---|
| Collect the user list and the administrator groups of your machine | python3 evidence.py collect |
| Seal the files of the evidence plan in the manifest | python3 evidence.py seal |
| Verify: exists, unchanged, fresh | python3 evidence.py verify |
| Good evidence says | what, from which system, who, when, complete, unchanged |
| Hash one file | sha256sum file |
Access review (lesson 7)
| Task | Command or code |
|---|---|
| Find orphan, leaver, excess and dormant accounts | python3 access_review.py find . |
| Check that every finding has a valid decision | python3 access_review.py check . |
| Decisions | remove, reduce, keep with a reason, by a person other than the account holder |
Changes and exceptions (lesson 8)
| Task | Command or code |
|---|---|
| Check the change log and the exception register | python3 change_check.py changes.csv exceptions.csv |
| Change types | normal (approved first), standard (pre-approved), emergency (approved within 2 days, reviewed) |
| An exception has | an owner, another person as approver, an end date, a compensating control |
Suppliers (lesson 9)
| Task | Command or code |
|---|---|
| Check supplier records and the responsibility table | python3 supplier_check.py check suppliers.csv responsibility.csv |
| Print the review calendar | python3 supplier_check.py calendar suppliers.csv |
| Clauses of a high supplier | security, breach_notice, audit, subprocessors, data_return, exit |
Backup and restore (lesson 10)
| Task | Command or code |
|---|---|
| Check the business impact analysis | python3 continuity.py bia bia.csv |
| Write checksums of a folder | (cd data && sha256sum *) > backup/SHA256SUMS |
| Pack, list and restore into a fresh folder | tar -czf b.tar.gz data, tar -tzf b.tar.gz, tar -xzf b.tar.gz -C restore |
| Compare the restored files | sha256sum -c SHA256SUMS, diff -rq a b |
| Measure the recovery point | python3 continuity.py measure FOLDER SHA256SUMS BACKUP_TIME FAILURE_TIME |
| Check a restore test record | python3 continuity.py check restore_test.json bia.csv |
| How long a process may be down, how much data may be lost | RTO, RPO |
| Shape of a backup | 3-2-1: 3 copies, 2 kinds of storage, 1 off site |
Internal audit (lesson 11)
| Task | Command or code |
|---|---|
| Run the tests of an audit plan | python3 audit.py audit_plan.csv audit |
| Check findings and corrective actions | python3 findings_check.py findings.csv |
| Grades of this course | major (20% or more of the tested records fail), minor, observation |
| A nonconformity needs | a root cause, a corrective action, an owner, a due date, a follow-up |
Other frameworks (lesson 12)
| Task | Command or code |
|---|---|
| Check a mapping | python3 mapping_check.py mapping.csv soa.csv |
| NIST CSF 2.0 Functions | Govern, Identify, Protect, Detect, Respond, Recover |
| SOC 2 categories | security, availability, processing integrity, confidentiality, privacy |
| Strength of a mapping row | close, partial, loose (with a note) |
| Count the values of a column | tail -n +2 file | cut -d, -f3 | sort | uniq -c |
Metrics (lesson 13)
| Task | Command or code |
|---|---|
Compute the four measures and write report.md | python3 metrics.py . |
| Sort a CSV file by its third field | sort -t, -k3 file |
| A good measure | from a record, both parts shown, a target set before, the worst item named |
Competence and awareness (lesson 14)
| Task | Command or code |
|---|---|
| Check who is trained for what and who has read the policy | python3 competence_check.py competence_needs.csv competence.csv hr.csv policies/index.csv |
| Clauses of ISO/IEC 27001:2022 | 7.2 competence, 7.3 awareness |
| What a competence row needs | a date, evidence, and a second person who checked |
Management review (lesson 15)
| Task | Command or code |
|---|---|
| Check a record of a management review and its actions | python3 review_check.py management_review.json review_actions.csv policies/index.csv |
| Clause of ISO/IEC 27001:2022 | 9.3 management review |
| Inputs of the review in this course | previous actions, metrics, audit, incidents, risks |
Evidence pack (lesson 16)
| Task | Command or code |
|---|---|
After kr-lab.sh, make the files that commands write | python3 evidence.py collect, python3 metrics.py ., python3 evidence.py seal |
| Check the whole pack | python3 check_pack.py [FOLDER] |
| Show only the parts with problems | python3 check_pack.py | grep -v " ok$" |
| Make a clean copy, or a copy with planted faults | python3 drill.py copy, python3 drill.py plant |
Safety habits
| Habit | Why |
|---|---|
| Collect evidence only from systems that are yours to read | A user list is personal data, and another system is not your lab |
| Hand over the whole population, never a sample of your choice | The person who chooses the rows controls the result |
| Never edit evidence, and never seal a changed file again to make a check pass | Find out who changed it, collect it again, and record what happened |
| Break a copy, not the pack | Test a checker on test- files or in drill/ |
| Restore into a fresh folder | The damaged data may hold the only copy of recent work |
| Nobody approves their own work, access, change or exception | Separation of duties |
| Accept a risk with a name and a date | A risk that nobody accepted is ignored, not accepted |
| Give every exception an end date | An exception with no end is a hidden policy |
| Say what a mapping or a certificate does not cover | "Mapped" is not "met", and a certificate has a scope |
| Give every competence record evidence and a second person who checked it | A record that its own subject confirms proves nothing |
| Take the text of a standard or a law from its source | This course describes and does not quote, and it gives no legal advice |