증거

증거 수집은 DevSecOps 참조 아키텍처의 중요한 측면 중 하나입니다. 규제 준수 증거는 규제 준수 감사 중에 감사자가 검색하는 감사 추적을 작성합니다. DevSecOps의 목표 중 하나는 감사 가능한 증거 라커에서 증거 생성과 저장을 자동화하는 것입니다.

DevSecOps 파이프라인이 증거를 처리하는 방식(파일 형식 및 락커 구조)은 다음과 같습니다:

증거 작성

증거는 파이프라인 스테이지 단계(예: 단위 테스트 결과, XML 또는 JSON 파일)에서 작성한 아티팩트와 다릅니다. 각 태스크는 증거 작성, 형식화, 저장과 같은 증거를 처리하는 여러 도구에 보고해야 합니다.

일반 테스트, 검사 또는 스캔은 다음 이미지에 표시된 DevSecOps 도구 또는 파이프라인 내에서 단계를 사용하여 파이프라인 스테이지에서 증거를 생성할 수 있습니다. DevSecOps 도구는 작업 결과를 수신하고 증거를 생성한 다음 증거 보관함에 저장할 수 있어야 합니다.

증거 생성
증거 생성

증거 형식에는 태스크 결과(통과 또는 실패), 작성된 아티팩트의 링크, 태스크 결과를 기반으로 작성된 인시던트 문제의 링크가 포함됩니다.

이러한 도구는 증거 콜렉션에만 초점을 두며 빌드 프로세스의 동작을 변경하지 않습니다. 실패한 태스크 결과로 인해 DevSecOps 참조 파이프라인이 중단되지 않습니다. 검사 및 실패의 증거가 존재하고 팀에 통지되고 배치 중에 작성된 변경 요청에 이러한 문제의 증거가 표시되고 변경 요청이 수동으로 승인되는 경우, 실패한 테스트 및 취약성과 함께 이미지를 빌드하고 배치할 수 있습니다.

증거 플로우

다음 다이어그램은 증거가 처리되는 방식과 지속적 통합 및 지속적 배포 단계를 통해 증거가 어떻게 흘러가는지 보여줍니다.

증거 흐름
증거 흐름

DevOps 아키텍처의 다양한 스테이지에서 수집되는 각 증거는 감사 가능한 증거 라커에 저장됩니다. 배치 중에 이 증거를 수집하여 배치 실행 종료 시 증거 라커에 저장된 증거 요약을 작성합니다.

변경 요청 저장소에 게시된 변경 요청에 증거 요약이 첨부됩니다. 수동 변경 요청 승인 시 승인자는 빌드 중에 발견되는 모든 문제를 인식합니다.

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 자산과 같이 테스트, 스캔 등을 수행할 수 있는 항목을 나타냅니다.

EvidenceAsset 유형은 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.com/<org-name>/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.com/<org-name>/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.com/<org-name>/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.com/<org-name>/e2e-compliance-incident-issues-20220412084808401/issues/1",
    "https://github.com/<org-name>/e2e-compliance-incident-issues-20220412084808401/issues/2",
    "https://github.com/<org-name>/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.com/<org-name>/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.com/<org-name>/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.com/<org-name>/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 파이프라인은 증거 요약 문서를 작성합니다. 이 문서에는 이미지를 배포하는 각 지속적 통합 빌드 중에 생성되는 모든 증거 중 가장 최근의 증거와 배포 자체 중에 생성되는 증거가 포함되어 있습니다. 단계를 전개하는 데 필요한 변경 요청에 대한 요약이 작성됩니다.

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 증거 자료입니다.