Announcing AppMap for GitHub - Runtime Code Reviews for Every Pull Request
Tags: ruby, java, python, node
Published: 2023-11-09 01:17:20

Most of us have a love-hate relationship with code reviews. We rely on code reviews to ensure that the code we send to production is clean, performs well, and is free of security flaws. But code reviews can also add a lot of overhead and delays to shipping code.

Some people suggest that code reviews should be eliminated altogether. Well, I'm not in that camp, and here's why: Unexpected code behavior and deep runtime defects are responsible for a staggering 40% of performance problems¹ and 50% of security concerns² in software development. But, I do think that it's important to make code reviews easier for developers, and at AppMap we've created AppMap for CI to help do that.

>“Security and performance reviews are part of the process on any engineering team, and ours is no different. It can take months to find issues and weeks to fix problems using static analysis and code reads. With AppMap, that time is reduced to minutes.”  
 -Padraig Coffey, CEO at Zartis.

If you know AppMap already, you know us for our [VS Code](https://marketplace.visualstudio.com/items?itemName=appland.appmap) and [JetBrains](https://plugins.jetbrains.com/plugin/16701-appmap) extensions that automatically generate complete, accurate, interactive diagrams of your code. So now, with AppMap for CI, we've built on the solid foundation of AppMap to make code reviews easier, better, and faster. 

The first CI platform we support is GitHub Actions. Our solution combines an [AppMap GitHub App](https://github.com/marketplace/get-appmap) with GitHub Actions. When you build your project, the [AppMap Analysis Action](https://github.com/marketplace/actions/appmap-analysis) analyzes AppMaps from before and after each code change. It's able to identify critical performance, security, and stability issues and annotate specific lines of code in the pull request. It also performs deep analysis of test case failures and web service API changes, giving you a big head start on code review. And by the way, the performance and security flaws that AppMap finds are not discoverable by static analysis tools - because modern code is too dynamic for static analysis tools to understand.

>“When we initially adopted AppMap, we were only using it for visualizing N+1 queries locally. We later integrated it into our CI run, and we are finding the GitHub comments posted by AppMap to be very useful. The OpenAPI integration, in particular, was a surprise: it’s nice to see an automatically generated summary of what endpoints have changed in a PR."  
-Paul Kuruvilla, CTO at CodeCrafters.


## Your data stays with you

We know that your code is sensitive, and you don't want it to be transmitted to 3rd parties. All AppMaps are stored as artifacts in your GitHub build system and are sent directly to your browser when you view them. The data only resides in two places - the GitHub Actions environment, and your machine. [Learn more at appmap.io/security](https://appmap.io/security).

## A tour of AppMap's "runtime code review"

✅ AppMap issues a summary report of its runtime analysis as a comment on every PR. The PR comment includes four key categories:

* **Failed tests**  

Identifies the root cause of test failures with detailed insights and direct links to the line of code which caused the error. AppMap also includes source diffs and behavioral sequence diffs for efficient debugging.  

* **API Changes**  

Detects API route differences, including new, deleted, or modified routes, as well as alterations in response attributes like body, content, and descriptions.  

* **Security flaws**  

Uncovers issues such as broken or missing access control, deprecated cryptography, improper session management, and missing authentication. AppMap focuses on the runtime security flaws that dominate the [OWASP Top 10](https://owasp.org/www-project-top-ten/), and can't be reliably detected by static analysis.

* **Performance problems**  

Identifies performance problems like N+1 SQL queries, very complex queries, RPC anti-patterns, and plain old slow code. 

### Example - Performance problems

Here's an example of a code change that introduces four new performance problems.

![Performance flaw summary](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0dz2ozc0mfx7vkm21yr7.png)

The AppMap runtime code review includes details about the flaws detected, a stack trace, and links to the offending source code.

![Performance flaw details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czksqcrzdzo1lkvbwrg1.png)

AppMap highlights specific code changes that are contributing to the flaw. It's able to focus on the specific code changes that are relevant to the newly introduced problem.

![Performance flaw source diff](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ol3cuyvbgm2t0ganr2t.png)

AppMap also links to an interactive "diff" diagram showing how the code change has introduced the flaw. 

![Performance flaw source diff](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0zyypkgqcyuayedl3q9j.png)

### Example - Security flaw

Here is an example of AppMap describing a security flaw and the code change that produced it.

![Security flaw details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9u4re8g0orrz58xpwgx7.png)

Included in the comment is a stack trace showing what led to the security flaw, including links to the source code.

![Security flaw stack trace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7hg757k5xitiwrjrj9hr.png)

AppMap also provides a full set of interactive visualizations that describe the code behavior that resulted in the security flaw.

![Security flaw AppMap](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q7ayep580rg2f3fvo3q0.png)

## Wrap-up

To get started, [install the AppMap GitHub App from the GitHub Marketplace.](https://github.com/marketplace/get-appmap) 

Not ready to try it for yourself? We have [example projects on our GitHub](https://appmap.io/docs/setup-appmap-in-ci/example-projects.html) so you can check out AppMap for GitHub Actions at work. 

**Links**

:robot: AppMap for GitHub Actions: https://getappmap.com
:arrow_down: Download AppMap for VSCode and JetBrains: https://appmap.io/download
:star: Star AppMap on GitHub: https://github.com/getappmap
:video_camera: Follow on: https://youtube.com/@appmap
:speech_balloon: Join AppMap Slack: https://appmap.io/slack
:information_source: Read the AppMap docs: https://appmap.io/docs

**References**

- [(1) FAUSTA: Scaling Dynamic Analysis with Traffic Generation at WhatsApp
](https://research.facebook.com/publications/fausta-scaling-dynamic-analysis-with-traffic-generation-at-whatsapp/)
- [(2) CWE Top 25 Most Dangerous Software Weaknesses](https://cwe.mitre.org/top25/)