Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 62 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This guide walks you through both installation and usage.
3. [Path Scan](#path-scan)
1. [Terraform Plan Scan](#terraform-plan-scan)
4. [Commit History Scan](#commit-history-scan)
1. [Commit Range Option](#commit-range-option)
1. [Commit Range Option (Diff Scanning)](#commit-range-option-diff-scanning)
5. [Pre-Commit Scan](#pre-commit-scan)
2. [Scan Results](#scan-results)
1. [Show/Hide Secrets](#showhide-secrets)
Expand Down Expand Up @@ -552,12 +552,12 @@ The Cycode CLI application offers several types of scans so that you can choose
| `--maven-settings-file` | For Maven only, allows using a custom [settings.xml](https://maven.apache.org/settings.html) file when scanning for dependencies |
| `--help` | Show options for given command. |

| Command | Description |
|----------------------------------------|-----------------------------------------------------------------|
| [commit-history](#commit-history-scan) | Scan all the commits history in this git repository |
| [path](#path-scan) | Scan the files in the path supplied in the command |
| [pre-commit](#pre-commit-scan) | Use this command to scan the content that was not committed yet |
| [repository](#repository-scan) | Scan git repository including its history |
| Command | Description |
|----------------------------------------|-----------------------------------------------------------------------|
| [commit-history](#commit-history-scan) | Scan commit history or perform diff scanning between specific commits |
| [path](#path-scan) | Scan the files in the path supplied in the command |
| [pre-commit](#pre-commit-scan) | Use this command to scan the content that was not committed yet |
| [repository](#repository-scan) | Scan git repository including its history |

### Options

Expand Down Expand Up @@ -701,9 +701,16 @@ If you just have a configuration file, you can generate a plan by doing the foll
### Commit History Scan

> [!NOTE]
> Secrets scanning analyzes all commits in the repository history because secrets introduced and later removed can still be leaked or exposed. SCA and SAST scanning focus only on the latest code state and the changes between branches or pull requests. Full commit history scanning is not performed for SCA and SAST.
> Commit History Scan is not available for IaC scans.

A commit history scan is limited to a local repository’s previous commits, focused on finding any secrets within the commit history, instead of examining the repository’s current state.
The commit history scan command provides two main capabilities:

1. **Full History Scanning**: Analyze all commits in the repository history
2. **Diff Scanning**: Scan only the changes between specific commits

Secrets scanning can analyze all commits in the repository history because secrets introduced and later removed can still be leaked or exposed. For SCA and SAST scans, the commit history command focuses on scanning the differences/changes between commits, making it perfect for pull request reviews and incremental scanning.

A commit history scan examines your Git repository's commit history and can be used both for comprehensive historical analysis and targeted diff scanning of specific changes.

To execute a commit history scan, execute the following:

Expand All @@ -719,13 +726,55 @@ The following options are available for use with this command:
|---------------------------|----------------------------------------------------------------------------------------------------------|
| `-r, --commit-range TEXT` | Scan a commit range in this git repository, by default cycode scans all commit history (example: HEAD~1) |

#### Commit Range Option
#### Commit Range Option (Diff Scanning)

The commit range option enables **diff scanning** – scanning only the changes between specific commits instead of the entire repository history.
This is particularly useful for:
- **Pull request validation**: Scan only the changes introduced in a PR
- **Incremental CI/CD scanning**: Focus on recent changes rather than the entire codebase
- **Feature branch review**: Compare changes against main/master branch
- **Performance optimization**: Faster scans by limiting scope to relevant changes

#### Commit Range Syntax

The `--commit-range` (`-r`) option supports standard Git revision syntax:

| Syntax | Description | Example |
|---------------------|-----------------------------------|-------------------------|
| `commit1..commit2` | Changes from commit1 to commit2 | `abc123..def456` |
| `commit1...commit2` | Changes in commit2 not in commit1 | `main...feature-branch` |
| `commit` | Changes from commit to HEAD | `HEAD~1` |
| `branch1..branch2` | Changes from branch1 to branch2 | `main..feature-branch` |

#### Diff Scanning Examples

**Scan changes in the last commit:**
```bash
cycode scan commit-history -r HEAD~1 ~/home/git/codebase
```

**Scan changes between two specific commits:**
```bash
cycode scan commit-history -r abc123..def456 ~/home/git/codebase
```

The commit history scan, by default, examines the repository’s entire commit history, all the way back to the initial commit. You can instead limit the scan to a specific commit range by adding the argument `--commit-range` (`-r`) followed by the name you specify.
**Scan changes in your feature branch compared to main:**
```bash
cycode scan commit-history -r main..HEAD ~/home/git/codebase
```

Consider the previous example. If you wanted to scan only specific commits in your repository, you could execute the following:
**Scan changes between main and a feature branch:**
```bash
cycode scan commit-history -r main..feature-branch ~/home/git/codebase
```

`cycode scan commit-history -r {{from-commit-id}}...{{to-commit-id}} ~/home/git/codebase`
**Scan all changes in the last 3 commits:**
```bash
cycode scan commit-history -r HEAD~3..HEAD ~/home/git/codebase
```

> [!TIP]
> For CI/CD pipelines, you can use environment variables like `${{ github.event.pull_request.base.sha }}..${{ github.sha }}` (GitHub Actions) or `$CI_MERGE_REQUEST_TARGET_BRANCH_SHA..$CI_COMMIT_SHA` (GitLab CI) to scan only PR/MR changes.

### Pre-Commit Scan

Expand Down
2 changes: 1 addition & 1 deletion cycode/cli/apps/scan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

app.command(name='path', short_help='Scan the files in the paths provided in the command.')(path_command)
app.command(name='repository', short_help='Scan the Git repository included files.')(repository_command)
app.command(name='commit-history', short_help='Scan all the commits history in this Git repository.')(
app.command(name='commit-history', short_help='Scan commit history or perform diff scanning between specific commits.')(
commit_history_command
)
app.command(
Expand Down
Loading