Input, validation and safety

Knowledge Videos

Short animated explainers, organised by subject.

Input, validation and safety

Never trust a request: validate empty and too-long values and answer 400, why ? placeholders stop SQL injection, and keep secrets and database files out of Git.

Transcript

Never trust what arrives in a request. A visitor can send an empty title, a huge one, or something that is not even J S O N.

Validate before you save. Check for empty values and too long ones, and answer with a four hundred and a clear message.

A bad visitor might send S Q L code as a title, to trick your database. This is called S Q L injection. Placeholders stop it, because the value is always treated as plain text.

Keep secrets, like passwords and keys, out of your code and out of Git. Put the database file and secret files in dot gitignore, and use made up data when you test.

Remember: never trust input, validate and answer with four hundred, use placeholders against injection, and keep secrets out of Git.

More in this series