Sign inSign up

checkmarx/2ms

By checkmarx

•Updated 10 months ago

Too many secrets (2MS) helps people protect their secrets on files, CMS systems, chats and git

Image
1

100K+

checkmarx/2ms repository overview

⁠2ms (Too Many Secrets)

Latest Release Homebrew License Trivy

2ms Mascot

Modern secrets discovery CLI for code, content, and collaboration platforms.

2ms is an open-source CLI from Checkmarx that helps teams surface credentials, API keys, tokens, and other sensitive data before it leaks. It builds on the gitleaks detection engine, adds Checkmarx expertise, CVSS-based scoring, and optional secret validation so you can triage the riskiest findings first.

⁠Table of Contents

⁠Quick Start

Install, scan your local workspace, and review the findings in seconds:

brew install 2ms
2ms filesystem --path .

Scan recent Git history instead:

2ms git . --depth 50

2ms prints a YAML summary by default and returns a non-zero exit code when secrets are detected.

⁠Highlights

  • Unified scanning for local directories, Git history, Slack, Discord, Confluence Cloud, and Paligo — each exposed as a dedicated subcommand.
  • Hundreds of tuned detection rules curated by Checkmarx on top of gitleaks, enriched with CVSS-based scoring in every finding.
  • Optional live secret validation (--validate) to confirm whether discovered credentials are still active.
  • Flexible filtering and noise reduction: --rule, --ignore-rule, --add-special-rule, --ignore-result, --regex, --allowed-values, and --max-target-megabytes.
  • Rich reporting for developers and pipelines with JSON, YAML, and SARIF outputs, multiple --report-path destinations, and CI-aware exit handling via --ignore-on-exit.
  • Automation ready: configuration files, 2MS_* environment variables, Docker images, and GitHub Actions templates.
  • Extensible plugin architecture — contributions for new data sources are welcome.

⁠Installation

⁠Homebrew (macOS/Linux)
brew install 2ms

Upgrade with brew upgrade 2ms. Confirm the install:

2ms --version
⁠Prebuilt Binaries

Download the latest release for your platform from the releases page⁠:

Unzip the archive and place the 2ms binary somewhere on your PATH (for example /usr/local/bin/2ms).

⁠Build from Source
git clone https://github.com/checkmarx/2ms.git
cd 2ms
go build -o dist/2ms ./...
./dist/2ms --version

Refer to go.mod for the minimum Go toolchain version.

⁠Docker

Run 2ms from the published container image:

docker run --rm checkmarx/2ms

Mount a workspace to scan it:

docker run --rm -v "$(pwd)":/repo checkmarx/2ms git /repo --stdout-format json

Provide tokens and other secrets through environment variables (-e SLACK_TOKEN=...) or mounted config files.

⁠Scan Targets

CommandSurfaceTypical Use
2ms filesystemLocal directoriesScan any type of source file.
2ms git <path>Git repositoriesInspect commit history to find any secret exposed.
2ms confluence <URL>Confluence CloudCrawl spaces and pages.
2ms discordDiscord serversAudit server message history.
2ms slackSlack workspacesReview channels for exposed credentials.
2ms paligoPaligo instancesScrape documentation components delivered via Paligo.
⁠Local File System
2ms filesystem --path . --ignore-pattern "*.log"
FlagTypeDescription
--pathstring (required)Directory to scan.
--project-namestringOptional label to distinguish multiple filesystem scans.
--ignore-patternstring sliceGlob patterns to exclude (matched against the file or folder name).
⁠Git Repositories
2ms git /path/to/repo --depth 200 --project-name api-service
FlagTypeDescription
--depthintLimit how many commits from HEAD are analyzed.
--all-branchesboolScan every branch instead of the checked-out branch.
--base-commitstringOnly scan commits between the base commit and HEAD.
--project-namestringOptional label to differentiate results.
⁠Confluence Cloud
2ms confluence https://<org>.atlassian.net/wiki --space-keys ENG,SEC --history \
  --username [email protected] --token "$ATLASSIAN_TOKEN"
FlagTypeDescription
--space-keysstring sliceComma-separated space keys to crawl.
--space-idsstring sliceComma-separated space IDs to crawl.
--page-idsstring sliceSpecific page IDs to scan.
--historyboolInclude all revisions (page history).
--usernamestringConfluence user/email for authentication.
--tokenstringAuthentication token (Confluence API token or scoped API token).
--max-api-response-megabytesintSoft per-response size limit (MB). 0 disables it. Exceeded batches are skipped.
--max-page-body-megabytesintSoft per-page body size limit (MB). 0 disables it. Oversized pages are skipped.
--max-total-scan-megabytesintGlobal download limit (MB). 0 disables it. If exceeded, the scan stops early.

URLs must be HTTPS. Without credentials 2ms scans only public content.

