证据
收集证据是DevSecOps参考架构的重要方面之一。 合规性证据将创建审计人员在合规性审计期间查找的审计跟踪。 DevSecOps的目标之一是自动生成证据并将其存储在可审计的证据柜中。
DevSecOps 管道处理证据(文件格式和锁定器结构)的方式是:
- v2 证据 (基于资产的证据)
证据创建
证据与管道阶段步骤 (例如单元测试结果或 XML 或 JSON 文件) 创建的工件不同。 每个任务都必须向多个处理证据 (例如,创建,格式化和存储证据) 的工具报告。
通过使用DevSecOps工具或管道中的步骤,任何通用测试、检查或扫描都能在管道阶段产生证据,如下图所示。 DevSecOps工具必须能够接收任务结果、创建证据,然后将其存储在证据柜中。
证据格式包含任务的结果 (传递或失败),指向已创建工件的链接以及指向基于任务结果创建的任何突发事件问题的链接。
这些工具仅关注证据收集,不会更改构建过程的行为。 DevSecOps参考管道不会因任务结果失败而中断。 如果存在检查和失败的证据,团队收到通知,在部署期间创建的变更请求显示这些问题的证据,并且手动核准变更请求,那么可以使用失败的测试和漏洞来构建和部署映像。
证据流
下图显示了如何处理证据以及证据如何流经持续集成和持续部署阶段。
在 DevOps 体系结构的各个阶段中收集的每个证据都存储在可审计的证据锁定程序中。 在部署期间,将收集此证据以创建在部署运行结束时保存到证据锁定程序的证据摘要。
证据摘要将附加到发布到变更请求存储库的变更请求。 在手动变更请求核准期间,核准人了解构建期间发现的任何问题。 此外,还会将摘要提交到 Security and Compliance Center。
v2 证据 (当前格式)
v2 证据锁定程序
证据存储在一个扁平的层次结构中,每个证据都有自己的 SHA256 哈希值,这就提供了一层完整性保护(即证据内容的任何修改都能被检测到)。 由于每个证据都与一个或多个资产相关,因此证据汇总算法会根据资产发现相关证据。
唯一的层次结构是类型区分和一些类似于 Git 散列对象结构的散列分组。
示例
.
└── raw/
├── assets/
│ └── xx/
│ └── abcdef123456789/
│ ├── evidences/
│ │ ├── 00abcdef123456789
│ │ └── 01abcdef123456789
│ └── index.json
├── attachments/
│ ├── aa/
│ │ └── abcdef123456789/
│ │ └── content
│ └── ab/
│ └── abcdef123456789/
│ └── content
├── cd/
│ ├── c9b77749-fd59-4d32-bbdb-18e55db1615d/
│ └── summary.json
| └── evdience-checks.json
├── cc/
│ ├── absd7749-fd59-4d32-bbdb-18e55db1615d/
│ └── summary.json
| └── evdience-checks.json
└── evidences/
├── 00/
│ └── abcdef123456789/
│ └── index.json
└── 01 /
└── abcdef123456789/
└── index.json
v2 证据收集
v2 证据必须尽可能靠近为证据创建结果的过程进行收集。 在每次扫描运行之后,例如在每次测试之后。
为收集证据,可在DevSecOps管道中使用 collect-evidence 脚本。
v2 证据格式
一个证据表示扫描,测试等结果。 证据始终至少连接到单个资产。 允许多个资产,例如可能一起测试多个资产的单个端到端测试套件。
资产表示可以测试,扫描等的内容,例如存储库中的 Git commit,Docker image 或具有 URI 的任何 generic 资产。
Evidence 和 Asset 类型表示 v2 锁定程序元素 (证据和资产) 的模式。 虽然模式使用 typescript 语法,但您可以将其转换为使用 JSON 模式。
type SHA1 = string; // 40 character string representing a SHA-1 hash in hexadecimal format
type SHA256 = string; // 64 character string representing a SHA256 hash in hexadecimal format
type IssueURL = string; // Link to issues on a git service provide like GitHub or GitLab
type RepositoryURL = string; // Link to a git repository
type AssetURI = string; // URI of an Asset, like an image or a repository link and git hash
type FileName = string; // file basename of the attachment
interface Evidence {
version: 2;
id: SHA256;
date: string;
evidence_type_id: string;
evidence_type_version: string;
origin: {
// scope defines a contextual set for multiple evidence, usually a SHA256 identifier or a CI/CD run ID
scope: SHA256;
// any further IDs can be used to determine evidence origin, see example
[index: string]: string;
},
details: {
result: 'success' | 'failure' | 'pending';
tool: string;
// field "details" can have any arbitrary key-value pairs to provide metadata
[index: string]: string;
}
attachments: Record<string, string> | EvidenceAssetAttachment[];
assets: string[] | EvidenceAssetAttachment[];
issues: IssueURL[],
findings?: IncidentFinding[];
}
export interface IncidentFinding {
id: string;
url: string;
due_date: string;
first_found?: string;
severity: ("high", "medium", "low", "critical, "informational");
has_exempt: boolean;
found_status: ("new", "existing", "autoclosed", "readonly");
}
export interface EvidenceAssetAttachment {
url: string; // hash of the asset or attachment
hash: string; // complete url of the asset or attachment
uri?: string; // name of the asset
}
interface Asset {
version: 1;
id: SHA256;
uri: AssetURI;
date: string;
type: 'commit' | 'image' | 'generic';
origin: {
// any IDs can be used to determine asset origin, see example
[index: string]: string;
},
details: Record<string, string>,
// Assets can relate to each other, for example
// an Image Asset can relate to the Git Commit Asset
// it was built from on code level
related: SHA256[];
}
示例
示例 v2 资产
{
"version": "1",
"id": "cdd3ee20188d2f5bfb7f14bdb9c7fa99b22184ca195d9fa0a953dfbe9b1769cb",
"uri": "https://github.ibm.com/cocoa-test/e2e-hello-compliance-app-20220412084808399.git#8c2a65373cb4fd27bccff646e8bdf63d02cae856",
"origin": {
"toolchain_crn": "crn:v1:bluemix:public:toolchain:us-south:a/40111714589c4f7099032529b26a7a63:fd3f2bf6-00f1-417f-b1a2-7df894223115::",
"pipeline_run_id": "a5e89ecc-a413-4dcb-b129-ff870ef3be85",
"pipeline_id": "66b583d9-3d1b-4b34-9e3a-cb807bf0c5ab"
},
"details": {
"sha": "8c2a65373cb4fd27bccff646e8bdf63d02cae856",
"repository": "https://github.ibm.com/cocoa-test/e2e-hello-compliance-app-20220412084808399.git"
},
"date": "2022-04-20T09:26:46.226Z",
"type": "commit",
"related": [
"26a0f02126461e6505d5001d50ac71e585c280479a01cc70e36397a784440bf8"
]
}
示例 v2 证据
{
"version": "2",
"id": "3fd209270fbaf46137ec3966affac2a431a835e750301c7c44d583e0e426e29e",
"date": "2022-04-20T09:33:43.782Z",
"evidence_type_id": "com.ibm.code_vulnerability_scan",
"evidence_type_version": "1.0.0",
"details": {
"result": "failure",
"tool": "cra"
},
"origin": {
"toolchain_crn": "crn:v1:bluemix:public:toolchain:us-south:a/779c0808c946b9e15cc2e63013fded8c:68213c68-4794-4d5e-ab50-f33d0d6190e4::",
"pipeline_id": "c17f18a6-24dd-4949-abb7-2b374f4691b6",
"pipeline_run_id": "d7a88836-72a1-402b-bb28-701439a543ae",
"pipeline_run_url": "https://cloud.ibm.com/devops/pipelines/tekton/c17f18a6-24dd-4949-abb7-2b374f4691b6/runs/d7a88836-72a1-402b-bb28-701439a543ae/code-compliance-checks/run-stage/?env_id=ibm:yp:us-south",
"scope": "117458e26512b0308d93cf6852958e5e875294a982d2b4ea2e9f463b4551a846"
},
"assets": [
{
"hash": "cdd3ee20188d2f5bfb7f14bdb9c7fa99b22184ca195d9fa0a953dfbe9b1769cb",
"uri": "https://github.ibm.com/cocoa-test/e2e-hello-compliance-app-20220412084808399.git#8c2a65373cb4fd27bccff646e8bdf63d02cae856",
"url": "https://s3.private.us-south.cloud-object-storage.appdomain.cloud/test/assets/cdd3ee20188d2f5bfb7f14bdb9c7fa99b22184ca195d9fa0a953dfbe9b1769cb/index.json"
}
],
"issues": [
"https://github.ibm.com/cocoa-test/e2e-compliance-incident-issues-20220412084808401/issues/1",
"https://github.ibm.com/cocoa-test/e2e-compliance-incident-issues-20220412084808401/issues/2",
"https://github.ibm.com/cocoa-test/e2e-compliance-incident-issues-20220412084808401/issues/3",
],
"findings": [
{
"id": "CVE-2022-42011",
"due_date": "2024-04-20",
"severity": "medium",
"first_found": "2024-03-06",
"url": "https://github.ibm.com/cocoa-test/e2e-compliance-incident-issues-20220412084808401/issues/3",
"found_status": "new",
"has_exempt": true
},
{
"id": "CVE-2022-42010",
"due_date": "2024-04-20",
"severity": "medium",
"first_found": "2024-03-06",
"url": "https://github.ibm.com/cocoa-test/e2e-compliance-incident-issues-20220412084808401/issues/1",
"found_status": "existing",
"has_exempt": false
},
{
"id": "CVE-2023-34969",
"due_date": "2024-04-20",
"severity": "medium",
"first_found": "2024-03-06",
"url": "https://github.ibm.com/cocoa-test/e2e-compliance-incident-issues-20220412084808401/issues/2",
"found_status": "existing",
"has_exempt": true
}
],
"attachments": [
{
"hash": "9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b",
"url": "https://s3.private.us-south.cloud-object-storage.appdomain.cloud/test/assets/9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b/index.json"
}
]
}
v2 证据摘要
DevSecOps管道会创建一份证据摘要文件。 此文档包含在部署映像的每个持续集成构建期间创建的所有最新证据,以及在部署本身期间创建的证据。 将为部署任何阶段所需的变更请求创建摘要。 Security and Compliance Center 集成尚不支持此证据格式。
interface Summary {
version: '2.0'; // schema version
date: string; // ISO-8601, UTC, ie. YYYY-MM-DDThh:mm:ssZ
toolchain_crn: string; // CRN of the toolchain that generated the summary
pipeline_id: string; // ID of the pipeline that generated the summary
pipeline_run_id: string; // ID of the pipeline run that generated the summary
evidences: Evidence[];
}
此摘要不会执行任何结果聚集。 这是收集的 v2 证据的原始数据,因为找到了与变更请求相关的资产的这些证据。