mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-12 11:47:11 +00:00
feat(security): secret and misconfiguration scanning (#651)
Extends Trivy scans with secret detection in image filesystems and misconfiguration scanning for Compose stacks. Adds tabs to the scan drawer for vulnerabilities, secrets, and misconfigs. Secret matches are redacted server-side (first 8 chars + ellipsis) before storage. - TrivyService: --scanners vuln,secret for images; trivy config for stacks - DB: scanners_used/secret_count/misconfig_count cols; secret_findings, misconfig_findings tables; cache key scoped by scanners - Routes: POST /security/scan accepts scanners array (requirePaid when secret requested); POST /security/scan/stack; GET .../secrets and .../misconfigs (paid-tier reads) - UI: tabs in VulnerabilityScanSheet; scan-options dropdown on images; Scan config button on stack header
This commit is contained in:
@@ -25,13 +25,17 @@ The Trivy CLI must be available on the machine running Sencho. Trivy is not bund
|
||||
| Scan policies (warning and critical alerts) | | ✓ | ✓ |
|
||||
| SBOM generation (SPDX, CycloneDX) | | ✓ | ✓ |
|
||||
| Scan history and comparison | | ✓ | ✓ |
|
||||
| Secret detection in image filesystems | | ✓ | ✓ |
|
||||
| Compose file misconfiguration scanning | | ✓ | ✓ |
|
||||
|
||||
## On-demand scanning
|
||||
|
||||
Navigate to the **Resources** tab and open the **Images** panel. When Trivy is available, every image row shows a shield icon alongside the delete action.
|
||||
|
||||
1. Click the shield icon on any image row to start a scan.
|
||||
2. The row shows a loading spinner while Trivy runs. Most scans finish in 10 to 60 seconds depending on image size and whether the Trivy database is already cached.
|
||||
1. Click the shield icon on any image row. A menu appears with two options:
|
||||
- **Scan (vulnerabilities)**: the default, fastest path. Trivy inspects package metadata only.
|
||||
- **Full scan (vulnerabilities + secrets)**: additionally walks the image filesystem for hardcoded credentials, tokens, and keys. This takes noticeably longer.
|
||||
2. The row shows a loading spinner while Trivy runs. Most vulnerability scans finish in 10 to 60 seconds depending on image size and whether the Trivy database is already cached. Full scans add the time needed to read the filesystem.
|
||||
3. When the scan completes, a severity badge appears next to the image status (e.g. `CRITICAL`, `HIGH`, `MEDIUM`, `LOW`, or `CLEAN`).
|
||||
4. Click the badge to open the scan results drawer.
|
||||
|
||||
@@ -55,15 +59,16 @@ Scan results are cached by image digest. If the same digest is scanned again wit
|
||||
|
||||
## The scan results drawer
|
||||
|
||||
The drawer shows a full breakdown of the most recent scan for an image:
|
||||
The drawer shows a full breakdown of the most recent scan for an image and groups findings across three tabs: **Vulnerabilities**, **Secrets**, and **Misconfigs**. The summary header shows counts across all three so you can see the full risk picture at a glance.
|
||||
|
||||
- **Summary**: counts per severity (critical, high, medium, low), total vulnerabilities, how many have a fix available, the Trivy version used, and when the scan ran.
|
||||
- **Filter tabs**: narrow the table to a specific severity.
|
||||
- **Vulnerability table**: paginated list of every CVE found, including:
|
||||
- **Vulnerabilities tab**: severity filter pills narrow the table, paginated list of every CVE found, including:
|
||||
- **CVE ID** (linked to the upstream advisory)
|
||||
- **Package** name and installed version
|
||||
- **Severity** badge
|
||||
- **Fixed version** with a green indicator if a fix is available
|
||||
- **Secrets tab**: hardcoded credentials or keys detected in the image filesystem, with severity, rule, title, and the file/line location. Secret values are redacted: only the first eight characters of the match are stored.
|
||||
- **Misconfigs tab**: misconfiguration findings with severity, check ID, title, target file, and a suggested resolution. For image scans this tab is empty; for stack config scans (see below) it is the primary view.
|
||||
|
||||
### Actions
|
||||
|
||||
@@ -163,6 +168,47 @@ From the scan results drawer, click **Download SBOM** and choose a format:
|
||||
|
||||
The download starts immediately and uses the image's digest (when available) in the filename.
|
||||
|
||||
## Secret detection
|
||||
|
||||
<Note>
|
||||
Secret detection requires a **Skipper** or **Admiral** license.
|
||||
</Note>
|
||||
|
||||
Full scans ask Trivy to walk the image filesystem for patterns that look like hardcoded credentials, API tokens, cloud access keys, or private keys. Detection rules cover common providers (AWS, GCP, GitHub, Slack, Stripe) plus generic high-entropy strings.
|
||||
|
||||
To run a full scan, click the shield icon in the Resources Hub and pick **Full scan (vulnerabilities + secrets)**. Findings appear on the **Secrets** tab of the scan drawer:
|
||||
|
||||
| Column | Description |
|
||||
|--------|-------------|
|
||||
| **Severity** | Trivy-assigned severity for the rule that matched. |
|
||||
| **Rule** | The detection rule identifier (e.g. `aws-access-key-id`). |
|
||||
| **Title** | A short description of what was detected. The second line shows a redacted excerpt of the match. |
|
||||
| **Target** | The file path inside the image filesystem, including the line number range when available. |
|
||||
|
||||
Only the first eight characters of any matched secret are stored, followed by an ellipsis. The full value is never written to the database, so exporting a scan drawer or comparing scans cannot leak the underlying credential.
|
||||
|
||||
Full scans take longer than vulnerability-only scans because Trivy reads every file in the image. If runtime is a concern, schedule full scans overnight and keep deploy-time scans on the default vulnerability-only setting.
|
||||
|
||||
## Compose misconfiguration scanning
|
||||
|
||||
<Note>
|
||||
Compose misconfiguration scanning requires a **Skipper** or **Admiral** license.
|
||||
</Note>
|
||||
|
||||
Beyond package CVEs, Sencho can run `trivy config` against a stack's Compose file to flag insecure defaults before you deploy. Typical checks include containers running as root, missing resource limits, privileged mode, host network, and mounted Docker sockets.
|
||||
|
||||
From any stack page, click **Scan config** next to the Deploy controls. Sencho runs the scanner against the stack's working directory and opens the scan drawer on the **Misconfigs** tab:
|
||||
|
||||
| Column | Description |
|
||||
|--------|-------------|
|
||||
| **Severity** | Rule severity (CRITICAL/HIGH/MEDIUM/LOW). |
|
||||
| **Check** | Rule ID or AVD identifier for the violated check. |
|
||||
| **Title** | Short summary, linked to the upstream advisory when available. The second line shows Trivy's detailed message. |
|
||||
| **Target** | The file that triggered the finding. |
|
||||
| **Fix** | The recommended resolution. |
|
||||
|
||||
Config scans are stored in the same history as image scans with an `image_ref` of `stack:<name>`, so they appear on the Scan history page and can be exported as CSV.
|
||||
|
||||
## Scan history
|
||||
|
||||
Every scan Sencho runs is stored with its full vulnerability detail. Scan records are automatically pruned after 90 days to keep the database compact. The history is used to power:
|
||||
@@ -241,3 +287,15 @@ Scan policies are managed from the control Sencho instance and replicate to ever
|
||||
### I suppressed a CVE but the scan badge count is unchanged
|
||||
|
||||
Badge counts reflect the raw findings so alerting and policy evaluation stay accurate. Open the scan drawer to confirm the row is dimmed with a shield-off icon. See [CVE Suppressions](/features/cve-suppressions) for how the filter is applied across the drawer, compare sheet, and other read surfaces.
|
||||
|
||||
### The Secrets tab is empty on an image I expect to contain credentials
|
||||
|
||||
Secret detection matches against Trivy's built-in rule set, which focuses on well-known provider patterns. Plain text passwords, custom token formats, or values that do not match any published rule will not appear. Ensure you picked **Full scan (vulnerabilities + secrets)** from the shield-icon menu; a plain vulnerability scan does not walk the filesystem.
|
||||
|
||||
### Scan config button is disabled on a stack
|
||||
|
||||
The button is only shown when Trivy is available on the stack's node, the current user is an admin, and the license is Skipper or Admiral. If all three conditions are met but the button stays disabled, another stack action (deploy, update, rollback) is still in progress; wait for it to finish.
|
||||
|
||||
### Compose misconfiguration scan returns 404
|
||||
|
||||
The scanner needs to locate a Compose file in the stack directory. If the stack was created outside Sencho and the working directory does not contain a file named `compose.yml`, `compose.yaml`, `docker-compose.yml`, or `docker-compose.yaml`, the scan returns 404. Name the file accordingly or keep the stack under Sencho's managed compose directory.
|
||||
|
||||
Reference in New Issue
Block a user