Skip to content

PHPC-2326: Run static analysis #1539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2024

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Apr 30, 2024

PHPC-2326

This PR is a proof-of-concept to use Semgrep to run static analysis. An advantage over the Coverity setup is the ability to run scans on pull requests and prevent merging of a pull request as long as issues are available. Note that this proof of concept makes use of Semgrep OSS without an account, so there is no possibility to triage issues. I'll revisit our options (there is a free tier for up to 10 contributors, but it only talks about private repositories) before continuing with the effort, but wanted to show how this could work.

@alcaeus alcaeus force-pushed the phpc-2326-static-analysis branch from 27fde1f to 6be0380 Compare April 30, 2024 07:30
@alcaeus alcaeus changed the base branch from master to v1.18 April 30, 2024 07:34
@alcaeus alcaeus force-pushed the phpc-2326-static-analysis branch from 6be0380 to a439899 Compare April 30, 2024 07:35
@@ -32,6 +32,7 @@
foreach ($vars as $var => $path) {
$cutNth = 2 + substr_count($path, '/');

// nosemgrep
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this? I assume shell_exec is the problem here.

Does Semgrep check M4 files? If not, you can exclude the entire scripts/ directory.

Either way, the PHP files under scripts/ shouldn't require scanning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excluded the bin and scripts directories as they only contain internal files

@alcaeus alcaeus force-pushed the phpc-2326-static-analysis branch from a439899 to e4a7b12 Compare May 22, 2024 07:58
@alcaeus alcaeus changed the base branch from v1.18 to v1.19 May 22, 2024 07:58
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@alcaeus alcaeus requested a review from jmikola May 22, 2024 08:24
@alcaeus alcaeus marked this pull request as ready for review May 22, 2024 08:25
@alcaeus alcaeus changed the title [POC] PHPC-2326: Run static analysis PHPC-2326: Run static analysis May 22, 2024
@alcaeus alcaeus merged commit 8e81e7b into mongodb:v1.19 May 22, 2024
49 of 53 checks passed
@alcaeus alcaeus deleted the phpc-2326-static-analysis branch May 22, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants