Source Code Review: Stategies

Hey folks,
Now, It is time to go over the strategies I use for my code review. Source code review can indeed be daunting at times. However, if done correctly, it is pure bliss and gives you more satisfaction.

https://bignerdranch.com/assets/img/blog/2014/01/code-review.jpg
https://bignerdranch.com/assets/img/blog/2014/01/code-review.jpg

Overview

I will outline a few strategies that I love to use. Then, we will go deeper and look at how it is done and what are its pros and cons.

  1. Coverage first review
  2. Keyword-based review
  3. functionality based review
  4. top-down review
  5. bottom-up review
  6. Automated review

1. Coverage first review

In this type of review, the reviewer will go through all the files from start to end and try to find if there are any critical bugs. This can also be done incrementally when a PR is made to the main branch. This kind of review is similar to a security review before pushing the code to the repo.

Speed of review: Low

Time to find the first bug: High

Coverage: High

False positive: Low

2. Keyword-based review

In this review, we search for potentially bad keywords like exec(), os.system() . We can also use regex to search for any API keys or hashes. This can also be replaced by automation through scanners.

Speed of review: High

Time to find the first bug: Low

Coverage: Medium

False positive: Low

3. Functionality based review

On a functionality-based review, we only care about a single or multiple functions. For example, we might look into the upload functionality and check for all the vulnerabilities related to the upload function such as bypass file type, large file upload, or upload with metadata.

Speed of review: High

Time to find the first bug: Medium

Coverage: Low

False positive: Low

4 . Top-down review

In this review, we start with the input field from the user or other medium into the application, then go till we reach the end of that data. Here, we are following the flow of the data till it reaches the entity such as DB, or goes to another application.

Speed of review: Medium

Time to find the first bug: Medium

Coverage: Medium

False positive: Low

5. Bottom-up review

In this review, we start with the output or databases and move up till we reach the input section of the code. Here, we are following the flow of the data till it reaches the entity such as input endpoints.

Speed of review: Medium

Time to find the first bug: Medium

Coverage: Medium

False positive: Low

6. Automated review

Here, we will use automated scanner like Sonarcube or Semgrep to get the work done. This can also be coupled with any of the above approaches.

Speed of review: High

Time to find the first bug: High

Coverage: High

False positive: High


Conclusion:

I hope these strategies help you in your security journey. Feel free to join the fuffsec family "subscribe" button.

Thanks for all your support.

Other interesting blogs:

Secure Code Review #1: Basics (Getting Started)
When it comes to software engineering, you may often hear the phrase “Trust the process,” but when it comes to security, it’s more…
Secure Code Review (SCR) : A5 — Security Misconfiguration
Security misconfiguration is a prevalent issue that can occur at any level of an application stack, including the network, platform, web…
Secure Code Review (SCR): A3 Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS) is one of the most prevalent, obstinate, and dangerous vulnerabilities in web applications. It allows attackers…