Compliance Automation and Tooling Questions
Using technology to make compliance continuous rather than point-in-time. Covers GRC platforms and control libraries (build versus buy, one control set mapped to many regulations, requirement-to-evidence traceability, risk roll-ups), compliance-as-code and policy-as-code checks mapped to framework controls (including testing, versioning and retiring the rules, and turning local legal and privacy obligations such as retention and masking into machine-checkable tests), continuous control monitoring and drift alerts, automated evidence collection and tamper-evident evidence pipelines for auditors, automated compliance and privacy reporting with traceable lineage (including regulatory SLA tracking such as DSAR deadlines), and wiring compliance checks into engineering pipelines without slowing teams. Focuses on what to automate first, how to map controls to machine-checkable tests, where to place checks, and the limits of automation. Does not cover designing or testing the controls themselves, the content of individual frameworks, hands-on security mechanics such as secrets, IAM, scanning or logging pipelines, or conducting the audit.
An auditor challenges your team: how can they be sure the automated evidence you hand over was not altered between collection and review? Design the evidence pipeline so integrity and provenance can be verified independently by the auditor, and explain what you would still not be able to prove.
Sample Answer
Direct answer
I would make the evidence tamper-evident and independently verifiable by signing it at the point of collection, chaining every record to the one before, storing it where it cannot be deleted, and giving the auditor the public key and periodic head hashes directly so they can verify without trusting us. Tamper-evident means alteration cannot happen unnoticed, which is weaker than "cannot happen". I would also tell the auditor plainly what this does not prove.
Threat model first
Who could alter evidence: a collector administrator, a storage administrator, a pipeline bug, or the team that owns the failing control. The design must hold even against our own admins.
Two building blocks
A hash (here SHA-256, a standard hash function) is a short fingerprint computed from data: the same data always gives the same fingerprint, and changing one character gives a completely different one, so a fingerprint shows whether data was changed but not who changed it. A digital signature is made with a private key that only the signer holds and checked with the matching public key, which can be shared freely. A valid signature shows the signed data is unchanged since signing and that the signer held the private key. The design below uses hashes to link records and a signature to anchor the chain. The core of the answer is three things: a hash chain, a signature by someone other than the evidence administrators, and a copy of the latest hash held outside our control. The rest (compliance versus governance mode, a timestamp authority, break-glass access) sets how strongly or how long those three hold.
The pipeline
- Collect with a read-only service identity, and record source, time and tool version.
- Hash and chain. Each record's hash covers its own content plus the previous record's hash, so changing one record breaks every later link.
- Sign the chain head (the newest hash, which depends on every record before it) with a private key held in a key management service or HSM (hardware security module, a tamper-resistant key device), controlled by a different team than the evidence administrators.
- Store immutably. S3 Object Lock in compliance mode (a write-once-read-many setting) means a protected object version cannot be overwritten or deleted by any user, including the account root user, until its retention date. Governance mode can be bypassed by someone holding a special permission, so it is weaker.
- Anchor externally. Send head hashes at period close to the auditor, or to an RFC 3161 time-stamping authority (a trusted third party that signs a hash with a time, proving the data existed before that time).
- Give the auditor a verifier and the public key. They run it themselves.
CloudTrail (the AWS activity log) has a built-in example of the same idea, log file integrity validation: SHA-256 hashes for each log file, an hourly digest file referencing them, signed with SHA-256 with RSA (a widely used signature scheme), with each digest containing the previous digest's signature. In plain terms, CloudTrail fingerprints each log file, signs an hourly list of those fingerprints, and links each list to the one before it, which is the chain-plus-signature pattern above.
Runnable demonstration of the chain and the verifier
import hashlib, json
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
def sha256(b): return hashlib.sha256(b).hexdigest()
# --- collector side -------------------------------------------------------
signing_key = Ed25519PrivateKey.generate()
public_key = signing_key.public_key() # given to the auditor out of band
items = [
("2025-03-01T02:00:00Z", "iam-users", {"users_without_mfa": 0}),
("2025-03-02T02:00:00Z", "iam-users", {"users_without_mfa": 1}),
("2025-03-03T02:00:00Z", "iam-users", {"users_without_mfa": 0}),
]
manifest, prev = [], "0" * 64
for ts, check, result in items:
body = json.dumps({"ts": ts, "check": check, "result": result}, sort_keys=True)
entry_hash = sha256((prev + body).encode()) # each entry commits to the one before
manifest.append({"body": body, "prev": prev, "hash": entry_hash})
prev = entry_hash
signature = signing_key.sign(prev.encode()) # signs the head of the chain
# --- auditor side: needs only manifest, signature, public key ------------
def verify(manifest, signature, public_key):
prev = "0" * 64
for i, e in enumerate(manifest):
if e["prev"] != prev or sha256((prev + e["body"]).encode()) != e["hash"]:
return f"FAIL: chain broken at entry {i}"
prev = e["hash"]
try:
public_key.verify(signature, prev.encode())
except Exception:
return "FAIL: head signature invalid"
return f"OK: {len(manifest)} entries, head {prev[:12]}"
print(verify(manifest, signature, public_key))
# tamper with the middle record (the failing MFA check) and re-verify
tampered = json.loads(json.dumps(manifest))
tampered[1]["body"] = tampered[1]["body"].replace('"users_without_mfa": 1', '"users_without_mfa": 0')
print(verify(tampered, signature, public_key))
# attacker also rebuilds every hash after the edit; only the signature stops this
prev = "0" * 64
for e in tampered:
e["prev"] = prev
e["hash"] = sha256((prev + e["body"]).encode())
prev = e["hash"]
print(verify(tampered, signature, public_key))
# deleting the newest entry leaves a valid chain, but the signed head no longer matches
print(verify(manifest[:-1], signature, public_key))
Real output:
OK: 3 entries, head 673b90aca7e9
FAIL: chain broken at entry 1
FAIL: head signature invalid
FAIL: head signature invalid
Plain walkthrough of the demo. Each entry stores the hash of the entry before it, so the three entries form a chain. When the middle record is edited, its recomputed hash no longer equals the stored one, so verification fails at entry 1. To hide that, an attacker must recompute entry 1's hash, which changes what entry 2 must store as its previous hash, which changes entry 2's hash, and so on, so every later hash changes. That is what the third case does. The chain is then consistent again, but its head is a different value from the one the signature was made over, and the attacker does not hold the private key to produce a new signature, so the signature check fails.
The first check verifies. The fourth check, deleting the newest entry, leaves a consistent chain but a different head from the one the signature covers, so it also fails. The demo needs the cryptography package. Ed25519, used in it, is a modern digital-signature algorithm; any standard signature scheme would show the same behavior.
Other sources, retention and access
- Endpoints, containers and network devices: have a local agent or the ingesting collector sign the record with a per-source identity, and produce a signed attestation report (a signed statement of what was collected from which source).
- Retention and disposition: retention is set per evidence class by the longest applicable requirement, with counsel confirming. When evidence is deleted after retention, a deletion record is written into the chain so the absence is explained.
- Access control: auditors get a read-only role, writers cannot delete, admins are separate, and every read is logged.
- Break-glass access: reading is allowed through a named role that opens an incident, expires, and is logged. It does not allow deletion, since compliance-mode retention blocks that regardless.
What I still could not prove
- That the source was true at collection. A compromised source or collector is faithfully signed.
- That nothing was left unrecorded. The chain shows that nothing recorded was changed, not that every check that should have run was recorded. A schedule of expected runs covers this.
- That the check logic is adequate for the control objective.
- The exact time. A timestamp authority proves the hash existed before that time, not that the collector clock was accurate.
- Key honesty. Someone holding the signing key who also controls storage could rebuild and re-sign everything, which is why key custody is separate and head hashes go outside our control early. The demo's signature check protects only while the key is held by someone other than the attacker.
Your company trains and serves ML models on personal data from EU and California customers, and compliance currently depends on engineers remembering the rules. How would you turn the privacy obligations into automated, machine-checkable controls across the ML pipelines, how would you prove to an auditor that they ran, and where would you still need human judgment?
Sample Answer
Direct answer
Turn each obligation into a gate that runs in the pipeline before training and fails closed (no pass, no run), then record every gate result in a tamper-evident evidence log (a log where any later edit can be detected) tied to the dataset and model version. Machines check what is checkable against records of truth (a deletion registry: the list of people whose erasure requests have been processed; a purpose ledger: a record of what each person's consent or contract lets the company use their data for; an approved-sources list: the data sources registered as allowed). People still decide the legal questions: which lawful basis applies, whether a purpose is compatible, whether a DPIA (data protection impact assessment, a structured risk assessment required for high-risk processing) is needed, and what erasure means for an already trained model.
Obligation to check mapping
The regulations named here are the GDPR (the EU General Data Protection Regulation) and the CCPA (the California Consumer Privacy Act). A lawful basis is one of the legal grounds GDPR Article 6 allows for processing personal data, such as consent, a contract, or legitimate interests. Purpose limitation (Article 5) means data collected for one stated purpose may not be reused for an incompatible one. Records of processing (Article 30) are a register of what personal data each system handles and why. Legitimate-interest balancing means weighing the company's interest against the person's rights and freedoms, and it is a judgment call.
| Obligation | Machine-checkable test | Human judgment |
|---|---|---|
| Purpose limitation and lawful basis (GDPR Articles 5 and 6) | Each record's subject has a permitted purpose in the ledger that covers this training purpose | Choosing the basis, deciding if a new purpose is compatible |
| Erasure (GDPR Article 17, CCPA right to delete) | Every subject in the deletion registry is excluded from datasets | Whether an exception applies, and whether to retrain a model |
| Records of processing (GDPR Article 30) | Every data source is registered with purpose and data categories; unregistered sources are blocked | Judging whether the registration is accurate |
| DPIA for high-risk processing (GDPR Article 35) | Pipeline cannot register without a linked DPIA reference | Writing the DPIA, judging residual risk |
| Cross-border transfer | Region tag on each record matches the allowed training region | Choosing the transfer mechanism (counsel) |
The code below implements the first three checks (purpose, erasure, approved source). The DPIA and transfer rows follow the same pattern against other lookup tables. Deadlines also matter for deletion: GDPR requires a response within one month of the request (extendable by two months for complex or numerous requests), and the CCPA gives 45 days (one 45-day extension). The gate checks the registry, so a deletion applies to new training runs from the moment it is recorded.
Worked gate with tamper-evident evidence
The code has two separable parts. The check function and the loop that builds findings are the privacy gate: they compare each record with the lookup tables and produce findings. Everything after the comment # Tamper-evident evidence is the evidence log, which hashes the result so that a later edit is detectable. The gate answers "how is the obligation automated" and the log answers "how is it proven that it ran".
import hashlib, json
# Pinned inputs: what the pipeline is about to train on, plus the sources of truth.
training_manifest = {
"run_id": "train-2026-10-04-01",
"purpose": "fraud_model",
"records": [
{"subject_id": "u1", "region": "EU", "source": "payments"},
{"subject_id": "u2", "region": "EU", "source": "payments"},
{"subject_id": "u3", "region": "CA", "source": "payments"},
{"subject_id": "u4", "region": "EU", "source": "support_chat"},
{"subject_id": "u5", "region": "CA", "source": "payments"},
],
}
# Purposes each subject's lawful basis / notice covers (consent ledger or contract basis).
permitted_purposes = {
"u1": {"fraud_model", "analytics"},
"u2": {"analytics"}, # not covered for fraud_model
"u3": {"fraud_model"},
"u4": {"fraud_model"},
"u5": {"fraud_model"},
}
deletion_requests = {"u3"} # processed erasure requests (EU or CA)
allowed_sources = {"payments"} # support_chat not approved in the records of processing
def check(rec, purpose):
reasons = []
if rec["subject_id"] in deletion_requests:
reasons.append("deleted_subject")
if purpose not in permitted_purposes.get(rec["subject_id"], set()):
reasons.append("purpose_not_permitted")
if rec["source"] not in allowed_sources:
reasons.append("source_not_approved")
return reasons
findings = []
for rec in training_manifest["records"]:
r = check(rec, training_manifest["purpose"])
if r:
findings.append({"subject_id": rec["subject_id"], "reasons": r})
result = "BLOCK" if findings else "PASS"
# Tamper-evident evidence: each entry commits to the previous entry's hash.
chain, prev = [], "0" * 64
entry_body = {
"run_id": training_manifest["run_id"],
"check": "privacy_gate_v1",
"records_checked": len(training_manifest["records"]),
"result": result,
"findings": findings,
}
digest = hashlib.sha256((prev + json.dumps(entry_body, sort_keys=True)).encode()).hexdigest()
chain.append({"prev": prev, "hash": digest, "body": entry_body})
print("result:", result)
print("records checked:", entry_body["records_checked"])
for f in findings:
print("finding:", f["subject_id"], f["reasons"])
print("evidence hash:", digest[:16])
# Verify the chain; then tamper with a finding and verify again.
def verify(c):
p = "0" * 64
for e in c:
if e["prev"] != p:
return False
if hashlib.sha256((p + json.dumps(e["body"], sort_keys=True)).encode()).hexdigest() != e["hash"]:
return False
p = e["hash"]
return True
print("chain valid:", verify(chain))
chain[0]["body"]["findings"] = []
print("chain valid after editing findings:", verify(chain))
result: BLOCK
records checked: 5
finding: u2 ['purpose_not_permitted']
finding: u3 ['deleted_subject']
finding: u4 ['source_not_approved']
evidence hash: 30f1493807c97249
chain valid: True
chain valid after editing findings: False
The run blocks because of three records (u2 not permitted for the fraud model, u3 deleted, u4 from an unapproved source), and the log entry records those findings with a hash that commits to the previous entry. Editing a finding afterwards breaks verification.
Why editing is detectable: a hash is a short fingerprint computed from data, where the same input always gives the same fingerprint and changing one character gives a completely different one. Each log entry's fingerprint is computed from its own content plus the previous entry's fingerprint. Change an old entry and its fingerprint no longer matches the one stored, and every later entry that recorded the old fingerprint stops matching too, so anyone who recomputes the chain sees the break. With one entry, as here, chain valid after editing findings: False shows exactly that: the recomputed hash differs from the stored one.
Proving to an auditor that the gates ran
- Design evidence: the gate code under change control, and the pipeline configuration showing training cannot start without a pass.
- Operating evidence: one log entry per training run. Reconcile the population: list of training runs from the scheduler versus list of gate entries. A run with no entry is a bypass, and it is the first thing an auditor will test.
- Lineage (the traceable path from a model back to the data it was trained on): the manifest hash links dataset version to training run to model artifact, so an auditor can walk from a model back to its gate result.
- Limits of the hash chain: someone with write access could recompute the whole chain. Store entries in write-once storage (storage that refuses edits and deletions until a retention date passes) in a separate account and publish the latest hash to a second system on a schedule.
Ownership
Privacy engineering owns the gate code, privacy counsel and the data protection officer (DPO) own the meaning of the ledger and registry, and each data owner owns the accuracy of their source registrations.
Where automation stops
- The gate is only as true as its ledger. If the consent record is wrong, the gate passes wrongly.
- Consent withdrawn after the check but before training completes: re-run the gate at dataset snapshot time.
- Whether a trained model must be retrained after erasure is unsettled legal and technical ground. I would escalate to the DPO and counsel rather than encode an answer, and engineer for cheap periodic retraining so the question stays affordable.
- Judging whether data is truly anonymous, and legitimate-interest balancing, stay human decisions.
A global enterprise wants one control library that maps to many regulations and frameworks, and regulations keep changing. How would you decide between buying a GRC platform and building your own, how would you structure the crosswalk so one change updates everything affected, and which systems would you integrate first?
Sample Answer
Direct answer
I would buy a GRC platform for the workflow, evidence collection and auditor-facing views, and build a thin layer of my own for what must stay portable: the unified control library and the crosswalk, stored as structured data I own and can export. Buy the commodity, own the model. That avoids a year of building ticket-and-workflow software while avoiding lock-in on the part that encodes the company's own control decisions.
Key terms
- GRC (governance, risk and compliance): software that holds controls, risks, policies, evidence and audit workflows.
- Crosswalk: a mapping that links one control to every framework requirement it satisfies.
- Unified control library: one set of company controls, each with one owner and one test, mapped to many frameworks, instead of separate control sets per framework.
- SOC 2: an auditor's report on whether a company's security controls work, issued under the American Institute of CPAs (AICPA) criteria. ISO 27001: the international standard for running an information security management system. NIST SP 800-53: a US government catalog of security controls, where IA-2(1) is the entry requiring multi-factor authentication (a second proof of identity beyond a password) for privileged accounts.
- Lock-in: being unable to leave a vendor without losing, or having to rebuild, your own data and decisions.
Buy versus build
| Factor | Leans buy | Leans build |
|---|---|---|
| Frameworks | Several common published ones (the SOC 2, ISO 27001 and NIST frameworks above) | Unusual or internal-only |
| Team | Small compliance team, few engineers to spare | Strong platform team, existing data stack |
| Integrations | Vendor has connectors for your systems | Mostly homegrown systems |
| Time to first audit | Soon | Flexible |
| Cost | License plus administration | Engineers plus maintenance forever |
| Lock-in | Can export controls and mappings | Full control |
Illustrative cost, same annual basis: buy is a 120k license plus half an administrator at 150k loaded (salary plus benefits and overhead), which is 75k, 195k per year; build is 1.5 engineers at 150k, 225k per year, before the cost of maintenance and not shipping product work. The numbers are invented for the comparison; the point is that costs are close, so capability and time decide. I would flip to build if the estate is mostly custom systems the vendor cannot connect to, or no vendor can model the company's frameworks.
Crosswalk structure so one change updates everything
Keep four linked layers, each versioned:
- Framework requirement: framework, version, clause id, text.
- Mapping (many to many: one requirement can map to several controls, and one control to several requirements): requirement to unified control, with strength (full or partial), reviewer and date.
- Unified control: statement, owner, test, systems in scope.
- Test and evidence: result, timestamp, artifact.
Filled in for one control (illustrative values), the four layers look like this:
| Layer | Row |
|---|---|
| Requirement | NIST SP 800-53 r5, IA-2(1), "multi-factor authentication for access to privileged accounts" |
| Requirement | ISO/IEC 27001:2022, Annex A 8.5, secure authentication |
| Requirement | SOC 2, CC6.1, logical access security |
| Mapping | IA-2(1) to CTL-MFA-ADMIN, full, reviewer j.doe, 2026-09-12 |
| Mapping | A.8.5 to CTL-MFA-ADMIN, full, reviewer j.doe, 2026-09-12 |
| Mapping | CC6.1 to CTL-MFA-ADMIN, partial (CC6.1 also needs other controls), reviewer j.doe, 2026-09-12 |
| Control | CTL-MFA-ADMIN, "All administrator accounts require MFA", owner iam-team, test admin_mfa_enforced, systems idp-prod |
| Test and evidence | 2026-10-03, pass, 0 of 41 admins without MFA, artifact a1f09c |
If a framework later renumbers A.8.5, only that requirement row and its mapping row change. The control, its test and the evidence history stay untouched.
Because requirements point at controls rather than at each other, changing one control's test updates every framework it supports. A new framework revision adds new requirement rows, and the diff immediately lists controls with unmapped new requirements. Where available, export in an open format; NIST's OSCAL (Open Security Controls Assessment Language) offers machine-readable catalogs, baselines and assessment data in XML, JSON and YAML.
Using automation to suggest mappings
A language model or text-similarity tool can propose candidate mappings. Store them as suggested, never approved. A person reviews each one; ambiguous requirements are marked partial and escalated to the control owner, counsel or the auditor, who decides what counts. Track the acceptance rate (the share of suggested mappings that reviewers approve), since a low rate means the suggestions are noise.
Which systems to integrate first
- Identity provider: access, MFA and joiner-leaver evidence supports many controls.
- Cloud account and asset inventory: defines scope and supplies configuration checks.
- Ticketing and change management: remediation and approval evidence.
- SIEM (security event log platform): logging and detection evidence, after the basics.
The reason is coverage per integration: identity and inventory feed the most controls for the least effort.
Worked example
Unified control "admins use multi-factor authentication" maps to NIST SP 800-53 IA-2(1) and to the matching SOC 2 (CC6.1) and ISO 27001 (Annex A 8.5) requirements, as the three mapping rows above show. One check against the identity provider updates all three.
Pitfall
Starting with per-framework control lists inside the tool, which recreates the duplication the unified library exists to remove.
Your company runs separate risk registers per product line and region, so leadership cannot see aggregate risk or compliance posture. How would you design the data model and ingestion for a GRC platform that rolls these up automatically, how would you keep scoring consistent across teams, and which executive views would you build from it?
Sample Answer
Direct answer
Build one canonical model (business unit, risk, control, link between them) with a single taxonomy (one shared list of risk categories) and a single anchored scoring rubric (a scoring guide that ties each level from 1 to 5 to concrete descriptions, so two people land on the same number), and ingest each local register through a mapping layer that normalizes into it. Roll up with worst-case and counts, never averages: nine risks scored 2 and one scored 15 average 3.3, which looks harmless, while the worst case (15) and the count of high risks (1) show the problem. Put three executive views on top. The hard part is not the tables. It is getting teams to score the same way and keeping the data fresh.
Data model (core record fields)
- business_unit: product line and region.
- risk: taxonomy category, owner, status (open, treating, accepted, closed), inherent likelihood and impact, residual likelihood and impact (inherent is before controls, residual after), last reviewed date, source system and source id.
- control and a risk_control link: last test result and date.
- history: a snapshot taken daily so trends exist.
Ingestion
- Extract from each register (spreadsheet, ticket tool, an existing GRC tool) on a schedule or via API.
- Map local categories to the shared taxonomy through a mapping table owned by risk management. An unmapped category is quarantined (held in a review queue) with an alert, not dropped.
- Validate: scores 1 to 5, owner present, review date present. Rejects go back to the register owner.
- Upsert (insert a new row, or update it if it already exists) keyed by source system plus source id, so reruns do not duplicate rows.
- Link duplicates: one vendor risk appearing in three products should point to a parent risk so the roll-up does not triple count it.
Consistent scoring
Use one 5x5 grid where score = likelihood x impact and high means 15 or above. Anchor each level with descriptors (for impact, ranges of financial loss, records exposed or downtime that leadership approved), run calibration sessions (meetings where teams score the same sample risks, compare, and discuss each difference until they converge), and have risk management re-score a small random sample each quarter. Show both the team's score and the re-scored one, so disagreement is visible rather than argued over. Roll-up uses ordinal scores (numbers that only rank risks, where the gaps between levels are not equal amounts), so do not sum them (ten minor risks scoring 2 each sum to 20, which would wrongly outrank one severe risk scoring 15), and do not mix them with quantified loss estimates from units that use FAIR (a method that estimates loss in money).
Worked roll-up
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("""
CREATE TABLE business_unit (id TEXT PRIMARY KEY, product_line TEXT, region TEXT);
CREATE TABLE risk (
id TEXT PRIMARY KEY, unit_id TEXT REFERENCES business_unit(id),
category TEXT, -- from the shared taxonomy
owner TEXT, status TEXT, -- open / treating / accepted / closed
likelihood INTEGER CHECK (likelihood BETWEEN 1 AND 5),
impact INTEGER CHECK (impact BETWEEN 1 AND 5),
residual_likelihood INTEGER CHECK (residual_likelihood BETWEEN 1 AND 5),
residual_impact INTEGER CHECK (residual_impact BETWEEN 1 AND 5),
last_reviewed TEXT
);
CREATE TABLE control (id TEXT PRIMARY KEY, last_test_result TEXT); -- pass / fail
CREATE TABLE risk_control (risk_id TEXT, control_id TEXT);
""")
db.executemany("INSERT INTO business_unit VALUES (?,?,?)", [
("BU1", "payments", "EU"), ("BU2", "payments", "US"), ("BU3", "lending", "EU")])
db.executemany("INSERT INTO risk VALUES (?,?,?,?,?,?,?,?,?,?)", [
("R1", "BU1", "third_party", "ana", "open", 4, 5, 3, 5, "2026-09-20"),
("R2", "BU2", "third_party", "bo", "treating", 3, 4, 2, 4, "2026-06-01"),
("R3", "BU3", "data_privacy", "cy", "open", 5, 3, 3, 3, "2026-09-28"),
("R4", "BU1", "access", "ana", "accepted", 2, 5, 2, 5, "2026-09-01"),
])
db.executemany("INSERT INTO control VALUES (?,?)", [("C1","pass"),("C2","fail")])
db.executemany("INSERT INTO risk_control VALUES (?,?)", [("R1","C1"),("R2","C2"),("R3","C1")])
print("Residual score = residual_likelihood x residual_impact; HIGH means score >= 15")
q = """
SELECT b.product_line, b.region, r.category,
COUNT(*) AS risks,
MAX(r.residual_likelihood * r.residual_impact) AS worst_residual,
SUM(r.residual_likelihood * r.residual_impact >= 15) AS high_count,
SUM(julianday('2026-10-04') - julianday(r.last_reviewed) > 90) AS stale_reviews
FROM risk r JOIN business_unit b ON b.id = r.unit_id
WHERE r.status <> 'closed'
GROUP BY b.product_line, b.region, r.category
ORDER BY worst_residual DESC, b.product_line, b.region
"""
for row in db.execute(q):
print(row)
print("Open risks with no linked control, or only failing controls:")
q2 = """
SELECT r.id, r.status FROM risk r
WHERE r.status <> 'closed' AND NOT EXISTS (
SELECT 1 FROM risk_control rc JOIN control c ON c.id = rc.control_id
WHERE rc.risk_id = r.id AND c.last_test_result = 'pass')
ORDER BY r.id
"""
for row in db.execute(q2):
print(row)
Residual score = residual_likelihood x residual_impact; HIGH means score >= 15
('payments', 'EU', 'third_party', 1, 15, 1, 0)
('payments', 'EU', 'access', 1, 10, 0, 0)
('lending', 'EU', 'data_privacy', 1, 9, 0, 0)
('payments', 'US', 'third_party', 1, 8, 0, 1)
Open risks with no linked control, or only failing controls:
('R2', 'treating')
('R4', 'accepted')
How the SQL works: the comparison inside SUM(...) is true (counted as 1) or false (counted as 0) for each row, so summing it counts how many rows meet the condition, here scores of 15 or more or reviews older than 90 days. julianday turns a date into a day number so that subtracting two dates gives the number of days between them. GROUP BY produces one output row per product line, region and category, with MAX giving the worst score in each group. The second query lists open risks for which no linked control has a passing test.
Reading the output: payments in the EU has one high residual risk (R1 scores 3 x 5 = 15, inherent 4 x 5 = 20). R2 is the only stale one: reviewed on 2026-06-01, 125 days before 2026-10-04, against a 90-day rule. R2 and R4 have no passing control: R2's only control failed its test, and R4 is accepted with no control, so its acceptance record is what the platform should surface.
Executive views
- Residual heat map (a grid colored by likelihood and impact) by product line and region, showing count of high risks and the worst score (not the mean).
- Top risks above appetite (risk appetite is the level of risk leadership agrees to accept; here, a residual score of 15 or more is above it), with owner, age, treatment status and next date.
- Control health and data quality: failed controls, risks with no passing control, share of risks with an owner, share reviewed in the last 90 days.
Limits
A rolled-up number is only as honest as its inputs. A register with stale reviews will look calm, which is why staleness is a first-class metric. Automatic aggregation cannot tell whether a team under-scored, which is what calibration is for.
The monthly compliance report is assembled by hand from several systems and is always late and occasionally wrong. How would you automate it end to end, what would you build in so a bad upstream feed does not silently produce a confident-looking report, and who would you let see and edit it?
Sample Answer
Direct answer
Replace the hand assembly with a scheduled pipeline that pulls each source through a data contract (a written agreement between the team that owns a feed and the team that consumes it: which fields, what format, how fresh, delivered when), runs data-quality gates, computes metrics from versioned definitions and publishes a dated report. The key design choice is that the pipeline fails closed, meaning that when it cannot be sure the data is good it refuses to present a final result instead of carrying on: when a feed is stale, empty or malformed, the report is marked incomplete and says why, rather than printing a tidy number built on bad data.
Step 1: Inventory the manual process
List every source system, who exports it, which spreadsheet formulas touch it and which numbers have been wrong before. Those past errors become the first automated tests.
Step 2: Build the pipeline
- Ingest from each system by API or scheduled export into a staging area, keeping the raw copy untouched.
- Validate each feed before use (see the next section).
- Transform with metric definitions in version control, each with an owner and a written definition.
- Publish a dated report plus a manifest (inputs used, row counts, definition versions, run time), on a schedule a day or two before the deadline so a failure can be fixed before it is late.
Step 3: Guards so a bad feed cannot hide
| Guard | What it catches |
|---|---|
| Freshness check | Feed last updated before the expected window |
| Volume check | Row count far from the recent norm (a feed that normally has 1,200 rows and arrives with 0 trips a 50% floor of 600 rows) |
| Schema check | Renamed or missing columns, changed types |
| Reconciliation | Total in the report disagrees with an independent control total (a headline figure the source system reports on its own, such as "1,213 active employees", which the report's own count must also match) |
| Per-section status | Each section shows complete, partial or missing, so one bad feed taints only its own section |
If any blocking guard fails, the report is stamped DRAFT: INCOMPLETE with the failing feed named, the owner is alerted, and nobody can publish it as final without a recorded override. The override requires a reason and a named approver.
Step 4: Who sees and edits
- View: audience-based roles (compliance team, executives, auditors), read-only. Sensitive detail (individual names, incident narratives) is restricted to people who need it.
- Edit: nobody edits the output. People change inputs at the source or change definitions through a reviewed change. The only manual path is a logged override with a reason.
- Approve: the report owner signs off on each period; that approval is stored with the manifest.
Worked example
Six feeds feed the monthly report. On the 3rd, the HR export arrives with 0 rows. The volume check (floor 600, because the usual is 1,200) fails. The old process would have shown "0 leavers without access revoked", which looks excellent and is wrong. The new pipeline marks the joiner-mover-leaver section (the part covering people who join the company, change roles or leave, and whether their access was granted, changed or removed on time) missing, sends the HR-data owner an alert, and the report goes out on schedule, stamped DRAFT: INCOMPLETE, with five sections complete and one flagged missing; it can be released as final only through the recorded override.
Trade-offs and pitfalls
- Over-tight thresholds create alert fatigue (so many alerts that people stop reading them); seed them from recent history and review them quarterly.
- Automation cannot tell that a definition is wrong, only that it is applied consistently. Keep a human review of definition changes.
- Keep the old manual report in parallel for one or two cycles and diff them, which finds the hand-assembly errors.
Unlock Full Question Bank
Get access to all 10 Compliance Automation and Tooling interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.