Installation Guide
Relevant source files
The following files were used as context for generating this wiki page:
2ms (Too many secrets) is an open-source CLI tool written in Go, powered by Checkmarx, designed to identify sensitive data like secrets and authentication keys in unencrypted text. It supports scanning various platforms, including Slack, Discord, Confluence, Git repositories, and local directories.
The tool is based on the Gitleaks framework and employs a scoring system based on CVSS to prioritize remediation. Users can install 2ms through precompiled binaries, compilation from source, or by using Docker containers.
Sources: README.md:14-23
Download and Install Precompiled Binaries
Precompiled binaries for the amd64 architecture are available for Windows, MacOS, and Linux. These are the recommended installation method for most users who do not require custom modifications.
Supported Platforms
| Operating System | Download Link (Latest) |
|---|---|
| Windows | Download |
| MacOS | Download |
| Linux | Download |
Sources: README.md:33-40
Global Installation (Linux Example)
To install 2ms globally on a Linux system, the binary should be placed in the system's PATH, such as /usr/local/bin/.
cd /opt
mkdir 2ms
cd 2ms
wget https://github.com/checkmarx/2ms/releases/latest/download/linux-amd64.zip
unzip linux-amd64.zip
sudo ln -s /opt/2ms/2ms /usr/local/bin/2ms
Sources: README.md:42-53
Compile from Source
As 2ms is a Go application, it can be compiled directly from the source code. This requires a Go development environment to be installed on the host machine.
git clone https://github.com/checkmarx/2ms.git
cd 2ms
go build -o dist/2ms main.go
./dist/2ms
Sources: README.md:58-64, tests/e2e.go:27-38
The compilation process involves fetching the repository, resolving dependencies (such as github.com/checkmarx/2ms and Gitleaks v8), and outputting an executable binary.
The diagram shows the standard flow for building the 2ms executable from source code.
Sources: README.md:60-63, tests/e2e.go:27-38
Run From Docker Container
Docker images are published to checkmarx/2ms. This method is ideal for ephemeral environments or CI/CD pipelines where local installation is not desired.
Basic Execution
docker run checkmarx/2ms
Mounting Local Directories
To scan local files within a container, use the -v flag to mount a host directory to a container path. For git scans, the repository must be mounted to /repo.
docker run -v /home/user/workspace/git-repo:/repo checkmarx/2ms git /repo
Sources: README.md:68-81
CI/CD Integrations
2ms can be integrated into automated workflows. When using these integrations, ensure that the checkout step fetches the full history (fetch-depth: 0) so that 2ms can scan all commits.
Integration Workflow
This sequence diagram illustrates how a CI/CD runner interacts with the repository and Docker to perform a scan.
Sources: README.md:88-100
Configuration Examples
- GitHub Actions: Uses a
docker runcommand within a job step, typically mounting$(pwd)to/repo. - Azure DevOps: Uses a
scriptstep in theazure-pipelines.ymlto execute the Docker container.
Sources: README.md:102-125
Post-Installation Verification
After installation, users can verify the setup by running the help command or listing available rules.
| Command | Purpose |
|---|---|
2ms --version | Verify the installed version. |
2ms --help | Display the CLI interface and available commands. |
2ms rules | List all secrets detection rules. |
Sources: README.md:152-168, engine/engine.go:175-180
The CLI supports several scan commands specialized for different platforms:
confluence: Requires a URL and optional credentials.filesystem: Requires a--path.git: Requires a local repository path.slack/discord: Requires authentication tokens.
Sources: plugins/confluence.go:49-55, plugins/filesystem.go:37-41, plugins/git.go:40-44
2ms provides a versatile set of installation options ranging from simple binary downloads to containerized execution in CI/CD pipelines, ensuring it can be deployed in diverse development environments.