Skip to content
MetaCyberGuruSecurity, tools and skills Search repositories
Menu

Observe. Explain. Repair.

Developer Lab

Work through engineering failures with explicit expectations. Start with a broken API contract or an overbroad security policy, inspect the evidence and test your repair. The beginner workspaces remain available below.

Make retries safe by contract

Repair a deliberately broken note API. Run the suite, inspect a failed trace, then change the configuration until every expectation passes.

validateBody and authorizeBeforeReplay are booleans. idempotency is off, key-only or fingerprint. maxTitle is 1 to 120; the target contract requires 80.

Run the suite to inspect the deliberately broken starter.

Target behavior and solution

POST /notes accepts exactly one title string with trimmed length 1 to 80 UTF-16 code units. Syntax errors return 400, field errors 422, no identity 401 and insufficient permission 403. A reused key with a changed normalized title returns 409. A successful retry returns the original 201 response and id.

Enable validation, select fingerprint, authorize before replay and retain maxTitle: 80. The suite also proves that failed validation does not reserve a key.

Suite results

Expected: malformed JSON is 400; invalid title is 422; same-key retry creates once; changed title is 409; revoked permission is 403.
The trace shows each request, server status, client-visible status, write count and decision.

Try your own retry sequence

Requests share one temporary session until reset. The first request can commit successfully while its response is lost. Retry with the same key, then change the title or permission.

Request session

No requests in this session.

Take the exercise into a real test runner

Download the dependency-free Node exercise. Extract it, run node --test contract.test.mjs, edit config.json and rerun. The broken starter intentionally fails. Run node exercise.mjs to write result.json. The kit includes request fixtures, exact expectations and the same bounded model used here. Node 20 or later is the exercise target.

This simulator holds at most 100 notes in memory. It models one route, one identity and sequential requests. It is not an OpenAPI validator, database, authentication system or production idempotency implementation. It does not model concurrent writes, key expiration, durable commits, duplicate JSON keys or arbitrary business fields. Production designs need identity-scoped keys, atomic persistence, retention rules and concurrency tests. Fingerprints here cover only the normalized title, not arbitrary JSON.

Read the API contract guide and HTTP idempotency semantics. The 409 and replay rules are this exercise's explicit API contract.

Explain what a policy would allow

Keep the application working while blocking injected scripts and unapproved origins. Inspect each resource decision, then switch to report-only to see why a violation is not a block.

The starter is intentionally overbroad and misses a nonce.

Fixed application scenario

The page origin is https://app.example.test. Permit its scripts, CSS, images and form action, the script origin https://cdn.example.test, the connection origin https://api.example.test, data images and one inline bootstrap with nonce bGVhcm5pbmctZGVtbw==. Block the unapproved origin, inline scripts without a nonce, event handlers, objects and the external base URL.

Reveal one policy that meets the scenario
default-src 'none';
script-src 'self' https://cdn.example.test 'nonce-bGVhcm5pbmctZGVtbw==';
style-src 'self'; img-src 'self' data:;
connect-src https://api.example.test;
object-src 'none'; base-uri 'none'; form-action 'self'

Use enforced mode to meet the blocking expectations. The fixed nonce is teaching data. Real nonce values must be unpredictable and generated fresh per response.

Resource trace and expectations

Analyze the starter policy to see its allow, block and expected results.

Policy review notes

Unsupported syntax produces unknown results, never a successful security verdict.

Modeled subset and deliberate limits

This is a reasoning exercise, not a browser-complete CSP validator or a security certification. It never applies your policy, executes HTML or scripts, fetches resources or sends violation reports. It evaluates only the listed static resources with modern nonce behavior and one policy supplied as an HTTP header. The editor accepts a line break after a semicolon between directives; export produces one header line. Line breaks inside a directive remain unsupported.

Supported directives: default-src, script-src, style-src, img-src, connect-src, object-src, base-uri and form-action. Supported sources: 'self', 'none', 'unsafe-inline', nonce sources, *, https:, data: and lowercase HTTPS origins without a port, path, query or fragment. Empty source lists block that resource type. base-uri and form-action do not inherit default-src.

Hashes, 'strict-dynamic', 'unsafe-eval', script/style element or attribute directives, wildcard subdomains, explicit ports, paths, multiple policies and other directives are unsupported. Unsupported syntax makes all resource verdicts unknown. Redirects, workers, frames, module imports, browser version differences, meta policies, Trusted Types and report delivery are outside the scenario. Even a passing exercise needs real browser testing for your application.

Nonce sources make 'unsafe-inline' ineffective for inline matching in this model, including when the supplied nonce does not match. Nonces do not authorize event-handler attributes. Report-only would observe violations while resources still run; this exercise has no reporting endpoint.

Sources: MDN script-src, MDN report-only, OWASP CSP guidance and W3C CSP specification.

See how HTML and CSS fit together

Change the starter page, then update the preview. Start with a heading, a paragraph and a list. Try the phone-width view before adding more styles.

What this preview supports

Common text, layout, table and form-display elements are rebuilt inside a sandbox. Scripts, event handlers, URL attributes, images, embedded pages and external resources are removed or blocked. Links do not navigate and form controls do not submit. This is a constrained markup exercise, not a full browser IDE or a test of your site’s security.

The combined HTML and CSS limit is 50,000 characters. Learn how to check structure and keyboard behaviour in your first page checklist.

Make JSON readable and find a value

Format a response, remove unnecessary whitespace or select one value with a JSON Pointer. Use /lessons/0/title on the example to read the first lesson’s title.

Output

