关于 vulnerability-scanning
这是一份用于识别和排序基础设施及应用漏洞的安全指南,适合开展安全评估和漏洞管理的团队。内容介绍扫描工具、风险优先级、修复跟踪及合规扫描流程。
主要功能
- 01使用 OpenVAS、Nessus 和 Nuclei 扫描
- 02编写并使用自定义 Nuclei 模板
- 03依据 CVSS 与风险因素排序
- 04在 CI/CD 中集成漏洞扫描
- 05执行 CIS 与 PCI DSS 合规扫描
适用场景
- 01评估基础设施中的已知 CVE
- 02为漏洞修复安排优先级
- 03将扫描纳入 CI/CD 流程
- 04开展合规性安全检查
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ bagelhole/ devops-security-agent-skills --skill vulnerability-scanning安装后在 Claude Code 中输入/vulnerability-scanning确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
assets/github-action-scan.yamltrivy-config.yamlreferences/remediation-guide.mdscanner-comparison.mdscripts/scan-images.shscan-repo.sh详细介绍
漏洞扫描
识别并确定基础设施和应用程序中的安全漏洞优先级。
何时使用此技能
在以下情况下使用此技能:
- 执行安全评估
- 实施漏洞管理计划
- 满足合规要求
- 对修复工作进行分类和排序
- 扫描基础设施中的已知 CVE
前提条件
- 拥有扫描工具的访问权限
- 可访问目标的网络
- 获得适当授权
漏洞扫描工具
| 工具 | 类型 | 适用场景 |
|---|---|---|
| Nessus | 商业 | 企业扫描 |
| OpenVAS | 开源 | 免费替代方案 |
| Qualys | 云端 SaaS | 大规模扫描 |
| Nexpose/InsightVM | 商业 | 资产管理 |
| Nuclei | 开源 | 基于模板的扫描 |
OpenVAS 设置
Docker 部署
# Run OpenVAS container
docker run -d --name openvas \
-p 443:443 \
-v openvas-data:/data \
greenbone/openvas-scanner
# Access web UI at https://localhost
# Default credentials: admin/admin
扫描命令
# Create target
omp -u admin -w admin --xml='<create_target>
<name>Web Servers</name>
<hosts>192.168.1.0/24</hosts>
</create_target>'
# Create task
omp -u admin -w admin --xml='<create_task>
<name>Weekly Scan</name>
<target id="target-uuid"/>
<config id="daba56c8-73ec-11df-a475-002264764cea"/>
</create_task>'
# Start task
omp -u admin -w admin --xml='<start_task task_id="task-uuid"/>'
# Get results
omp -u admin -w admin --xml='<get_results task_id="task-uuid"/>'
Nessus
API 用法
import requests
class NessusScanner:
def __init__(self, url, access_key, secret_key):
self.url = url
self.headers = {
'X-ApiKeys': f'accessKey={access_key}; secretKey={secret_key}',
'Content-Type': 'application/json'
}
def create_scan(self, name, targets, template='basic'):
"""Create a new scan."""
templates = self.get('/editor/scan/templates')
template_uuid = next(
t['uuid'] for t in templates['templates']
if t['name'] == template
)
payload = {
'uuid': template_uuid,
'settings': {
'name': name,
'text_targets': targets,
'enabled': True
}
}
return self.post('/scans', payload)
def launch_scan(self, scan_id):
"""Start a scan."""
return self.post(f'/scans/{scan_id}/launch')
def get_results(self, scan_id):
"""Get scan results."""
return self.get(f'/scans/{scan_id}')
def export_report(self, scan_id, format='pdf'):
"""Export scan report."""
payload = {'format': format}
response = self.post(f'/scans/{scan_id}/export', payload)
file_id = response['file']
# Wait for export
while True:
status = self.get(f'/scans/{scan_id}/export/{file_id}/status')
if status['status'] == 'ready':
break
time.sleep(5)
return self.get(f'/scans/{scan_id}/export/{file_id}/download')
def get(self, path):
response = requests.get(f'{self.url}{path}', headers=self.headers, verify=False)
return response.json()
def post(self, path, data=None):
response = requests.post(f'{self.url}{path}', json=data, headers=self.headers, verify=False)
return response.json()
# Usage
scanner = NessusScanner('https://nessus:8834', 'access-key', 'secret-key')
scan = scanner.create_scan('Weekly Infrastructure Scan', '10.0.0.0/24')
scanner.launch_scan(scan['scan']['id'])
Nuclei
安装
# Install nuclei
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# Or download binary
wget https://github.com/projectdiscovery/nuclei/releases/latest/download/nuclei_linux_amd64.zip
unzip nuclei_linux_amd64.zip
基本扫描
# Update templates
nuclei -update-templates
# Scan single target
nuclei -u https://example.com
# Scan multiple targets
nuclei -l targets.txt
# Scan with specific templates
nuclei -u https://example.com -t cves/
nuclei -u https://example.com -t vulnerabilities/
# Scan with severity filter
nuclei -u https://example.com -s critical,high
# Output formats
nuclei -u https://example.com -o results.txt
nuclei -u https://example.com -json -o results.json
自定义模板
# custom-check.yaml
id: custom-admin-panel
info:
name: Admin Panel Detection
author: security-team
severity: info
tags: recon,panel
requests:
- method: GET
path:
- "{{BaseURL}}/admin"
- "{{BaseURL}}/administrator"
- "{{BaseURL}}/wp-admin"
matchers-condition: or
matchers:
- type: word
words:
- "admin"
- "login"
condition: and
- type: status
status:
- 200
- 301
- 302
CVSS 评分
严重性级别
| 分数 | 评级 | 响应时间 |
|---|---|---|
| 9.0-10.0 | 严重 | 24 小时 |
| 7.0-8.9 | 高 | 7 天 |
| 4.0-6.9 | 中 | 30 天 |
| 0.1-3.9 | 低 | 90 天 |
优先级因素
prioritization_criteria:
critical_factors:
- Internet-facing systems
- Systems with sensitive data
- Active exploitation in the wild
- Authentication bypass
high_factors:
- Remote code execution
- Privilege escalation
- Data exfiltration risk
context_adjustments:
- Compensating controls in place (-1)
- No direct exposure (-1)
- Critical business system (+1)
- Compliance requirement (+1)
漏洞管理流程
工作流
vulnerability_workflow:
discovery:
- Run scheduled scans
- Import third-party findings
- Correlate with asset inventory
analysis:
- Validate findings
- Remove false positives
- Assess business impact
- Prioritize by risk score
remediation:
- Assign to owners
- Track SLA compliance
- Verify fixes
- Document exceptions
reporting:
- Executive summaries
- Technical details
- Trend analysis
- Compliance metrics
跟踪模板
## Vulnerability Ticket
**ID:** VULN-2024-001
**CVE:** CVE-2024-12345
**CVSS:** 9.8 (Critical)
**Affected System:** web-server-01
### Description
Remote code execution vulnerability in Apache Struts.
### Impact
Attacker can execute arbitrary code on the server.
### Remediation
1. Update Apache Struts to version 2.5.33
2. Apply WAF rule as temporary mitigation
### Timeline
- Discovered: 2024-01-15
- SLA Due: 2024-01-16
- Remediated: 2024-01-15
### Evidence
- Scan report: [link]
- Screenshot: [link]
CI/CD 集成
GitHub Actions
name: Vulnerability Scan
on:
schedule:
- cron: '0 2 * * *'
push:
branches: [main]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Nuclei
uses: projectdiscovery/nuclei-action@main
with:
target: https://example.com
templates: cves/
output: nuclei-results.txt
- name: Check for critical findings
run: |
if grep -q "critical" nuclei-results.txt; then
echo "Critical vulnerabilities found!"
exit 1
fi
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: vulnerability-report
path: nuclei-results.txt
合规扫描
CIS 基准扫描
# Using OpenSCAP
oscap xccdf eval \
--profile xccdf_org.ssgproject.content_profile_cis \
--results results.xml \
--report report.html \
/usr/share/xml/scap/ssg/content/ssg-ubuntu2204-ds.xml
PCI DSS 扫描
pci_scan_requirements:
quarterly:
- External vulnerability scan (ASV)
- Internal vulnerability scan
after_changes:
- Significant infrastructure changes
- New system deployments
passing_criteria:
- No vulnerabilities rated 4.0+ (CVSS)
- False positives documented
- Scan completed within 90 days
常见问题
问题:误报
问题:扫描器报告了不存在的漏洞 解决方案:手动验证、调整扫描器并维护例外列表
问题:覆盖不完整
问题:并非所有资产都经过扫描 解决方案:更新资产清单、验证凭据并检查网络访问
问题:扫描影响
问题:扫描影响生产系统 解决方案:安排在维护窗口期间扫描,并使用经过身份验证的扫描
最佳实践
- 维护准确的资产清单
- 定期安排扫描
- 在修复前验证发现的问题
- 跟踪指标(MTTR、存续时间)
- 与工单系统集成
- 妥善记录例外情况
- 根据风险确定优先级
- 尽可能实现自动化
相关技能
- sast-scanning - 代码分析
- container-scanning - 容器安全
- cis-benchmarks - 合规基准
评论
支持 Markdown