Scan and Fix Mode
Overview
Uses Mobb's built-in Opengrep scanner to identify vulnerabilities in your repository. No external SAST tool or pre-generated report required.
Produces code fixes and redirects the user to the fix report page on the Mobb platform
Also supports a diff-aware mode (via
--baseline-commit) that only reports findings introduced since a given commit. Ideal for pull request scans.Can run report-only (via
--scan-only) and can enforce your organization's Scan & Gate Policy (via--gate) to fail a build.
Scan and Fix Mode - Usage
To check what options are available, run:
npx @mobb.ai/cli@latest analyze --helpHere is the output of the help file:
mobbdev analyze
Provide a code repository, get automated fixes right away. You can also provide a vulnerability report to analyze or
have Mobb scan the code for you.
Options:
-f, --scan-file Select the vulnerability report to analyze (Checkmarx, Snyk, Fortify,
CodeQL, Sonarqube, Semgrep, Datadog, Black Duck) [string]
-r, --repo Github / GitLab / Azure DevOps repository URL [string] [required]
-p, --src-path Path to the repository folder with the source code; alternatively, you
can specify the Fortify FPR file to extract source code out of it
[string]
--ref Reference of the repository (branch, tag, commit) [string]
--mobb-project-name Mobb project name [string] [default: "My first project"]
-y, --yes Skip prompts and use default values [boolean]
--ci Run in CI mode, prompts and browser will not be opened
[boolean] [default: false]
--org, --organization-id Organization id [string]
--api-key Mobb authentication api-key [string]
--auto-pr Enable automatic pull requests for new fixes [boolean] [default: false]
--create-one-pr Create a single unified PR for all fixes (requires --auto-pr)
[boolean] [default: false]
--commit-directly Commit directly to the scanned branch instead of creating a pull
request [boolean] [default: false]
--pull-request, --pr, --pr-number, --pr-id Number of the pull request [number]
--polling Use HTTP polling instead of WebSocket for status updates. Useful for
proxy environments or firewalls that block WebSocket connections.
Polling interval: 5 seconds, timeout: 30 minutes.
[boolean] [default: false]
--baseline-commit Only report findings introduced since this commit (PR mode). The sha
must be reachable from the scanned repository — unreachable baselines
fail the scan loudly. Effective only when no scan file is provided.
[string]
--scan-only Scan only: run the Mobb scan and report findings without generating
fixes. The report can be fixed later (re-run without this flag, or
use the Fix button in the app). Ignores fix-related flags
(--auto-pr, --commit-directly, --create-one-pr).
[boolean] [default: false]
--gate Enforce the organization's Scan & Gate Policy: after the scan, the
backend decides whether any finding blocks, and the CLI exits 2 when
it does (0 = pass, 1 = operational error; a scan that fails to finish
exits 1, not 2). Mobb scans only — cannot be combined with
--scan-file. In PR pipelines pair it with --baseline-commit so only
findings new in the PR can block. [boolean] [default: false]
--help Show help [boolean]Example: Full Repository Scan
To scan an entire repository and generate fixes, run the analyze command without the -f flag:
Notice that there is no -f or --scan-file parameter. When no scan file is provided, Mobb will:
Scan the repository using Mobb's internal Opengrep scanner
Generate automated fixes for supported issues along with a fix report
Diff-Aware Mode (--baseline-commit)
Scan and Fix also supports a diff-aware mode that only reports findings introduced since a given commit. This is especially useful in pull request workflows, where you only want to surface (and fix) vulnerabilities that the PR itself adds, not pre-existing issues on the base branch.
To enable diff-aware mode, pass the base commit SHA via --baseline-commit:
Scan-Only Mode (--scan-only)
Pass --scan-only to run Mobb's scan and record the findings without generating fixes:
The scan report is stored on the Mobb platform and can be fixed later — either re-run the same command without
--scan-only, or use the Fix button in the Mobb app.Fix-related flags (
--auto-pr,--commit-directly,--create-one-pr) are ignored when--scan-onlyis set.
Use this when you want visibility into findings first, or to keep scan and fix as separate pipeline stages.
Gate Mode (--gate)
Pass --gate to have the scan enforce your organization's Scan & Gate Policy. After the scan completes, the Mobb backend decides whether any finding should block, and the CLI exits with a dedicated exit code so your pipeline can fail the build:
0
Pass — no finding blocks under the policy
1
Operational error, including a scan that failed to finish
2
Blocked — the Scan & Gate Policy blocks on at least one finding
Automatic PR
To enable automatic PRs for the fixes Mobb generates, add the --auto-pr flag:
Other related flags:
--create-one-pr: Bundle all fixes into a single unified PR (requires--auto-pr)--commit-directly: Commit fixes directly to the scanned branch instead of opening a PR (requires--auto-pr)--pr-number: Associate the fixes with an existing pull request (requires--commit-directly)
Click here to learn more about the Automatic PR feature.
Full Workflow Example: GitHub Actions (Diff-Aware Scan + Auto-PR)
The following GitHub Actions workflow runs Mobb's native diff-aware scan on every pull request, then automatically commits fixes back to the PR branch. Because Mobb's CLI performs the scan natively, there is no separate SAST step needed in the pipeline.
Key things to note in this workflow:
--baseline-commit "${{ github.event.pull_request.base.sha }}"makes the scan diff-aware. Only findings introduced by the PR are reported and fixed.--pr-numberassociates the fixes with the originating PR.--auto-prcombined with--commit-directlycauses Mobb to push fix commits directly to the PR branch.No
actions/setup-nodestep is required for the runtime itself — the@mobb.ai/clibinary embeds its own.npxis available on GitHub-hosted runners out of the box.
Benefits of Scan and Fix Mode
No external scanner required: No need to run Checkmarx, Snyk, Semgrep, or other SAST tools first
Streamlined workflow: One command to scan and fix
Built-in scanner: Uses Mobb's optimized Opengrep engine
Diff-aware:
--baseline-commitlets you focus only on newly introduced findings, perfect for PR gatingBuild gating:
--gatefails the pipeline (exit code 2) when your Scan & Gate Policy blocksReport first, fix later:
--scan-onlyseparates visibility from remediationImmediate results: Get fixes without waiting for external scan reports
Last updated