run2_trivy-offline-scanning
Use Trivy vulnerability scanner in offline mode to scan dependency lock files and produce JSON vulnerability reports without internet access.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- run2_trivy-offline-scanning
- description
- Use Trivy vulnerability scanner in offline mode to scan dependency lock files and produce JSON vulnerability reports without internet access.
03 SKILL.md 正文
Trivy Offline Vulnerability Scanning (Round 2)
Environment Details
- Trivy binary:
/usr/bin/trivy(version 0.69.3) - Database cache:
/root/trivy-cache/(containsdb/trivy.dbanddb/metadata.json) - DB updated: 2026-01-21 (may be outdated — scan results reflect DB date)
Key Command
trivy fs /root/package-lock.json \
--format json \
--output /root/trivy_report.json \
--scanners vuln \
--skip-db-update \
--offline-scan \
--cache-dir /root/trivy-cache
Important Flags
| Flag | Purpose |
|---|---|
fs <file> |
Scan a dependency lock file directly |
--skip-db-update |
Don't fetch updated DB (offline requirement) |
--offline-scan |
Disable all network calls |
--cache-dir |
Point to offline DB location |
--scanners vuln |
Only vulnerability scanning (skip misconfig) |
Behavior Notes
- Trivy by default suppresses dev dependencies — use
--include-dev-depsif needed - Output goes to the file specified by
--output; stdout shows only progress logs - Non-zero exit code indicates scan failure (not just vulnerability presence)
Python Wrapper
import subprocess, sys, os
def run_trivy_scan(target='/root/package-lock.json',
output='/root/trivy_report.json',
cache_dir='/root/trivy-cache'):
db_path = os.path.join(cache_dir, 'db', 'trivy.db')
if not os.path.exists(db_path):
print(f"[!] DB not found at {db_path}")
sys.exit(1)
cmd = [
'trivy', 'fs', target,
'--format', 'json',
'--output', output,
'--scanners', 'vuln',
'--skip-db-update',
'--offline-scan',
'--cache-dir', cache_dir
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
print(result.stderr)
sys.exit(1)
print(f"[+] Scan complete: {output}")
return output
JSON Output Structure
{
"Results": [
{
"Target": "package-lock.json",
"Class": "lang-pkgs",
"Type": "npm",
"Vulnerabilities": [
{
"VulnerabilityID": "CVE-2024-29415",
"PkgName": "ip",
"InstalledVersion": "2.0.0",
"FixedVersion": "", // Empty string = no fix; use 'N/A'
"Severity": "HIGH",
"Title": "node-ip: Incomplete fix for CVE-2023-42282",
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2024-29415",
"CVSS": {
"ghsa": { "V3Score": 8.1 },
"redhat": { "V3Score": 9.8 }
}
}
]
}
]
}
Gotchas
FixedVersioncan beNoneOR an empty string""— handle both as 'N/A'Vulnerabilitieskey may benull(not just missing) — useor []not just.get()- Multiple fix versions are comma-separated in a single string:
"7.5.2, 6.3.1, 5.7.2"
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.