Every lesson, example, exercise, and answer in roadmap order. Use the contents to jump to a topic, or open any lesson on its own.
Revision 139 lessonsdraft
Developer
Start simple. Build well.
Modules, interfaces, concurrency, Fiber, PostgreSQL, and tests.
CONNECTING THE PIECES8 min read
Modules and a small Go program
Start with explicit dependencies and a reproducible build.
The idea
A Go module gives packages a stable import path and records dependency versions. Keep the booking domain separate from the executable that wires dependencies. Commit go.mod and go.sum. A package name describes a responsibility; it is not a reason to build a deeply nested folder hierarchy.
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
Go
moduleexample.com/booking// cmd/api/main.go composes the application.// internal/booking owns the booking behavior.// go test ./... checks all module packages.
Run tests and builds with a pinned Go toolchain in CI.
Your turn
Where should a PostgreSQL connection be constructed, and which package should own booking invariants?
Reveal a worked answer
Construct the pool in the executable composition root and pass a narrow dependency into the booking operation. Keep booking invariants in the booking package so transport and persistence cannot become their only enforcement points.
Go satisfies interfaces implicitly. The booking operation can define the small persistence behavior it requires, while the PostgreSQL adapter implements it without naming that interface. Compose behavior through fields and methods rather than an inheritance tree.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Small interfaces make dependency direction visible.
Accept interfaces when substitution protects a useful boundary.
Do not introduce an interface for every concrete type automatically.
Your turn
An adapter implements twenty methods but the use case needs one. How large should the consumer interface be?
Reveal a worked answer
Define the one operation the use case consumes. This limits coupling and makes a test fake small. Avoid producing a shared giant repository interface merely because an adapter offers many methods.
A store may return a not-found sentinel, a cancellation error, or an unexpected database failure. Preserve the error chain with wrapping so callers can classify behavior. Translate internal errors at the transport boundary and log a controlled event; do not return SQL or connection details to the browser.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
Go
iferr!=nil {
returnBooking{}, fmt.Errorf("find booking: %w", err)
}
// At the boundary:iferrors.Is(err, ErrNotFound) {
returnfiber.ErrNotFound
}
Decisions that matter
Wrapping preserves a cause while adding operation context.
Use errors.Is and errors.As rather than comparing error strings.
Expected domain errors and infrastructure failures need different handling.
Your turn
A database error includes host information. What should the API return and what should its test assert?
Reveal a worked answer
Return a stable generic server error and a correlation identifier. Assert the public status and response contract, and verify the SQL and connection string are absent. Retain operational detail only in an appropriately protected logging channel.
A context carries cancellation, deadlines, and request-scoped values across API boundaries. Pass it as the first parameter and call the returned cancel function. Fiber has its own request context lifecycle; derive a standard context for database deadlines and do not retain the pooled Fiber context after the handler returns.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Cancellation is cooperative; an operation must observe the context.
A timeout does not prove a database write failed to commit.
Do not use context values as a hidden dependency container.
Your turn
Why is saving *fiber.Ctx in a background goroutine unsafe?
Reveal a worked answer
Fiber reuses request contexts. Read the required values while handling the request, copy data that must outlive it, and use an independently managed standard context for background work. Define who owns shutdown and cancellation.
Starting one goroutine per incoming item can exhaust a service under load. Limit parallel work, give each worker a cancellation path, and define who closes a channel. Communicating ownership often makes races easier to avoid than sharing mutable state guarded by scattered locks.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Concurrency coordinates overlapping work; it does not guarantee CPU parallel speedup.
Bound workers, queues, and downstream connections together.
Run go test -race and include goroutine shutdown cases.
Your turn
A producer blocks sending after all consumers return on cancellation. What must change?
Reveal a worked answer
Every potentially blocking send should select between the channel and ctx.Done, and the producer must stop on cancellation. Give one owner responsibility for closing the channel. Test early cancellation and run the race detector.
Go’s standard HTTP types make request and response semantics explicit. A handler chooses headers before writing a status or body. Learn methods, status codes, routing, cancellation, and body limits even when the deployed app uses Fiber. Standard handlers and Fiber handlers have different context APIs.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Knowing HTTP semantics transfers across frameworks.
Use the framework’s native request APIs deliberately.
Set server timeouts and request-size limits, not just handler logic.
Your turn
What happens if a handler starts writing a successful body before deciding it needs to return 404?
Reveal a worked answer
The initial body write commits the response headers and default status. Resolve errors and choose status before writing the response. Test status, headers, and body together rather than checking only the JSON text.
Fiber provides routing and middleware on fasthttp. Keep handlers small: read and validate input, call the use case, then return a response. Construct shared dependencies once at startup. Compile one binary and let systemd supervise its lifecycle; use graceful shutdown to drain in-flight work.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Use Fiber-native routing and middleware consistently.
Request contexts are pooled and must not escape their lifetime.
Performance decisions need workload measurements, not framework labels alone.
Your turn
Where should the pgx pool live, and should a handler create a pool on every request?
Reveal a worked answer
Create one bounded pool at startup, inject the store into handlers, and close it after the service drains. Creating pools per request multiplies connections and discards reuse. Verify database readiness before declaring the app available.
pgx provides PostgreSQL-native APIs and a connection pool. Parameter binding separates data from SQL syntax. Every booking lookup must also include the authorized tenant: parameterization prevents injection, while a tenant predicate prevents cross-tenant reads. Size the pool for the database’s actual connection budget.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
Go
err:=pool.QueryRow(ctx, `
SELECT id, seats FROM bookings
WHERE tenant_id = $1 AND id = $2`,
tenantID, bookingID,
).Scan(&booking.ID, &booking.Seats)
iferrors.Is(err, pgx.ErrNoRows) {
returnBooking{}, ErrNotFound
}
Decisions that matter
Set deadlines so exhausted pool waits cannot continue indefinitely.
Always close multi-row results and inspect rows.Err.
Use a dedicated migration identity and test least-privilege behavior.
Your turn
Why does parameterized SQL alone fail to prevent a user from requesting another tenant’s booking?
Reveal a worked answer
It protects query syntax, not object authorization. Include a trusted tenant scope in the predicate, then test the same booking ID with a different tenant. Keep the app role unable to change schema or grant permissions.
A table of inputs and expected outcomes is effective for booking validation. Give each case a meaningful name and isolate state between cases. Add PostgreSQL integration tests for SQL and concurrency behavior that a fake cannot represent. Fiber’s app.Test can exercise routes without opening a public listener.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Use focused unit cases for rules and real boundary tests for adapters.
Parallel tests require isolated state and cleanup.
Race tests find data races, not every logical concurrency bug.
Your turn
A test fake saves bookings correctly, but production omits the tenant predicate. Which test boundary is missing?
Reveal a worked answer
Add an integration test against PostgreSQL that queries a known booking through another tenant and receives no result. Keep the unit test for orchestration, but do not treat it as evidence for adapter SQL.
Measure request rate, errors, latency, and database pool pressure. A correlation ID ties a handler to the work it triggers. Use structured logs with stable fields and exclude secrets. On SIGTERM, stop accepting traffic, drain bounded in-flight work, and close dependencies after handlers finish.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
High-cardinality labels can make metrics expensive; do not label every booking ID.
Readiness should reflect required dependencies without exposing internals.
Retain a previous release and verify rollback before depending on it.
Your turn
A release is active in systemd but the domain returns 502. What do you check in order?
Reveal a worked answer
Verify the process and local listener, then local readiness, proxy upstream and route, DNS, and TLS. Use the exact external route in a smoke check. A process manager’s active state does not establish end-to-end availability.
A small team needs independent booking and billing models without operating a fleet of services. Organize modules around business capabilities, expose narrow contracts, and keep tables under module ownership. Enforce references so the billing module cannot reach into booking internals.
Follow the flow
Single deployableBooking module | Billing moduleOwned tables per module
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
C#
publicinterfaceIBookingModule
{
Task<BookingReceipt>ReserveAsync(
ReserveBookingcommand, CancellationTokenct);
}
// Billing consumes the public contract, not booking tables.
Trade-offs
One deployment simplifies releases and local debugging.
Boundaries still need automated dependency checks.
A shared database is compatible with module ownership; cross-module SQL is a policy decision.
When to avoid it
Avoid using folders as evidence of modularity when the team cannot enforce data and dependency boundaries.
Your turn
Draw the allowed dependencies for booking and billing. Where should a shared customer ID live?
Reveal a worked answer
Treat the ID as a value passed across contracts. Keep customer behavior in its owning module; avoid a shared model library that makes every module depend on every change.
A port describes a conversation with the application. An inbound adapter translates HTTP into a reservation command. An outbound port lets the use case save a booking without knowing PostgreSQL. C# commonly wires this through DI; Go commonly wires constructors explicitly. The business use case is the same.
Follow the flow
HTTP adapterReserve use caseBookingStore portPostgreSQL adapter
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Ports should reflect operations the application needs.
A single adapter does not make an interface mandatory.
Keep cancellation and errors meaningful across the boundary.
When to avoid it
Avoid exposing an entire ORM through a port: it leaks infrastructure and defeats the boundary.
Your turn
Replace the PostgreSQL adapter with a fake that records the booking. Which application code needs to change?
Reveal a worked answer
The composition root chooses the fake; the use case remains unchanged. Assert the saved booking and error propagation. Keep an integration test for the real adapter so the fake cannot conceal SQL bugs.
Saving a booking and then publishing to a broker can lose the event if the process crashes between the two operations. Write the booking and an outbox row in one database transaction. A separate dispatcher publishes the row and records delivery. A crash after publish can still cause duplicate delivery.
Follow the flow
One DB transactionBooking + outbox rowDispatcherBroker
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
BEGIN;
INSERT INTO bookings(id, tenant_id) VALUES ($1, $2);
INSERT INTO outbox(id, kind, payload)
VALUES ($3, 'BookingReserved', $4);
COMMIT;
-- A dispatcher later claims and publishes pending rows.
Trade-offs
No distributed transaction is required between DB and broker.
The dispatcher needs locking, retry limits, and lag monitoring.
Retention and deduplication windows must support the replay policy.
When to avoid it
Avoid an outbox when no external effect must be coupled to a local commit.
Your turn
The dispatcher crashes after broker acknowledgement but before marking the row sent. What must the consumer support?
Reveal a worked answer
The row can be published again. Make the consumer idempotent using event IDs and a durable deduplication record committed with its effect. The outbox prevents lost publish intent, not all duplicate deliveries.
A caller retries a booking after losing the response. Accept an idempotency key scoped to the tenant and operation, store a request fingerprint and result, and use a unique constraint to arbitrate concurrent requests. Reusing a key for different input should produce a documented conflict.
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
UNIQUE (tenant_id, operation, idempotency_key)
Key exists + matching fingerprint → replay saved result
Key exists + different fingerprint → conflict
New key → commit effect and saved result together
Trade-offs
Idempotency reduces duplicate effects but requires durable state.
Define key retention and response replay semantics.
Do not put sensitive payloads in plain idempotency keys.
When to avoid it
Avoid claiming a GET-like read cache is sufficient protection for a state-changing operation.
Your turn
Two identical requests with one key arrive simultaneously. Why is an in-memory dictionary insufficient across two app instances?
Reveal a worked answer
Each process has its own dictionary and both can create a booking. Enforce uniqueness and commit the operation record with the business write in PostgreSQL. Test concurrency and recovery after process restart.
The application first checks a cache and loads the authoritative store on a miss. Include tenant and representation version in the cache key. Expire entries and invalidate them after successful writes. A concurrent read can still repopulate stale data, so decide whether bounded staleness is acceptable.
Follow the flow
Cache lookupMiss: database readPopulate with TTLReturn
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Protect against stampedes with bounded coordination and jittered expiry.
A cache outage should have a tested fallback and load budget.
When to avoid it
Avoid caching authorization decisions or capacity invariants without a clear invalidation and consistency model.
Your turn
A cache key uses only the booking ID. What isolation assumption is missing?
Reveal a worked answer
The key does not express tenant scope. Include the authorized tenant and any permission-sensitive representation context. Authorization must still run; a cache hit must not bypass access control.
Microsoft DSC uses configuration documents to describe resource instances and their desired properties. Resource implementations provide the meaning of get, test, and set. Inspect installed resources and use a disposable lab before changing state. Keep credentials out of versioned documents.
Follow the flow
Configuration documentResource discoveryGet current stateTest desired stateSet in lab
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
dsc resource list
dsc config get --file lab.dsc.yaml
dsc config test --file lab.dsc.yaml
# Review the test result before applying:
dsc config set --file lab.dsc.yaml
Decisions that matter
Declarative documents improve repeatability when resource behavior is reliable.
Resource availability differs by environment and installed version.
Application rollback and configuration rollback need separate plans.
Your turn
What must you check before applying a configuration copied from another machine?
Reveal a worked answer
Verify the schema and DSC version, installed resource types and versions, target environment, permissions, and every intended state change. Run get and test in a disposable lab first. A valid document does not imply the changes are safe for a production host.
Get retrieves current resource state. Test compares it with desired state and reports whether it matches. Set enforces the desired state. These are different operations: a successful get does not show compliance, and set can change the machine. Inspect the command output and process exit status according to the installed CLI version.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
dsc config get --file lab.dsc.yaml
dsc config test --file lab.dsc.yaml
dsc config set --file lab.dsc.yaml
dsc config test --file lab.dsc.yaml
Decisions that matter
Get is observation; test is comparison; set may mutate resources.
Inspect per-resource results in addition to command completion.
Run practice configurations only in the intended disposable environment.
Your turn
After set succeeds, why run test again?
Reveal a worked answer
Verify the resulting state rather than assuming execution success equals convergence. Save the before and after evidence, investigate resources that still differ, and confirm any dependent service is actually healthy.
Drift is the difference between desired and observed state. An idempotent resource should converge to the same state when applied repeatedly. A script that restarts a service on every run may reach the desired state while still causing unnecessary disruption. Measure both state and side effects.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Baseline: set → test says in desired state
Repeat: set → no unnecessary change
Introduce drift in the disposable lab
Observe: test detects the mismatch
Repair: set → test confirms convergence
Decisions that matter
A drift report needs a known desired version to be meaningful.
Automatic remediation can repeat a bad configuration; stage and review changes.
Detecting drift and choosing to repair it are separate policy decisions.
Your turn
Design evidence that a resource is idempotent rather than merely successful twice.
Reveal a worked answer
Record resource state, reported changes, and relevant side effects across two applications. The second should not repeat destructive or disruptive work. Introduce controlled drift and confirm one repair followed by a stable repeat.
Build one immutable artifact, run rule and integration tests, scan it, and promote that same artifact through environments. Record the source revision, dependencies, migration version, and configuration contract. Rebuilding separately for production introduces an untested difference.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Source revision
→ tests + dependency checks
→ reproducible build
→ signed or checksummed artifact
→ staging smoke checks
→ production deployment + verification
Decisions that matter
Fast feedback comes from small early checks and meaningful later boundary tests.
A green pipeline proves its checks, not every production assumption.
Deployment identity should have only the permissions needed to deploy.
Your turn
A staging image passed tests, but production rebuilds from a moving branch. What evidence is missing?
Reveal a worked answer
There is no proof production runs the tested artifact. Promote the same digest, record the deployment revision, and verify external behavior. Keep secrets injected at runtime rather than baked into the artifact.
A release checklist should name service ownership, alerts, expected load, backup recovery, and rollback. Run a representative journey through the public domain. Test dependency failure and shutdown behavior in staging. A checklist is useful only when its claims link to observed evidence.
Follow the flow
RequestApplication ruleData or external systemObservable result
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
[ ] Exact artifact revision recorded
[ ] Required dependencies ready
[ ] Public DNS and TLS verified
[ ] Representative read/write smoke checks pass
[ ] Backup restored in a test environment
[ ] Previous release and rollback procedure available
Decisions that matter
Run destructive drills in a controlled environment with an owner.
Define alert thresholds from actual service objectives.
A backup file is not proof of recoverability until a restore works.
Your turn
Choose one failure drill for a booking service and state the expected user and operator experience.
Reveal a worked answer
Temporarily deny database access in staging. Readiness should fail, users should receive a bounded generic error, and operators should see an actionable alert without secret leakage. Restore access and verify recovery without a restart if the pool supports it.
For the booking SaaS, tenant isolation and reservation integrity are assets worth protecting. Map identities, data stores, entry points, and privileged operations. Place enforcement where authority is known and verify the same control through every entry point.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Name a control that belongs in the application even when a reverse proxy exists.
Reveal a worked answer
Resource authorization must remain at the application boundary because the proxy does not own booking data and tenant membership. Test direct application access in a controlled environment as well as the public route.
Draw how the browser, identity provider, API, database, and payment service exchange data. Mark trust boundaries and ask how a caller could spoof identity, tamper with input, disclose another tenant’s data, or exhaust a resource. Rank concrete threats by impact and plausible exposure.
Follow the flow
BrowserTrust boundaryBooking APITenant-scoped store
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Browser → [trust boundary] → Booking API
Booking API → tenant-scoped PostgreSQL
Booking API → payment provider
Threat: valid user requests another tenant's booking
Mitigation: trusted tenant predicate + negative test
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Write one abuse case for a booking export endpoint.
Reveal a worked answer
A legitimate user changes an export identifier to download another tenant’s records. Require resource-level tenant authorization for generation and download, avoid predictable public URLs, and add a regression test for cross-tenant access.
Validate shape and size at input boundaries. Bind SQL parameters rather than concatenating input. Encode untrusted text for its output context. Authorization still has to decide whether the caller may act on a valid identifier; well-formed input is not permission.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
Go
err:=pool.QueryRow(ctx,
"SELECT id FROM bookings WHERE tenant_id=$1 AND id=$2",
tenantID, bookingID,
).Scan(&id)
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Why should a lesson renderer escape code text even though it is presented inside a code element?
Reveal a worked answer
HTML is parsed inside code elements. A literal closing tag or script text could become markup without escaping. Escape source text before adding trusted highlighting spans, and test malicious snippets through the renderer.
The OWASP Top 10 is an awareness document about major web application security risks. Use it to prompt reviews of access control, configuration, injection, dependency integrity, and error handling. It is not an exhaustive test plan or a claim of compliance by itself. Record the edition used in your review.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Review question: can tenant A read tenant B's booking?
Control: authorize every object operation
Test: same booking ID, different authenticated tenant
Evidence: no booking data returned
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Turn one risk category into a concrete booking API verification task.
Reveal a worked answer
For injection, enumerate SQL construction sites, replace concatenation with parameter binding, and test an input containing SQL metacharacters as ordinary data. Verify both result correctness and absence of unintended data access.
ASVS provides verifiable application security requirements. Select requirements for the application’s risk and record their version and identifiers. Link each chosen requirement to a control owner, test, and evidence. An unchecked requirement needs a reason and disposition rather than silently disappearing.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Requirement version + identifier
→ application control
→ automated test or review procedure
→ evidence at a source revision
→ owner and review date
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Why is “we follow ASVS” less useful than a requirement-to-evidence matrix?
Reveal a worked answer
The matrix says which requirements apply, how they are enforced, and what evidence proves them at a specific revision. It exposes exclusions and gaps instead of allowing a general claim to imply complete coverage.
Static application security testing analyzes code or artifacts without exercising a live application. It can detect suspicious data flows and insecure API usage, but it needs context and triage. Add rules and dependency checks to CI, assign an owner, and validate findings with a minimal reproduction.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
A scanner reports a false positive in a tenant-safe query. How should the suppression be recorded?
Reveal a worked answer
Document the code location, rule, analysis of the data flow, evidence, owner, and review condition. Scope the suppression narrowly and reconsider it after changes; do not disable the entire rule to quiet one result.
Dynamic application security testing observes a running target. Use a controlled staging environment with written scope and test accounts for different roles and tenants. DAST can expose runtime configuration and behavior that static analysis misses, while coverage depends on reachable paths and authentication.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Authorized staging target
→ authenticate as test tenant A
→ exercise documented API paths
→ inspect findings
→ verify against negative authorization tests
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Why can an unauthenticated DAST scan miss a cross-tenant booking export flaw?
Reveal a worked answer
It cannot reach the authenticated flow or compare two tenant contexts. Configure scoped accounts and seeded data, then verify authorization with explicit negative cases. A clean scan is limited by the paths and identities exercised.
Authentication establishes who is calling. Authorization checks whether that identity may perform the requested action on this resource. A SaaS API should bind requests to trusted tenant membership and apply object-level checks. Deny by default when permission cannot be established.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Identity valid? → action permitted? → tenant owns resource?
Only then execute the booking operation.
Test anonymous, wrong role, wrong tenant, and valid caller.
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
A user can list their own bookings but download any attachment by ID. What failed?
Reveal a worked answer
The attachment endpoint missed object-level authorization. Apply the same trusted tenant and ownership checks to downloads, exports, and indirect IDs. Add a regression test and review sibling endpoints for the same pattern.
Use maintained platform libraries and approved protocols rather than designing ciphers. Passwords need a dedicated password-hashing scheme with a per-password salt and an appropriate cost. Encryption needs key management, rotation, authenticated integrity, and clear ownership. TLS protects a transport path, not all stored data.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Need confidentiality + integrity? → authenticated encryption
Need password verification? → dedicated password hash
Need random token? → cryptographically secure generator
Keep keys outside source and logs.
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Why is hashing a password once with a fast general-purpose hash inadequate?
Reveal a worked answer
Fast hashes permit attackers to test guesses cheaply. Use the platform identity stack or a maintained password-hashing implementation with tunable cost and salts. Store algorithm and cost metadata so hashes can be upgraded.
A penetration test begins with written authorization, named targets, allowed techniques, time windows, test accounts, data handling rules, and a contact for stopping the test. Reports should connect a reproducible issue to business impact and remediation. Keep exercises inside owned test fixtures and disposable environments.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Scope: staging booking API only
Accounts: tenant-a-reviewer, tenant-b-reviewer
Excluded: payment provider and production identities
Report: steps, affected version, impact, fix, retest result
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
A staging API redirects to a third-party payment page. Is that page automatically in scope?
Reveal a worked answer
No. The third party is a separate target and requires explicit authorization. Stop at the agreed boundary and document the integration assumption. Use provider sandbox fixtures for the defensive exercise.
A useful finding includes an affected asset and version, reproduction evidence, plausible impact, and an owner. Prioritize using exposure, exploitability, business criticality, and existing controls, alongside severity scores. Track accepted risk separately from a verified fix and include a review date.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Detect → validate → prioritize → assign
→ remediate → regression test → rescan/retest
→ verified closure with revision and evidence
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
A critical library advisory affects a package that the running service does not load. Can it be ignored immediately?
Reveal a worked answer
Validate the dependency path and deployed artifact, document exposure and reachability, and still plan an update or an explicit risk disposition. Do not equate a scanner label with complete application context.
A code change is not closure evidence. Reproduce the original flaw against the old fixture, apply the fix, then show the same case fails safely and the authorized use still succeeds. Re-run the relevant scanner or manual procedure and record the tested source and artifact revisions.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Before: tenant B can read tenant A's fixture booking
After: cross-tenant request returns no data
Positive control: tenant A still reads its own booking
Evidence: test IDs + build revision + retest date
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
What should the retest include if the original flaw was in CSV exports?
Reveal a worked answer
Exercise the export creation, status, and download routes, including expired links and another tenant’s identifiers. Check the actual exported bytes for forbidden data. A JSON endpoint test alone cannot verify the CSV fix.
A CVE identifier names a publicly disclosed vulnerability record. A CWE identifier classifies a kind of software weakness. Use CVE for affected product and version tracking, and CWE to group root causes and improve coding practices. Neither identifier alone proves the service is exploitable.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Specific vulnerability: CVE record + affected versions
Weakness category: CWE classification
Local assessment: deployed version + configuration + exposure
Outcome: update, mitigation, or owned risk decision
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
How would you use these identifiers after fixing SQL injection in your own test fixture?
Reveal a worked answer
Classify the root weakness with the appropriate CWE when supported by the analysis. Record affected internal revisions and the regression test. Do not invent a CVE: CVE assignment follows the program’s process.
Common Platform Enumeration describes product naming for inventory and vulnerability matching. Combine product and version identifiers with package lock files, artifact digests, and an inventory of deployed services. A product-name match is a lead that needs version and configuration validation.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Asset: booking-api production
Artifact: immutable digest
Packages: module + locked version
Product identifier: CPE when applicable
Match advisory → verify deployed applicability
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
A vulnerability feed matches a similarly named product. What do you verify before opening an urgent remediation task?
Reveal a worked answer
Confirm vendor, product, edition, affected version range, platform, and whether the vulnerable component is present in the deployed artifact. Preserve the evidence and avoid treating an ambiguous name match as confirmed exposure.
PCI DSS concerns environments that store, process, or transmit payment account data and systems that can affect their security. For the booking capstone, use a payment provider’s test flow and retain a provider reference instead of card data. Determine actual scope and validation obligations with the responsible payment and assessment parties.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Browser → payment provider test flow
Booking API stores: provider reference + booking status
Booking API excludes: raw card number, security code
Verify logs, traces, and error reports also exclude card data.
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Why does using a hosted payment page not justify claiming the whole business is PCI compliant?
Reveal a worked answer
The integration reduces some data handling but scope depends on the actual architecture, controls, and applicable validation. Map flows and responsibilities, verify the provider integration, and have the responsible parties determine requirements. A course exercise is not an assessment.
ISO/IEC 27001 specifies requirements for an information security management system. It connects organizational context, risk assessment, treatment, operation, evaluation, and improvement. Application tests can provide evidence for a control, but a secure endpoint alone does not establish organizational certification.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Information asset → risk assessment → treatment owner
Control evidence → monitoring and review
Incident lesson → corrective action → improvement
Decisions that matter
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
How can the booking team make its tenant-isolation tests useful to an organizational security program?
Reveal a worked answer
Record the protected asset, risk, control owner, test procedure, source revision, result, and review schedule. Link failures to corrective work. Keep the application evidence distinct from the organization-wide management-system requirements.
NIST SSDF organizes secure development practices around preparing the organization, protecting software, producing well-secured software, and responding to vulnerabilities. Map practices to owners and repeatable evidence. Integrate threat review, dependency controls, protected builds, and remediation into ordinary delivery.
Follow the flow
Asset or requirementControlVerificationEvidence + owner
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Choose a control against a concrete risk and document its owner.
Exercise negative cases in authorized test fixtures.
Retain evidence at a specific revision and revisit it when the system changes.
Your turn
Choose one SSDF-aligned practice and name the evidence your capstone can produce.
Reveal a worked answer
For vulnerability response, keep a sample finding with an owner, impact assessment, affected revision, fix, regression test, and verified retest result. For artifact protection, record the exact tested artifact digest and deployment provenance.
Build a tenant-scoped API that creates and reads bookings against PostgreSQL. Choose a modular monolith with an explicit booking application boundary unless a measured need justifies more complexity. Provide C# and Go implementations of the same reserve-and-read use case and document how dependency wiring differs.
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
POST /bookings: validate input, authorize tenant, reserve atomically
GET /bookings/{id}: return only within authorized tenant
GET /healthz: bounded readiness check
Evidence: migrations, test results, architecture decisions
Decisions that matter
Keep the scope small enough that all boundary tests can run.
Use the same API and data contract for the C# and Go comparison.
Record simplifications and remaining risks instead of implying production certification.
Your turn
Submit a release candidate with an architecture decision record, threat model, test report, and operational checklist. Explain one pattern you deliberately avoided.
Reveal a worked answer
A strong submission states the consistency invariant, tenant trust boundary, error contract, migration identity, and recovery path. It demonstrates concurrent final-seat reservations and cross-tenant denial. Avoiding microservices because one team and one deployment meet the need is a defensible decision when supported by the constraints.
Create a test fixture with a booking owned by tenant A and a caller from tenant B. Capture a failing authorization regression against the deliberately vulnerable fixture. Add the tenant predicate and resource check, rerun the reproduction, and preserve the positive authorized case. Connect this evidence to a release revision.
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Focused example
text
Finding: cross-tenant booking access in owned fixture
Before: negative test fails by returning foreign data
Fix: trusted tenant + booking ID query
After: negative and positive controls pass
Close: link source revision, test evidence, and retest result
Decisions that matter
Keep intentionally vulnerable fixtures isolated from the deployed service.
Verification must test the original path, not only nearby code.
A successful retest closes the specified finding, not every security risk.
Your turn
Write a concise remediation report that another reviewer can reproduce without access to production data.
Reveal a worked answer
Include the fixture setup, exact method and route, test identities, observed before and after outcomes, affected and fixed revisions, root cause, regression test IDs, and retest result. Use synthetic records and omit tokens and private data.