Learning guides / Workflow practice library / Configuration reviews
Original offline coding practice · Configuration reviews
Reject dangerous keys in a configuration patch
Walk nested data before merging it into an application object.
The behavior you need to preserve
Return sorted unique forbidden key paths for __proto__, prototype or constructor at any object depth, including arrays with numeric path segments. This is a review helper, not a universal security parser.
The defect to investigate: A top-level-only scan misses a nested constructor key.
This is a small fictional repository task, independent of any provider's course assignments. You can work alone or use a coding assistant. The useful result is a change you can explain and checks that distinguish it from the supplied wrong implementation.
Preparation: read a JavaScript function, open a terminal in an extracted folder and use Node.js 20 or newer. Reserve roughly 20–45 minutes for one attempt and review; this is a planning suggestion, not a measured completion time.
Get the runnable project
Download the exercise, cases and reference ZIP
2,216 bytes. The archive contains task.mjs, task.test.mjs, cases.json, inspect.mjs, task.reference.mjs and a README. Extract all files into one folder. No npm install, network request, model API or paid account is needed.
node --test task.test.mjs
node inspect.mjsUnchanged starter: 1 passing and 2 failing checks out of 3; the test command exits with code 1. The failure is intentional. It is the evidence you will use to judge the repair.
A case that distinguishes the error
Predict the result for this input before opening the reference. Read the written contract literally, including its input domain and boundary rule.
Input
{
"safe": {
"constructor": {
"x": 1
}
}
}Expected
[
"safe.constructor"
]Starter output
[]The complete cases.json includes 3 fixed examples. Every test also checks that the caller's input stays unchanged. An example can expose one mistake while leaving other input classes untested.
Repair and review the change
- Save the original command output and write one sentence connecting the mismatch to the contract.
- Trace the relevant operation in
task.mjs. Explain why the starter produces the shown output before asking an assistant to change it. - Change only that implementation. Keep the input cases, their expected values and the test file unchanged.
- Rerun the test command. The reference result is 3/3 passing checks and exit code 0. A repair should achieve that same result without changing the contract.
- Review the diff, save the output and add a fresh example from the declared domain. Write its expected value yourself before running it.
If a suggested change handles an example by hard-coding it, compare that explanation with the other cases. If it changes behavior outside the contract, record the proposed extension separately before adding requirements.
Reference implementation and reasoning
Open after your attempt
A top-level-only scan misses a nested constructor key. The implementation below follows the stated contract; compare its operations with the discriminating input rather than treating its presence as proof that your own change is correct.
export function solve(x) {
const out=[];function walk(v,p=""){if(!v||typeof v!=="object")return;for(const [k,a] of Object.entries(v)){const path=p?p+"."+k:k;if(["__proto__","prototype","constructor"].includes(k))out.push(path);walk(a,path);}}walk(x);return [...new Set(out)].sort();
}Copying this function can make the provided checks pass. To establish useful practice evidence, explain why it returns the expected result and demonstrate one additional case you selected independently.
Other required examples
| Input | Expected output |
|---|---|
| |
| |
| |
Use the result to choose your next lesson
If you could not run the command, practice the runtime and terminal first. If the command ran but the mismatch was hard to explain, spend the next session tracing data and assertions. If the repair was straightforward, review a fresh counterexample and make the input domain more explicit.
Cursor's official debugging chapter and Claude Code 101 are further reading for coding-agent workflows. These practice fixtures are our own material, not included provider assessments.
Find a coding-assistant learning route → · Work through a course decision
A coding-assistant workflow differs from building an app that calls an LLM API or studying machine-learning algorithms. Change the goal and your experience in the quiz if either better describes your intended output. Public lesson access and tool usage are separate; check current pricing and account requirements.