Know the limits before formatting

Formatting preserves number and string tokens exactly, including large integers and long decimals. Duplicate object keys are rejected, including keys written with equivalent Unicode escapes. This prevents silent value loss. Formatting is not schema validation; the system that later consumes your JSON may still round numbers. The input limit is 200 KB, with at most 100 nesting levels and 20,000 values.

JSON Pointer escapes / as ~1 and ~ as ~0. It does not support JSONPath filters. Read the JSON Pointer specification or practise with the API contract guide.

Practise HTTP responses without a server

This is a local simulation. It uses three sample lessons. No request is sent, no account is created and writes are not saved. Change a request or force a failure to see the response a client might need to handle.

Response

Example client code

A template only. example.invalid is a reserved placeholder; replace it with your own compatible API. This code is displayed, never executed here.

Three experiments to try

  1. Request GET /lessons/99. A missing resource returns 404.
  2. Send POST /lessons with {"title":""}. Valid JSON can still fail field validation with 422.
  3. Create a valid lesson, then list lessons again. The list stays unchanged because this simulator does not persist writes.

The fixture also covers invalid JSON (400), unsupported methods (405) and a list limit from 1 to 3. Real APIs may choose different status codes and require authentication, CORS configuration, timeouts and durable storage. Use the testing guide to turn these cases into checks.

Choose an API with its limits in view

A public endpoint, a free trial and permission for commercial use are different things. These eight services are starting points for small projects, with links to their own documentation. Access conditions checked November 7, 2026; confirm current terms before you integrate.

8 services.

Weather

Open-Meteo

Non-commercial free access; commercial subscription

Useful for a forecast prototype. The free hosted service is restricted to non-commercial use; a commercial or advertising-supported product needs to check the paid service terms. Data attribution and permission to use a hosted endpoint are separate requirements. This directory does not call the API.

Project idea: Sketch a forecast card with saved example data before choosing a service plan.

Official documentation · Access details

Space and public data

NASA APIs

Developer key; endpoint-specific limits

A collection of services rather than one uniform dataset. DEMO_KEY has small shared IP-based limits. Register your own key for a project, read the endpoint documentation and check image credits and usage rights before publishing media. A key does not make every item public domain.

Project idea: Build an astronomy reading list that preserves each item’s source and credit.

Official documentation · Access details

Public data

World Bank Indicators

Public indicators API

Version 2 provides country and indicator data with pagination and JSON responses. Preserve dates, units and source metadata. A missing observation is not zero, and different indicators need not cover the same years. Check the licence attached to the dataset you choose.

Project idea: Compare one indicator across two countries using the same available year.

Official documentation · Access details

Books and search

Open Library

Public read endpoints; low-volume usage policy

Good for book discovery and catalogue experiments. The service asks clients to identify themselves, cache results and respect rate limits. Its APIs are intended for low-volume, human-facing requests. Bulk downloads belong on the documented data-dump route; do not build a high-traffic backend by repeatedly querying the public API.

Project idea: Make a small reading list that handles a missing author or cover gracefully.

Official documentation · Access details

Practice and testing

JSONPlaceholder

Free fake REST API

Suitable for learning request methods and response handling without an account. Create, update and delete operations are simulated: a successful response does not mean a later request will contain your change. Use dummy content and distinguish this behaviour from a persistent application backend.

Project idea: Test loading, success and error states in a small post reader.

Official documentation · Access details

Images and layout

Lorem Picsum

Public placeholder-image endpoints

Width, height, fixed IDs and seeded routes help you test an image layout. A random placeholder can change, so use a stable route when comparing designs. Follow the source-image links and check usage rights before turning a temporary image into published editorial content. Public access is not an uptime guarantee.

Project idea: Test a responsive gallery with consistent image dimensions.

Official documentation · Access details

Security

Have I Been Pwned

Free Pwned Passwords; subscription for authenticated breach searches

The password hash-range service and the email-breach search API have different access requirements. Authenticated breach searches require a subscription key. Password checks use a documented hash-prefix design; never send a plaintext password to an improvised endpoint. This lab does not collect passwords or email addresses.

Project idea: Read the hash-range design and model its response using synthetic data.

Official documentation · Access details

Maps and geocoding

OpenStreetMap Nominatim

Limited public geocoding service

The public server has an application-wide maximum of one request per second, identification and attribution requirements, and restrictions on bulk work and client-side autocomplete. Open map data does not mean unlimited use of a public server. Read the policy before choosing a provider or hosting your own service.

Project idea: Design a manually submitted place search with caching and visible attribution.

Official documentation · Access details

Before choosing a provider, check authentication, quotas, attribution, allowed use, error behaviour and what happens when the service is unavailable. The API terms checklist walks through that decision.

Engineering practice: take the next step

Each path starts with a failure, finishes with evidence and names what a production implementation still needs.

Browser security · CSP

Explain a policy before enforcing it

Compare resource-level decisions, nonce handling and report-only behavior. Turn a passing exercise into a staged browser verification plan.

Build a small project, one skill at a time

You do not need to learn every framework on a roadmap before making something useful. Start with the page, define the data it needs, then test and deploy a small working version.

Your workspace stays in your browser

The lab processes editor input locally. It does not deliberately upload your code or JSON, save it to local storage, run analytics, or call the listed APIs. Normal page requests still reach our server and may be logged. Your browser may restore form values; use sample data rather than passwords, private records or API keys. Following a documentation link opens that provider’s website under its own privacy terms.

Found an incorrect example or outdated API condition? Report it with the workspace name and a non-sensitive example.