trivy-offline-vulnerability-scanning
Use Trivy vulnerability scanner in offline mode to discover security vulnerabilities in dependency files without internet access.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- trivy-offline-vulnerability-scanning
- description
- Use Trivy vulnerability scanner in offline mode to discover security vulnerabilities in dependency files without internet access.
03 SKILL.md 正文
Trivy Offline Vulnerability Scanning
Setup
Trivy requires a pre-downloaded vulnerability database for offline scanning.
Check database exists:
ls /root/trivy-cache/db/
# Should show: trivy.db metadata.json
Key Flags
| Flag | Purpose |
|---|---|
fs <target> |
Scan a file or directory |
--format json |
JSON output for parsing |
--output <file> |
Save results to file |
--scanners vuln |
Only vulnerability scanning |
--skip-db-update |
Do not update database (offline) |
--offline-scan |
Enable offline mode |
--cache-dir <path> |
Path to offline database |
--severity HIGH,CRITICAL |
Filter by severity |
Usage
import subprocess, os, sys
def run_trivy_offline_scan(target_file, output_file, cache_dir='/root/trivy-cache'):
db_path = os.path.join(cache_dir, "db", "trivy.db")
if not os.path.exists(db_path):
print(f"[!] Database not found at {db_path}")
sys.exit(1)
command = [
"trivy", "fs", target_file,
"--format", "json",
"--output", output_file,
"--scanners", "vuln",
"--skip-db-update",
"--offline-scan",
"--cache-dir", cache_dir
]
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode != 0:
print(result.stderr)
sys.exit(1)
return output_file
JSON Output Structure
{
"Results": [
{
"Target": "package-lock.json",
"Vulnerabilities": [
{
"VulnerabilityID": "CVE-2021-44906",
"PkgName": "minimist",
"InstalledVersion": "1.2.5",
"FixedVersion": "1.2.6",
"Severity": "CRITICAL",
"Title": "Prototype Pollution in minimist",
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2021-44906",
"CVSS": { "nvd": { "V3Score": 9.8 } }
}
]
}
]
}
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.