Skip to content

Commit 8241439

Browse files
authored
CM-52347 - Update README to better explain diff scanning capabilities via commit range (#334)
1 parent 98070af commit 8241439

File tree

2 files changed

+63
-14
lines changed

2 files changed

+63
-14
lines changed

README.md

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This guide walks you through both installation and usage.
3535
3. [Path Scan](#path-scan)
3636
1. [Terraform Plan Scan](#terraform-plan-scan)
3737
4. [Commit History Scan](#commit-history-scan)
38-
1. [Commit Range Option](#commit-range-option)
38+
1. [Commit Range Option (Diff Scanning)](#commit-range-option-diff-scanning)
3939
5. [Pre-Commit Scan](#pre-commit-scan)
4040
2. [Scan Results](#scan-results)
4141
1. [Show/Hide Secrets](#showhide-secrets)
@@ -552,12 +552,12 @@ The Cycode CLI application offers several types of scans so that you can choose
552552
| `--maven-settings-file` | For Maven only, allows using a custom [settings.xml](https://maven.apache.org/settings.html) file when scanning for dependencies |
553553
| `--help` | Show options for given command. |
554554
555-
| Command | Description |
556-
|----------------------------------------|-----------------------------------------------------------------|
557-
| [commit-history](#commit-history-scan) | Scan all the commits history in this git repository |
558-
| [path](#path-scan) | Scan the files in the path supplied in the command |
559-
| [pre-commit](#pre-commit-scan) | Use this command to scan the content that was not committed yet |
560-
| [repository](#repository-scan) | Scan git repository including its history |
555+
| Command | Description |
556+
|----------------------------------------|-----------------------------------------------------------------------|
557+
| [commit-history](#commit-history-scan) | Scan commit history or perform diff scanning between specific commits |
558+
| [path](#path-scan) | Scan the files in the path supplied in the command |
559+
| [pre-commit](#pre-commit-scan) | Use this command to scan the content that was not committed yet |
560+
| [repository](#repository-scan) | Scan git repository including its history |
561561
562562
### Options
563563
@@ -701,9 +701,16 @@ If you just have a configuration file, you can generate a plan by doing the foll
701701
### Commit History Scan
702702
703703
> [!NOTE]
704-
> 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.
704+
> Commit History Scan is not available for IaC scans.
705705
706-
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.
706+
The commit history scan command provides two main capabilities:
707+
708+
1. **Full History Scanning**: Analyze all commits in the repository history
709+
2. **Diff Scanning**: Scan only the changes between specific commits
710+
711+
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.
712+
713+
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.
707714

708715
To execute a commit history scan, execute the following:
709716

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

722-
#### Commit Range Option
729+
#### Commit Range Option (Diff Scanning)
730+
731+
The commit range option enables **diff scanning** – scanning only the changes between specific commits instead of the entire repository history.
732+
This is particularly useful for:
733+
- **Pull request validation**: Scan only the changes introduced in a PR
734+
- **Incremental CI/CD scanning**: Focus on recent changes rather than the entire codebase
735+
- **Feature branch review**: Compare changes against main/master branch
736+
- **Performance optimization**: Faster scans by limiting scope to relevant changes
737+
738+
#### Commit Range Syntax
739+
740+
The `--commit-range` (`-r`) option supports standard Git revision syntax:
741+
742+
| Syntax | Description | Example |
743+
|---------------------|-----------------------------------|-------------------------|
744+
| `commit1..commit2` | Changes from commit1 to commit2 | `abc123..def456` |
745+
| `commit1...commit2` | Changes in commit2 not in commit1 | `main...feature-branch` |
746+
| `commit` | Changes from commit to HEAD | `HEAD~1` |
747+
| `branch1..branch2` | Changes from branch1 to branch2 | `main..feature-branch` |
748+
749+
#### Diff Scanning Examples
750+
751+
**Scan changes in the last commit:**
752+
```bash
753+
cycode scan commit-history -r HEAD~1 ~/home/git/codebase
754+
```
755+
756+
**Scan changes between two specific commits:**
757+
```bash
758+
cycode scan commit-history -r abc123..def456 ~/home/git/codebase
759+
```
723760

724-
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.
761+
**Scan changes in your feature branch compared to main:**
762+
```bash
763+
cycode scan commit-history -r main..HEAD ~/home/git/codebase
764+
```
725765

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

728-
`cycode scan commit-history -r {{from-commit-id}}...{{to-commit-id}} ~/home/git/codebase`
771+
**Scan all changes in the last 3 commits:**
772+
```bash
773+
cycode scan commit-history -r HEAD~3..HEAD ~/home/git/codebase
774+
```
775+
776+
> [!TIP]
777+
> 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.
729778

730779
### Pre-Commit Scan
731780

cycode/cli/apps/scan/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
app.command(name='path', short_help='Scan the files in the paths provided in the command.')(path_command)
2222
app.command(name='repository', short_help='Scan the Git repository included files.')(repository_command)
23-
app.command(name='commit-history', short_help='Scan all the commits history in this Git repository.')(
23+
app.command(name='commit-history', short_help='Scan commit history or perform diff scanning between specific commits.')(
2424
commit_history_command
2525
)
2626
app.command(

0 commit comments

Comments
 (0)