⁠Authentication
⁠Examples
  • Scan all public pages (no auth):

    2ms confluence https://<org>.atlassian.net/wiki
    
  • Scan private pages with an api token or a scoped api token (requires auth):

    2ms confluence https://<org>.atlassian.net/wiki --username <USERNAME> --token <API_TOKEN>
    
  • Scan specific spaces by ID:

    2ms confluence https://<org>.atlassian.net/wiki --space-ids 1234567890,9876543210
    
  • Scan specific pages by ID:

    2ms confluence https://<org>.atlassian.net/wiki --page-ids 11223344556,99887766554
    
⁠Slack
2ms slack --token "$SLACK_TOKEN" --team my-workspace --duration 30d --channel secure-chat
FlagTypeDescription
--tokenstring (required)Slack token with permission to read conversations.
--teamstring (required)Workspace name or ID.
--channelstring sliceChannel names or IDs to target. Defaults to all channels.
--durationdurationLook back interval (default 14d). Use values like 24h, 7d, 1M.
--messages-countintUpper bound on messages per channel (0 = all).
⁠Discord
2ms discord --token "$DISCORD_TOKEN" --server 1097814317077897307 --duration 9999h
FlagTypeDescription
--tokenstring (required)Discord bot or user token.
--serverstring slice (required)Server (guild) names or IDs to scan.
--channelstring sliceChannel names or IDs to restrict the scan. Defaults to all channels.
--durationdurationLook back interval (default 14d).
--messages-countintMaximum messages per channel (0 = scan until duration is met).
⁠Paligo
2ms paligo --instance your-instance --username alice --token "$PALIGO_TOKEN"
FlagTypeDescription
--instancestring (required)Paligo instance name (subdomain).
--usernamestringPaligo username (use with --token).
--tokenstringAPI token for authentication.
--authstringBase64-encoded username:password alternative to --username/--token.
--folderintFolder ID to scope the scan; scans the whole instance when omitted.

⁠Configuration & Tuning

Global flags work with every subcommand. Combine them with configuration files and environment variables to automate 2ms in large environments.

⁠Global Flags
FlagTypeDefaultDescription
--configstringPath to a YAML or JSON configuration file.
--log-levelstringinfoLogging level: trace, debug, info, warn, error, fatal, or none.
--stdout-formatstringyamlyaml, json, or sarif output on stdout.
--report-pathstring sliceWrite findings to one or more files; format is inferred from the extension.
--ignore-on-exitenumnoneControl exit codes: all, results, errors, or none.
--max-target-megabytesint0Skip files larger than the threshold (0 disables the check).
--validateboolfalseEnrich results by verifying secrets when supported.
⁠Configuration Files & Environment Variables

Pass --config to load shared defaults:

# .2ms.yaml
log-level: debug
stdout-format: json
report-path:
  - reports/2ms.json

filesystem:
  path: .
  ignore-pattern:
    - "*.log"

You can still override values via CLI flags; the CLI always wins over config values.

⁠Rules, Validation, and Custom Detection
  • List the available detection rules (and whether they support validation) with 2ms rules.
  • The full rule catalog lives in docs/list-of-rules.md⁠.
  • Focus on specific checks with --rule <rule-id> or exclude noisy ones with --ignore-rule.
  • Enable opt-in detections via --add-special-rule <rule-id> and tailor searches using custom --regex patterns.
  • Suppress individual findings with --ignore-result <secret-id> or whitelist known safe secrets using --allowed-values.
  • --validate asks 2ms to contact the upstream service (when available) to confirm a secret is still active. Validation outcomes feed into the CVSS-derived score in each result.

⁠Reports & Outputs

2ms prints YAML summaries by default. Switch formats or emit multiple artifacts:

2ms git . \
  --stdout-format json \
  --report-path build/2ms.sarif \
  --report-path build/2ms.yaml

SARIF reports plug directly into GitHub Advanced Security or other code-scanning dashboards. All outputs include rule metadata, severity scores, file locations, and (when enabled) validation status.

⁠CI/CD & Automation

Run 2ms in pipelines, scheduled jobs, or security gates:

name: secret-scan
on:
  pull_request:
  push:
    branches: [main]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
        with:
          fetch-depth: 0
      - name: Run 2ms
        run: |
          docker run --rm -v "$PWD":/repo checkmarx/2ms \
            git /repo --stdout-format sarif \
            --report-path /repo/artifacts/2ms.sarif \
            --ignore-on-exit results
      - name: Upload SARIF
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: artifacts/2ms.sarif

Use --ignore-on-exit results to keep pipelines green when only findings (not errors) are present, or leave it at the default none to fail on detected secrets.

⁠Contributing

2ms is built around a plugin system so new targets and enhancements are easy to add. Check out CONTRIBUTING.md⁠ for development setup, coding guidelines, and how to propose new rules or plugins.

⁠Community

2ms is maintained by Checkmarx and released under the Apache 2.0 License⁠ — contributions and feedback are always welcome.

Tag summary

Content type

Image

Digest

sha256:f167f3585…

Size

34.5 MB

Last updated

10 months ago

docker pull checkmarx/2ms