Validate Your Input
Check every value that enters your program before you use it.
When people hear security, they think of hackers. That is part of it. But most security problems start with ordinary mistakes: a program trusts a value it should have checked, hides an error it should have reported, or forgets a case it should have handled. Those mistakes corrupt data, crash programs, and expose private information whether or not anyone is attacking.
A secure program keeps doing the right thing when conditions are bad. The input is mistyped. The file is missing. The number is negative. Someone is deliberately feeding it garbage. In every case, the program either handles the situation or fails clearly and safely.
The habits in this lab come from the NSA’s secure programming principles. They apply to any program, including the small command-line application your team is building.
if chain and match statement needs a path for input you did not expect.Each page uses the same small example: a command-line inventory tracker that lets a user add items, remove items, list what is in stock, and save to a file. It is close to what your team project does, so the fixes should look familiar.
The Information Literacy assignment asks you to research one of these principles and decide whether it applies to your team’s project. These pages are the starting point for that research.
Check every value that enters your program before you use it.
Catch errors where you can fix them. Let the rest propagate.
Tell the user what went wrong without revealing how your program works inside.
Every branch needs a path for the input you did not expect. Use defaults to handle it.
Your tools can find many of these problems before you run the code. Read what they say and fix it.