|
|
|
|
|
by donatj
657 days ago
|
|
You can get as many eyes as you want on all changes. I don't think it will help much. This sort of thing usually happens because of a change in something completely benign, rather than "security-critical changes". We recently had a pretty major vulnerability exposed by a PEN test (thankfully) that was caused by a single misplaced NOT ! operator in a pretty simple function, maybe 20loc with 100% test coverage as counted by line. The problem case was untested because while tests touched 100% of lines, not all combinations of paths through the code were tested. The code had been written by myself about a year ago, and reviewed by four seasoned developers, none of whom spotted the issue. How many thousands of eyes are on OpenSSL and yet major world ending vulnerabilities still crop up? This might be a hot take, but you can make the process as painful as you like but at the end of the day, building secure software is nigh impossible. We should be putting less trust in software. |
|
And I think one of the approaches that helped me to write safer code is to parse, and not validate.
That way drastically limit the situations we can get into where we forget to validate certain conditions.
e.g. you have a User struct, and you want to do an action which requires you to validate whether the user is an admin.
2 options here
* validate whether the user is an admin (which could happen multiple times when you're invoking distinct functions as part of a workflow)
* parse the User into an AdminUser. If the user is an admin, the function will work, and then you can pass on your new struct into places that require an admin. If it fails, the user is not an admin. Now you have merged all your checks into 1 place.