Add blank lines around headers

This commit is contained in:
yeasy
2026-03-24 09:27:04 -07:00
parent 857e3b73f6
commit ae8636e96f
112 changed files with 468 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ dockremap:165536:65536
```bash
$ sudo systemctl restart docker
```
#### 验证映射效果
我们可以运行一个简单的容器并执行 `sleep` 命令同时在宿主机上观察进程的所有者

View File

@@ -53,6 +53,7 @@ $ docker run --rm -it \
--security-opt apparmor=custom-nginx-profile \
nginx
```
### 18.5.3 容器镜像漏洞静态扫描
现代防护的防御已经不仅仅在运行阶段而向延伸至了构建与分发时期控制很多安全隐患并不是用户代码中的直接逻辑异常而是打包环境或者引入库的基础 `APT` 安装层面潜伏了开源界众所周知的历史漏洞

View File

@@ -41,6 +41,7 @@ trivy image --severity HIGH,CRITICAL \
--exit-code 1 \
myregistry.com/myapp:v1.0.0
```
#### Grype - 支持多种软件包的扫描器
Grype Anchore 开发支持更广泛的软件包管理器和语言
@@ -67,6 +68,7 @@ grype sbom:sbom.json
# 扫描特定目录
grype dir:/path/to/app
```
#### Snyk - 完整的安全平台
Snyk 提供了商业级的安全扫描服务特别适合企业环境
@@ -130,6 +132,7 @@ syft dir:/path/to/app -o json > sbom.json
# 从 OCI 镜像档案生成
syft oci-archive:image.tar -o json > sbom.json
```
#### CycloneDX SPDX 格式
两种主流的 SBOM 格式
@@ -173,6 +176,7 @@ syft oci-archive:image.tar -o json > sbom.json
]
}
```
#### SBOM 的应用场景
**漏洞关联**
@@ -249,6 +253,7 @@ cosign verify myregistry.com/myapp:v1.0.0 \
--certificate-identity https://github.com/myorg/myrepo/.github/workflows/build.yml@refs/heads/main \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
```
#### Docker Content Trust Notary
Docker Content Trust 使用 Notary 实现镜像签名 Docker 官方的签名解决方案
@@ -276,6 +281,7 @@ docker push --disable-content-trust myregistry.com/myapp:v1.0.0
# 查看签名信息
docker inspect --format='{{.RepoDigests}}' myregistry.com/myapp:v1.0.0
```
### 18.6.4 供应链安全最佳实践
#### 1. 基础镜像安全
@@ -289,6 +295,7 @@ RUN apt-get update && apt-get install -y curl
FROM ubuntu:22.04@sha256:a6d2b38300ce017add71440577d5b0a90460d0e6e0e14...(完整 64 位哈希)
RUN apt-get update && apt-get install -y curl=7.68.0-1ubuntu1
```
#### 2. 构建时扫描
Dockerfile 中集成安全扫描
@@ -308,6 +315,7 @@ RUN go build -o app .
FROM alpine:3.17@sha256:abcd1234...(请替换为实际完整的 64 位摘要哈希)
COPY --from=builder /app/app /app
```
#### 3. 运行时镜像扫描策略
```bash
@@ -320,6 +328,7 @@ trivy image --severity HIGH,CRITICAL \
# 定期扫描已部署的镜像
trivy image --scanners vuln,misconfig registry:5000/myapp:latest
```
#### 4. 镜像仓库安全配置
**Harbor私有镜像仓库的安全扫描**
@@ -335,6 +344,7 @@ trivy:
scan_on_push: true # 推送时自动扫描
scan_all: true # 扫描仓库中的所有镜像
```
#### 5. 政策执行
Kubernetes 环境中使用 Admission Webhook 强制镜像签名和扫描
@@ -359,6 +369,7 @@ webhooks:
admissionReviewVersions: ["v1"]
sideEffects: None
```
### 18.6.5 CI/CD 中集成安全扫描
#### GitHub Actions 工作流示例
@@ -445,6 +456,7 @@ jobs:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
```
#### GitLab CI 工作流示例
```yaml
@@ -509,6 +521,7 @@ push:
only:
- main
```
### 18.6.6 常见问题与最佳实践
**Q: 扫描报告中有过时的 CVE如何处理**

View File

@@ -23,6 +23,7 @@ flowchart LR
Proc --> Mech
end
```
## 本章内容
本章涵盖 Docker 安全的多个层面从内核隔离机制到运行时防护和供应链安全