(Above is Chat for core developers, end users, supporters - click on the badge to join)
It is a Code Scanning/SAST/Static Analysis/Linting solution using many tools/Scanners with One Report. You can also add any tool to it. Currently, it supports many languages and tech stacks. Similar to SonarQube, but it is different.
Fig. 1 Scanmycode concept diagram
How is Scanmycode different than SonarQube?
If you like it, please give it a GitHub star/fork/watch/contribute. This will ensure continous development ⭐
This project would not be possible without the generous support of our sponsors.
Your Logo Here | Your Logo Here | Your Logo Here | Your Logo Here |
If you also want to support this project, head over to our Github sponsors page or Patreon (preferred due to better Tax handling)
To install it. Install docker
and docker-compose
and then:
2 options
- Fastest (use DockerHub built images). If unsure, use this.
git clone https://github.com/marcinguy/scanmycode-ce.git
cd scanmycode-ce/dockerhub
./start.sh
- Slower (build everything)
git clone https://github.com/marcinguy/scanmycode-ce.git
cd scanmycode-ce/docker
./start.sh
Go in the Browser to:
http://localhost:5000
Sign up locally (and login in when needed)
Cloud and Kubernetes (scaling) installation:
If your connection is not fast and/or you have no server.
Installation time: ca. 1 minute
Check installation on Kubernetes (Free) thanks to Okteto.com
https://github.com/marcinguy/scanmycode-ce/blob/master/okteto/README.md
It is platform independent (Python). Checkers are also mostly available on different platforms. "Master" branch is for Linux x86_64, however there is also "macos" branch with Dockerfiles for arm64 (including arm64 checkers). M1 mac has arm64 architecture (30% cheaper and 30% faster than alternatives)
More info in the Wiki:
https://github.com/marcinguy/scanmycode-ce/wiki
You can plug it anywhere on your CI/CD pipeline as a command.
With SMC one command, you add 1,500+ checks using different scanners (SMC is Meta scanner in that sense, with supporting smart snapshots and other goodies. It is not just running tools always on full code)
SMC supports also CLI only mode, no Web Interface, worker etc. Run a binary in Docker in your own CI/CD pipeline (whatever it is) in Quality Gates that will output line by line (scanner and findings) on checkout code from Git (folder)
Fig 2. Sample CI/CD Pipeline (Photo courtesy of Viking from THC Telegram Channel)
You can put it under Quality Gates.
Build Docker image Worker-CLI and run checkmate
from there. Below is sample flow:
CLI Mode only
- Clone the repo i.e into
/tmp/test
- set env var CODE_DIR i.e
export CODE_DIR=/tmp/test
. This env var should point to your Git cloned repo dir. - Cd into it (this is important!)
- Run
checkmate init
- Run
checkmate git init
- Run
checkmate git analyze
Run checkmate issues
This will be shown
/root
/tmp/test
/tmp/test
Loading plugin: git
Loading plugin: trufflehog3
Loading plugin: trojansource
Loading plugin: metrics
Loading plugin: bandit
Loading plugin: brakeman
Loading plugin: phpanalyzer
Loading plugin: gosec
Loading plugin: confused
Loading plugin: pmd
Loading plugin: semgrep
Loading plugin: semgrepdefi
Loading plugin: semgrepjs
Loading plugin: checkov
semgrepjs ExpressLfrWarning
semgrepjs CookieSessionNoDomain
semgrepjs CookieSessionNoPath
semgrepjs CookieSessionNoSecure
semgrepjs CookieSessionDefault
semgrepjs CookieSessionNoSamesite
There is a DockerHub image also for it ready.
docker pull scanmycode/scanmycode3-ce:worker-cli
You can run the Commands with docker as below:
$ docker run -ti scanmycode/scanmycode3-ce:worker-cli checkmate
/root
/root
Loading plugin: git
Loading plugin: trufflehog3
Loading plugin: trojansource
Loading plugin: metrics
Loading plugin: bandit
Loading plugin: brakeman
Loading plugin: phpanalyzer
Loading plugin: gosec
Loading plugin: confused
Loading plugin: pmd
Loading plugin: semgrep
Loading plugin: semgrepdefi
Loading plugin: semgrepjs
Loading plugin: checkov
Usage: checkmate [command] [command] [...] [args]
Type "checkmate help" for help
Same workflow as above, but using Docker binary:
export CODE_DIR=/tmp/test
cd /tmp/test
docker run -e CODE_DIR -v /tmp/test:/tmp/test -ti scanmycode/scanmycode3-ce:worker-cli /bin/sh -c 'cd /tmp/test && checkmate init'
docker run -e CODE_DIR -v /tmp/test:/tmp/test -ti scanmycode/scanmycode3-ce:worker-cli /bin/sh -c 'cd /tmp/test && checkmate git init'
docker run -e CODE_DIR -v /tmp/test:/tmp/test -ti scanmycode/scanmycode3-ce:worker-cli /bin/sh -c 'cd /tmp/test && checkmate git analyze'
docker run -e CODE_DIR -v /tmp/test:/tmp/test -ti scanmycode/scanmycode3-ce:worker-cli /bin/sh -c 'cd /tmp/test && checkmate issues'
Progpilot, PMD, Bandit, Brakeman, Gosec, confused, semgrep, trufflehog3, jshint, log4shell via custom semgrep rule and other(s). Some were modified.
Community Edition does not have GitHub support and other plugins. But rest is the same.
or Check the:
Both use static analysis to find bugs and defects, but there are a few differences.
- Scanmycode supports Cloudnative and Infrastructure Scanning
- Scanmycode supports secrets Scanning
- Scanmycode can be extended with any tool producing JSON output (any binary, in any technology/language/product)
Above are the biggest differences.
- Scanmycode is Open Source, SonarQube also offers an open-source version, but it is missing features (For example, 12 of the supported languages are not available in the open-source offering, and more powerful dataflow features are only available in the paid versions)
- Scanmycode supports scanning only changed files (differential analysis), SonarQube does not
- Scanmycode uses also semgrep as one of the tools (without semgrep community rules, only Scanmycode's custom rules)
Below are semgrep's (also Scanmycode advantages over SonarQube):
"Extending Semgrep with custom rules is simple, since Semgrep rules look like the source code you’re writing. Writing custom rules with SonarQube is restricted to a handful of languages and requires familiarity with Java and abstract syntax trees (ASTs)."
"Semgrep focuses on speed and ease-of-use, making analysis possible at up to 20K-100K loc/sec per rule. SonarQube authors report approximately 0.4K loc/sec for rulesets in production."
Source: semgrep's website
Scanmycode is based on QuantifedCode. QuantifiedCode is a code analysis & automation platform. It helps you to keep track of issues and metrics in your software projects, and can be easily extended to support new types of analyses. The application consists of several parts:
- A frontend, realized as a React.js app
- A backend, realized as a Flask app, that exposes a REST API consumed by the frontend
- A background worker, realized using Celery, that performs the code analysis
Currently supports: PHP, Java, Scala, Python, Ruby, Javascript, Typescript, GO, Solidity, DeFi Security (DeFi exploits), Infractructure as a Code (IaC) Security and Best Practices (Docker, Kubernetes (k8s), Terraform AWS, GCP, Azure), Secret Scanning, Dependency Confusion, Trojan Source, Open Source and Proprietary Checks (total ca. 1,500+ checks)
Advantages:
- Many tools, one report (unification)
- Dismiss, collaborate on findings. Mark false-positives
- Enable/disable each individual check in Checkers
- ca. 1,500+ checks now (Linters, Static Code Analysis/Code Scanning)
- any tool outputting JSON can be added
- fast (checks only new code on recheck)
- Git support (HTTPS/TLS and SSH). For private repositories only SSH.
- all REST API callable (CI/CD integrateable)
- Swiss army knife tool/SIEM for Code Scanning
- 100% Code transparency & full control of your code
Cloud version and more at https://www.scanmycode.io
Cloud version has also many other plugins, also other plugins are commercially available for licensing (GitHub, GitHub organizations, Slack)
Looking for contributing individuals and organizations. Feel free to contact me at [email protected]
TODO
- update Dependencies (Backend & Frontend - done)
- update to latest React
- update to Python3 (see scanmycode3 branch - done)
- update/add new Checkers (if you wish)
Scanmycode's QuantifiedCode parts remain released under BSD-3 Clause License. However, modifications are released under LGPL-2.1 with Commonsclause.
You can use this software, but cannot sell it, also base services on it (SaaS - Software as a Service setups). This is the Commonsclause. If you would like to do it, please contact me first for the permission at [email protected]
We provide several options for installing Scanmycode. Which one is the right one for you depends on your use case.
- The manual installation is best if you want to modify or change Scanmycode
- The Docker-based installation is probably the easiest way to try Scanmycode without much work
- The Ansible-based installation is the most suitable way if you want to run Scanmycode in a professional infrastructure (possibly with multiple servers)
The following section will only discuss the manual installation process, for the other options please check their corresponding repositories.
The installation consists of three parts:
- Install the dependencies required to run Scanmycode
- Download the required source code
- Set up the configuration
Scanmycode requires the following external dependencies:
- A message broker (required for the background tasks message queue). We recommend either RabbitMQ or Redis.
- A database (required for the core application). We recommend PostgreSQL, but SQLite is supported as well. Other database systems might work too (e.g. MySQL), but are currently not officially supported. If you need to run Scanmycode on a non-supported database, please get in touch with us and we'll be happy to provide you some guidance.
Now with the dependencies installed, we can go ahead and download Scanmycode:
git clone https://github.com/marcinguy/scanmycode-ce.git
Scanmycode CE manages dependencies via the Python package manager, pip.
Scanmycode gets configured via YAML settings files. When starting up the application, it incrementally loads settings from several files, recursively updating the settings object. First, it will load default settings from quantifiedcode/settings/default.yml
. Then, it will check if a QC_SETTINGS
environment variable is defined and points to a valid file, and if so it will load settings from it (possibly overwriting default settings). If not, it will look for a settings.yml
file in the current working
directory and load settings from there. Additionally, it will check if a QC_SECRETS
environment variable is defined and points to a valid file, and also load settings from there (this is useful for sensitive settings that should be kept separate from the rest [e.g. to not check them into version control]).
There is a sample settings.yml
file in the root of the repository that you can start from.
After editing your settings, run the setup command via
#run from the root directory of the repository
python manage.py setup
The setup assistant will iteratively walk you through the setup, and when finished you should have a working instance of Scanmycode!
To run the web application, simply run
python manage.py runserver
To run the background worker, simply run
python manage.py runworker
See docker folder. You can spin up everything using one command.
Coming Soon!