Basic

The debugger is a switch

A server that shows the source of an error shows the source of an error to whoever asks. The switch is not a convenience, it is a permission with a boundary.

What you will see

One line. The proof is in the suite, not in a note.

About 1 min of reading

Try It

Prove the debugger is refused

1

Write the mode

printf 'mode=production debug=off\n' > /tmp/m.txt; cat /tmp/m.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One line. The mode is written at creation, which is the rule.
2

Attempt to reach the debugger

printf 'debug=off\n' | awk '{print ($1=="debug=on") ? "frame" : "refuse"}'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
refuse. The refusal is the answer, and the answer is a test.
3

Write the test as a case

printf 'case=debugger-expected-refuse mode=production\n' >> /tmp/s.txt; tail -1 /tmp/s.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One line. The proof is in the suite, not in a note.

Data Flow

A switch to a refusal
1 The mode is read at creation
↓
2 The debugger is attached or not
↓
3 A request asks for the debugger
↓
4 The suite expects a refusal
Why this works
Why the switch is decided at creation

A switch set per request is a switch that can be set by the request. Creation is the last place the input cannot reach.

The artefact that proves it

A test that asks for the debugger and expects a refusal. The test is the proof, and the proof is in the suite.

Examples

On in production is a leak

The debugger executes code on request. Executing code on request is the most dangerous thing a server can do.

Off in development is a cost

The error is a stack trace in a log. The cost is reading a log instead of a page, and the reading is minutes.

The boundary is a host check

It is allowed on one host and refused on the rest. The host is the boundary, and the boundary is a number.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Application state and its owner
Previous Lesson
Application state and its owner
Next Lesson
Running the server is a choice
Running the server is a choice →