Skip to content

Commit b7d8e29

Browse files
authored
Merge pull request #137 from mongodb/development
v1.61.0
2 parents fc73ba3 + ea60add commit b7d8e29

27 files changed

+874
-217
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [v1.61.0]
6+
- Fixed local filesystem scans to keep `open_path_as_is` enabled when opening Git repositories and only disable it for diff-based scans.
7+
- Created Linux and Windows specific installer script
8+
- Updated diff-focused scanning so `--branch-root-commit` can be provided alongside `--branch`, letting you diff from a chosen commit while targeting a specific branch tip (still defaulting back to the `--branch` ref when the commit is omitted).
9+
- Updated rules
10+
511
## [v1.60.0]
612
- Removed the `--bitbucket-username`, `--bitbucket-token`, and `--bitbucket-oauth-token` flags in favour of `KF_BITBUCKET_*` environment variables when authenticating to Bitbucket.
713
- Added provider-specific `kingfisher scan` subcommands (for example `kingfisher scan github …`) that translate into the legacy flags under the hood. The new layout keeps backwards compatibility while removing the wall of provider options from `kingfisher scan --help`.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ publish = false
1010

1111
[package]
1212
name = "kingfisher"
13-
version = "1.60.0"
13+
version = "1.61.0"
1414
description = "MongoDB's blazingly fast and accurate secret scanning and validation tool"
1515
edition.workspace = true
1616
rust-version.workspace = true

README.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,32 +166,45 @@ brew install kingfisher
166166

167167
<details>
168168

