Nobody has started this yet — be first.
Business impact
This project's whole privacy story for click analytics is: we hash IPs, we don't store them raw, salted with the app's secret so the hash can't be reverse-engineered against a rainbow table of common IPs. Right now that story is false. Anyone who can read ClickEvent.ip_hash values (a DB backup, a support engineer, an attacker with read access) can precompute sha256(ip) for every IPv4 address in a target's ISP range -- a fully tractable offline table -- and de-anonymize every click in the table, across every deployment of this app, since the hash never depends on which app/secret produced it.
Problem
hash_ip(ip_address, salt) accepts salt as a parameter but never uses it -- the function computes hashlib.sha256(ip_address.encode("utf-8")).hexdigest() and ignores salt entirely.
Current behavior
hash_ip(ip, salt="secret-A") and hash_ip(ip, salt="secret-B") for the same ip produce the identical digest.
Expected behavior
The same IP hashed with two different salts produces two different digests. _record_click already passes current_app.config["SECRET_KEY"] as the salt -- hash_ip needs to actually mix it into the hash.
Steps to reproduce
Why this matters
A keyless hash of a small-entropy input (IPv4 space is ~4.3 billion values, and real traffic clusters into much smaller known ranges) is reversible by brute force in seconds. The entire point of keying/salting a hash with a per-deployment secret is that the attacker now needs the secret too -- without it, "hashed" buys nothing beyond casual obfuscation. This is a one-line fix but exactly the kind of one-line mistake that silently defeats an entire security control.
Suggested approach
Look at how salt is currently threaded into the hash computation (it is not). Combine salt and ip_address before hashing -- the exact combination scheme does not matter much (concatenation with a separator is fine) as long as changing salt changes the output for the same IP, and the function stays deterministic for the same (ip_address, salt) pair.
Acceptance criteria
Verification
pytest practice_tickets/tests/test_ticket_03_ip_hash_salt.py -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
Sign in to create it automatically, or do it yourself:
$git checkout -b fix/ip-hash-missing-saltFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/ip-hash-missing-saltSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign indocker-entrypoint.shcurl -X POST http://localhost:5000/api/urls \
-H "Content-Type: application/json" \
-d '{"target_url": "https://anthropic.com", "custom_slug": "claude"}'
# -> {"slug": "claude", "short_url": "http://localhost:5000/claude", "expires_at": null}
curl -i http://localhost:5000/claude # 302 redirect, records a click
make seed # or: docker compose exec web flask seed-db
If something is already listening on 5432/6379 locally, uncomment POSTGRES_HOST_PORT / REDIS_HOST_PORT in .env to remap the host side — the app always talks to db/redis over the compose network regardless. Run production-style (gunicorn, no dev server, no bind mount) with docker compose -f docker-compose.prod.yml up --build. GET /healthz checks both Postgres and Redis connectivity.
You do not need Docker running at all to work the tickets — the test suite uses TestingConfig (SQLite in-memory via StaticPool) and fakeredis instead of a real Postgres/Redis, so everything runs against a plain virtualenv:
python3 -m venv .venv && .venv/bin/pip install -r requirements-dev.txt
.venv/bin/pytest practice_tickets/tests/test_ticket_01_base62_roundtrip.py -v # a single ticket
./practice_tickets/run_tickets.sh # all 20, clean pass/fail summary
./practice_tickets/run_tickets.sh 05 13 16 # just a few, by number
All 20 tests fail at the start; as you fix each ticket in app/, its test (and only its test) should flip to passing. .venv/bin/pytest tests/ (via make test) runs the project's own main suite — some ticket bugs (TICKET-05, 07, 08, 09, 14 among others) also break assertions in that suite, since they are real bugs in shared code paths; fixing the ticket fixes those too, not a separate task.
Level 1
Fix a bug
Read existing behaviour, correct it.