169-
You can easily install using [ubi](https://github.com/houseabsolute/ubi), which downloads the correct binary for your platform.
169+
Use the bundled installer script to fetch the latest release and place it in
170+
`~/.local/bin` (or a directory of your choice):
170171

171172
```bash
172173
# Linux, macOS
173174
curl --silent --location \
174-
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh | \
175-
sh && \
176-
ubi --project mongodb/kingfisher --in "$HOME/.local/bin"
175+
https://raw.githubusercontent.com/mongodb/kingfisher/main/scripts/install-kingfisher.sh | \
176+
bash
177177
```
178178

179-
This installs and runs `ubi` and then places the `kingfisher` executable in `~/.local/bin` on Unix-like systems.
179+
To install into a custom location, pass the desired directory as an argument:
180+
181+
```bash
182+
curl --silent --location \
183+
https://raw.githubusercontent.com/mongodb/kingfisher/main/scripts/install-kingfisher.sh | \
184+
bash -s -- /opt/kingfisher
185+
```
180186

181187
</details>
182188

183189
### Windows
184190

185191
<details>
186192

187-
You can easily install using [ubi](https://github.com/houseabsolute/ubi), which downloads the correct binary for your platform.
193+
Download and run the PowerShell installer to place the binary in
194+
`$env:USERPROFILE\bin` (or another directory you specify):
188195

189196
```powershell
190197
# Windows
191-
powershell -exec bypass -c "Invoke-WebRequest -URI 'https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.ps1' -UseBasicParsing | Invoke-Expression" && ubi --project mongodb/kingfisher --in .
198+
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
199+
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/mongodb/kingfisher/main/scripts/install-kingfisher.ps1' -OutFile install-kingfisher.ps1
200+
./install-kingfisher.ps1
192201
```
193202

194-
This installs and runs `ubi` and then places the `kingfisher` executable in the current directory on Windows.
203+
You can provide a custom destination using the `-InstallDir` parameter:
204+
205+
```powershell
206+
./install-kingfisher.ps1 -InstallDir 'C:\Tools\Kingfisher'
207+
```
195208
</details>
196209

197210

@@ -415,6 +428,11 @@ kingfisher scan ./my-project \
415428

416429
Limit scanning to the delta between your default branch and a pull request branch by combining `--since-commit` with `--branch` (defaults to `HEAD`). This only scans files that differ between the two references, which keeps CI runs fast while still blocking new secrets.
417430

431+
Use `--branch-root-commit` alongside `--branch` when you need to include a specific commit (and everything after it) in a diff-focused scan without re-examining earlier history. Provide the branch tip (or other comparison ref) via `--branch`, and pass the commit or merge-base you want to include with `--branch-root-commit`. If you omit `--branch-root-commit`, you can still enable `--branch-root` to fall back to treating the `--branch` ref itself as the inclusive root for backwards compatibility. This is especially useful in long-lived branches where you want to resume scanning from a previous review point or from the commit where a hotfix forked.
432+
433+
> **How is this different from `--since-commit`?**
434+
> `--since-commit` computes a diff between the branch tip and another ref, so it only inspects files that changed between those two points in history. `--branch-root-commit` rewinds to the parent of the commit you provide and then scans everything introduced from that commit forward, even if the files are unchanged relative to another baseline. Reach for `--since-commit` to keep CI scans fast by checking only the latest delta, and use `--branch-root-commit` when you want to re-audit the full contents of a branch starting at a specific commit.
435+
418436
```bash
419437
kingfisher scan . \
420438
--since-commit origin/main \
@@ -434,8 +452,21 @@ kingfisher scan /tmp/SecretsTest --branch feature-1 \
434452
--since-commit=$(git -C /tmp/SecretsTest merge-base main feature-1)
435453
#
436454
# scan only a specific commit
437-
kingfisher scan /tmp/dev/SecretsTest \
455+
kingfisher scan /tmp/SecretsTest \
438456
--branch baba6ccb453963d3f6136d1ace843e48d7007c3f
457+
#
458+
# scan feature-1 starting at a specific commit (inclusive)
459+
kingfisher scan /tmp/SecretsTest --branch feature-1 \
460+
--branch-root-commit baba6ccb453963d3f6136d1ace843e48d7007c3f
461+
#
462+
# scan feature-1 starting from the commit where the branch diverged from main
463+
kingfisher scan /tmp/SecretsTest --branch feature-1 \
464+
--branch-root-commit $(git -C /tmp/SecretsTest merge-base main feature-1)
465+
#
466+
# scan from a hotfix commit that should be re-checked before merging
467+
HOTFIX_COMMIT=$(git -C /tmp/SecretsTest rev-parse hotfix~1)
468+
kingfisher scan /tmp/SecretsTest --branch hotfix \
469+
--branch-root-commit "$HOTFIX_COMMIT"
439470
```
440471

441472
When the branch under test is already checked out, `--branch HEAD` or omitting `--branch` entirely is sufficient. Kingfisher exits with `200` when any findings are discovered and `205` when validated secrets are present, allowing CI jobs to fail automatically if new credentials slip in.

data/rules/azurestorage.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@ rules:
44
pattern: |
55
(?xi)
66
(?:
7-
\b
8-
azure
9-
(?:.|[\n\r]){0,32}?
10-
(?i:
11-
(?:Account|Storage)
12-
(?:[._-]Account)?
13-
[._-]?Name
14-
)
15-
(?:.|[\n\r]){0,20}?
16-
([a-z0-9]{3,24})
7+
# A) Connection string: AccountName=<name>
8+
(?i:AccountName)\s*=\s*([a-z0-9]{3,24})(?:\b|[^a-z0-9])
9+
10+
|
11+
# B) Blob endpoint URL: <name>.blob.core.windows.net
12+
([a-z0-9]{3,24})\.blob\.core\.windows\.net\b
13+
1714
|
18-
([a-z0-9]{3,24})
19-
(?i:\.blob\.core\.windows\.net)
20-
)\b
21-
min_entropy: 2.5
15+
# C) Explicit KV labels near 'azure storage/account name' with tight separators
16+
\bazure(?:[_\s-]*)(?:storage|account)(?:[_\s-]*)(?:name)\b
17+
[\s:=\"']{0,6}
18+
([a-z0-9]{3,24})(?:\b|[^a-z0-9])
19+
)
20+
min_entropy: 2.0
2221
visible: false
2322
confidence: medium
2423
examples:
25-
- azure_storage_name=mystorageaccount123
24+
- AccountName=mystorageaccount
2625
- mystorageaccount.blob.core.windows.net
27-
26+
- azure_storage_name="prodblob2024"
2827
- name: Azure Storage Account Key
2928
id: kingfisher.azurestorage.2
3029
pattern: |
@@ -45,4 +44,4 @@ rules:
4544
type: AzureStorage
4645
depends_on_rule:
4746
- rule_id: kingfisher.azurestorage.1
48-
variable: AZURENAME
47+
variable: AZURENAME

data/rules/gitlab.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ rules:
33
id: kingfisher.gitlab.1
44
pattern: |
55
(?xi)
6-
\b
7-
(
6+
\b
7+
(
88
glpat-
99
[0-9A-Z_-]{20}
10-
)
11-
(?:\b|$)
10+
)
1211
min_entropy: 3.5
1312
confidence: medium
1413
examples:
@@ -114,4 +113,32 @@ rules:
114113
- '"token is missing"'
115114
- '"403 Forbidden"'
116115
negative: true
117-
url: https://gitlab.com/api/v4/ci/pipeline_triggers/{{ TOKEN }}
116+
url: https://gitlab.com/api/v4/ci/pipeline_triggers/{{ TOKEN }}
117+
- name: GitLab Private Token - Updated Format
118+
id: kingfisher.gitlab.4
119+
pattern: |
120+
(?x)
121+
\b
122+
(
123+
glpat-[A-Za-z0-9_-]{36,38}\.01\.[a-z0-9]{9}
124+
)
125+
min_entropy: 3.5
126+
confidence: medium
127+
examples:
128+
- glpat-5m8CwMZi4bwlRSCKzG0-3W86MQp1OmV5Y2UK.01.1012mzo24
129+
references:
130+
- https://github.com/diffblue/gitlab/blob/39c63ee83369bf5353256a6b95f3116728edd102/doc/api/personal_access_tokens.md
131+
- https://docs.gitlab.com/api/personal_access_tokens/
132+
validation:
133+
type: Http
134+
content:
135+
request:
136+
headers:
137+
PRIVATE-TOKEN: '{{ TOKEN }}'
138+
method: GET
139+
response_matcher:
140+
- report_response: true
141+
- type: WordMatch
142+
words:
143+
- '"id"'
144+
url: https://gitlab.com/api/v4/personal_access_tokens/self

data/rules/vercel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rules:
88
(?:.|[\n\r]){0,32}?
99
\b
1010
(
11-
[a-zA-Z0-9]{24}
11+
[A-Z0-9]{24}
1212
)
1313
\b
1414
confidence: medium

scripts/install-kingfisher.ps1

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<#
2+
.SYNOPSIS
3+
Download and install the latest Kingfisher release for Windows.
4+
5+
.DESCRIPTION
6+
Fetches the most recent GitHub release for mongodb/kingfisher, downloads the
7+
Windows x64 archive, and extracts kingfisher.exe to the destination folder.
8+
By default the script installs into "$env:USERPROFILE\bin".
9+
10+
.PARAMETER InstallDir
11+
Optional destination directory for the kingfisher.exe binary.
12+
13+
.EXAMPLE
14+
./install-kingfisher.ps1
15+
16+
.EXAMPLE
17+
./install-kingfisher.ps1 -InstallDir "C:\\Tools"
18+
#>
19+
param(
20+
[Parameter(Position = 0)]
21+
[string]$InstallDir = (Join-Path $env:USERPROFILE 'bin')
22+
)
23+
24+
$repo = 'mongodb/kingfisher'
25+
$apiUrl = "https://api.github.com/repos/$repo/releases/latest"
26+
$assetName = 'kingfisher-windows-x64.zip'
27+
28+
if (-not (Get-Command Invoke-WebRequest -ErrorAction SilentlyContinue)) {
29+
throw 'Invoke-WebRequest is required to download releases.'
30+
}
31+
32+
if (-not (Get-Command Expand-Archive -ErrorAction SilentlyContinue)) {
33+
throw 'Expand-Archive is required to extract the release archive. Install the PowerShell archive module.'
34+
}
35+
36+
Write-Host "Fetching latest release metadata for $repo"
37+
try {
38+
$response = Invoke-WebRequest -Uri $apiUrl -UseBasicParsing
39+
$release = $response.Content | ConvertFrom-Json
40+
} catch {
41+
throw "Failed to retrieve release information from GitHub: $_"
42+
}
43+
44+
$releaseTag = $release.tag_name
45+
$asset = $release.assets | Where-Object { $_.name -eq $assetName }
46+
if (-not $asset) {
47+
throw "Could not find asset '$assetName' in the latest release."
48+
}
49+
50+
$tempDir = New-Item -ItemType Directory -Path ([System.IO.Path]::GetTempPath()) -Name ([System.Guid]::NewGuid().ToString())
51+
$archivePath = Join-Path $tempDir.FullName $assetName
52+
53+
try {
54+
if ($releaseTag) {
55+
Write-Host "Latest release: $releaseTag"
56+
}
57+
58+
Write-Host "Downloading $assetName"
59+
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $archivePath -UseBasicParsing
60+
61+
Write-Host 'Extracting archive…'
62+
Expand-Archive -Path $archivePath -DestinationPath $tempDir.FullName -Force
63+
64+
$binaryPath = Join-Path $tempDir.FullName 'kingfisher.exe'
65+
if (-not (Test-Path $binaryPath)) {
66+
throw 'Extracted archive did not contain kingfisher.exe.'
67+
}
68+
69+
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
70+
$destination = Join-Path $InstallDir 'kingfisher.exe'
71+
Copy-Item -Path $binaryPath -Destination $destination -Force
72+
73+
Write-Host "Kingfisher installed to: $destination"
74+
Write-Host "Ensure '$InstallDir' is in your PATH environment variable."
75+
}
76+
finally {
77+
if ($tempDir -and (Test-Path $tempDir.FullName)) {
78+
Remove-Item -Path $tempDir.FullName -Recurse -Force
79+
}
80+
}

scripts/install-kingfisher.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
REPO="mongodb/kingfisher"
5+
DEFAULT_INSTALL_DIR="$HOME/.local/bin"
6+
LATEST_DL_BASE="https://github.com/${REPO}/releases/latest/download"
7+
8+
usage() {
9+
cat <<'USAGE'
10+
Usage: install-kingfisher.sh [INSTALL_DIR]
11+
12+
Downloads the latest Kingfisher release for Linux or macOS and installs the
13+
binary into INSTALL_DIR (default: ~/.local/bin).
14+
15+
Requirements: curl, tar
16+
USAGE
17+
}
18+
19+
if [[ "${1-}" == "-h" || "${1-}" == "--help" ]]; then
20+
usage
21+
exit 0
22+
fi
23+
24+
INSTALL_DIR="${1:-$DEFAULT_INSTALL_DIR}"
25+
26+
# deps
27+
command -v curl >/dev/null 2>&1 || { echo "Error: curl is required." >&2; exit 1; }
28+
command -v tar >/dev/null 2>&1 || { echo "Error: tar is required." >&2; exit 1; }
29+
30+
OS="$(uname -s)"
31+
ARCH="$(uname -m)"
32+
33+
case "$OS" in
34+
Linux) platform="linux" ;;
35+
Darwin) platform="darwin" ;;
36+
*) echo "Error: Unsupported OS '$OS' (Linux/macOS only)." >&2; exit 1 ;;
37+
esac
38+
39+
case "$ARCH" in
40+
x86_64|amd64) arch_suffix="x64" ;;
41+
arm64|aarch64) arch_suffix="arm64" ;;
42+
*) echo "Error: Unsupported arch '$ARCH' (x86_64/amd64, arm64/aarch64 only)." >&2; exit 1 ;;
43+
esac
44+
45+
asset_name="kingfisher-${platform}-${arch_suffix}.tgz"
46+
: "${asset_name:?internal error: asset_name not set}" # guard for set -u
47+
48+
download_url="${LATEST_DL_BASE}/${asset_name}"
49+
50+
tmpdir="$(mktemp -d)"
51+
cleanup() { rm -rf "$tmpdir"; }
52+
trap cleanup EXIT
53+
54+
archive_path="$tmpdir/$asset_name"
55+
56+
echo "Downloading latest: ${asset_name}"
57+
# -f: fail on HTTP errors (e.g., 404 if asset missing)
58+
if ! curl -fLsS "${download_url}" -o "$archive_path"; then
59+
echo "Error: Failed to download ${download_url}" >&2
60+
echo "Tip: Ensure the release includes '${asset_name}'." >&2
61+
exit 1
62+
fi
63+
64+
echo "Extracting archive…"
65+
tar -C "$tmpdir" -xzf "$archive_path"
66+
67+
if [[ ! -f "$tmpdir/kingfisher" ]]; then
68+
echo "Error: Extracted archive did not contain the 'kingfisher' binary." >&2
69+
exit 1
70+
fi
71+
72+
mkdir -p "$INSTALL_DIR"
73+
install -m 0755 "$tmpdir/kingfisher" "$INSTALL_DIR/kingfisher"
74+
75+
printf 'Kingfisher installed to: %s/kingfisher\n\n' "$INSTALL_DIR"
76+
if ! command -v kingfisher >/dev/null 2>&1; then
77+
printf 'Add this to your shell config if %s is not on PATH:\n export PATH="%s:$PATH"\n' "$INSTALL_DIR" "$INSTALL_DIR"
78+
fi

0 commit comments

Comments
 (0)