Skip to content

Commit f0403b1

Browse files
committed
Adding more details
1 parent 15fdf88 commit f0403b1

File tree

1 file changed

+48
-25
lines changed

1 file changed

+48
-25
lines changed

docs/adrs/00014-enterprise-contract-integration.md

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ An EC Wrapper (HTTP service) acts as a proxy between Trustify's EC service and C
3434

3535
Each SBOM + policy pair has a validation state that follows this lifecycle:
3636

37-
- **Pending** — initial state, set when an SBOM is associated with a policy (e.g., a default policy assigned at SBOM upload time; upload itself is outside the scope of this ADR). Indicates no validation has been triggered yet for this SBOM against this policy.
37+
- **Pending** — initial state, set when an SBOM is associated with a policy. Indicates no validation has been triggered yet for this SBOM against this policy.
3838
- **In Progress** — a user has triggered validation; the request is being processed. Other users can see this state, preventing duplicate validation runs for the same SBOM + policy pair.
3939
- **Pass** — Conforma validation succeeded; the SBOM satisfies the policy.
4040
- **Fail** — Conforma validation found policy violations; violation details are linked.
@@ -74,10 +74,6 @@ Conforma is not available as WASM and would require major upstream changes.
7474

7575
A Redis/RabbitMQ queue would improve retry handling and priority management; implement if the 429-based rejection approach proves insufficient under real load.
7676

77-
### Future API Migration
78-
79-
When Conforma provides a REST API, the EC Wrapper can be replaced by pointing Trustify's adapter directly at the Conforma REST endpoint. A feature flag (`ec-api-mode`) allows gradual migration. No changes to the service layer, API endpoints, or UI are required.
80-
8177
## The solution
8278

8379
### System Architecture
@@ -108,10 +104,7 @@ C4Context
108104
```mermaid
109105
C4Container
110106
title Enterprise Contract Integration - Container Diagram
111-
112107
Person(user, "Trustify User", "Software engineer or security analyst")
113-
114-
115108
Container_Boundary(trustify, "Trustify System") {
116109
Container(webui, "Web UI", "Rust/Actix", "Trustify GUI")
117110
Container(api, "API Gateway", "Actix-web", "REST API endpoints for SBOM <br/> and compliance operations")
@@ -130,24 +123,33 @@ C4Container
130123
System_Ext(policyRepo, "Policy Repository", "Git repository with EC policies")
131124
}
132125
126+
Container_Boundary(oidc, "OIDC") {
127+
System_Ext(oidc, "OIDC", "OPenID Connect OAuth 2.0
128+
", "")
129+
}
130+
133131
Rel(user, webui, "Views compliance status", "HTTP API")
134132
Rel(user, api, "Views compliance status", "HTTP API")
135133
Rel(webui, api, "API calls", "JSON/HTTP API")
136134
Rel(api, ecModule, "Triggers validation", "Function call")
137-
Rel(ecModule, ecWrapper, "POST /api/v1/validation {SBOM, policy_ref}<br/>← returns validation_id", "HTTP API")
138-
Rel(ecWrapper, api, "POST /api/v2/ec/validation/{validation_id}/result", "HTTP callback")
135+
Rel(ecModule, ecWrapper, "POST /validation", "HTTP API formData")
136+
Rel(ecWrapper, api, "POST /validation/{id}/result", "HTTP API")
139137
Rel(ecWrapper, conforma, "ec validate input {SBOM} {policy}", "Spawned command")
140138
Rel(ecModule, postgres, "Saves validation<br/>results", "SQL")
141139
Rel(ecModule, storage, "Stores EC reports", "Function call")
142140
Rel(storage, s3, "Persists reports", "S3 API")
143141
Rel(conforma, policyRepo, "Fetches policies", "Git/HTTPS")
142+
Rel(ecWrapper, oidc, "Authenticate", "OAuth API")
144143
145144
UpdateRelStyle(user, webui, $offsetX="-60", $offsetY="30")
146145
UpdateRelStyle(user, api, $offsetX="-60", $offsetY="-50")
147146
UpdateRelStyle(webui, api, $offsetX="-40", $offsetY="10")
148147
UpdateRelStyle(ecModule, ecWrapper, $offsetX="-50", $offsetY="-20")
148+
UpdateRelStyle(ecWrapper, api, $offsetX="-60", $offsetY="-10")
149149
UpdateRelStyle(ecModule, postgres, $offsetX="-40", $offsetY="10")
150150
UpdateRelStyle(storage, s3, $offsetX="-40", $offsetY="10")
151+
UpdateRelStyle(conforma, policyRepo, $offsetX="-40", $offsetY="100")
152+
UpdateRelStyle(ecWrapper, oidc, $offsetX="30", $offsetY="40")
151153
152154
UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="2")
153155
```
@@ -180,15 +182,15 @@ C4Component
180182
Container_Boundary(dbms, "Database") {
181183
ContainerDb(postgres, "PostgreSQL", "Database", "Stores validation results and policy references")
182184
}
183-
Container_Boundary(storage, "S3 System") {
185+
Container_Boundary(storage, "S3 System") {
184186
System_Ext(s3, "S3 Object Storage", "Stores SBOM documents and reports")
185187
}
186188
187189
Rel(api, ecEndpoints, "POST /sboms/{id}/ec-validate,\nGET /sboms/{id}/ec-report", "JSON/HTTPS")
188190
Rel(ecEndpoints, ecService, "validate_sbom() / get_ec_report()", "Function call")
189191
Rel(ecService, policyManager, "get_policy_config()", "Function call")
190192
Rel(policyManager, postgres, "SELECT ec_policies", "SQL")
191-
Rel(ecService, ecWrapper, "POST /api/v1/validation → returns validation_id", "HTTP")
193+
Rel(ecService, ecWrapper, "POST /api/v1/validation → returns {id}", "HTTP")
192194
Rel(ecWrapper, conforma, "ec validate", "Process spawn")
193195
Rel(ecWrapper, api, "POST /api/v2/ec/validation/{validation_id}/result", "JSON/HTTPS")
194196
Rel(ecService, resultParser, "parse_output()", "Function call")
@@ -220,7 +222,7 @@ sequenceDiagram
220222
participant S3 as Object Storage
221223
participant Wrapper as EC Wrapper (HTTP)
222224
223-
User->>API: POST /api/v2/sbom/{sbom_id}/ec-validate {policy_id}
225+
User->>API: POST /api/v2/sbom/{sbom_id}/ec-validate/{policy_id}
224226
API->>EP: dispatch request
225227
EP->>VS: validate_sbom(sbom_id, policy_id)
226228
@@ -318,36 +320,46 @@ sequenceDiagram
318320
**`ec_validation_result`** - one row per validation execution
319321

320322
- `id` (UUID, PK)
321-
- `validation_id` (VARCHAR, unique) - ID returned by the EC Wrapper, used for callback correlation
322323
- `sbom_id` (UUID, FK → sbom)
323324
- `policy_id` (UUID, FK → ec_policies)
324-
- `status` (VARCHAR) - 'pending', 'in_progress', 'pass', 'fail', 'error'
325+
- `status` (ENUM) - 'pending', 'in_progress', 'pass', 'fail', 'error'
325326
- `violations` (JSONB) - Structured violation data for querying
326327
- `summary` (JSONB) - Total checks, passed, failed, warnings
327328
- `report_url` (VARCHAR) - S3 URL to detailed report
328-
- `executed_at` (TIMESTAMP)
329-
- `execution_duration_ms` (INTEGER)
329+
- `start_time` (TIMESTAMP)
330+
- `end_time` (TIMESTAMP)
330331
- `conforma_version` (VARCHAR) - Conforma CLI version used (e.g., `v0.8.83`), for reproducibility
331332
- `policy_version` (VARCHAR) - Policy commit hash or tag resolved at validation time
332333
- `error_message` (TEXT) - Populated only on error status
333334

334-
### API Endpoints
335+
### Trustify API Endpoints
335336

336337
```
337-
POST /api/v2/sboms/{id}/ec-validate # Trigger validation
338+
POST /api/v2/sboms/{id}/ec-validate # Trigger validation
338339
GET /api/v2/sboms/{id}/ec-report # Get latest validation result
339340
GET /api/v2/sboms/{id}/ec-report/history # Get validation history
340341
GET /api/v2/ec/report/{result_id} # Download detailed report from S3
341342
POST /api/v2/ec/validation/{validation_id}/result # Callback: EC Wrapper posts Conforma result
342343
343-
POST /api/v2/ec/policies # Create policy reference (admin)
344-
GET /api/v2/ec/policies # List policy references
345-
GET /api/v2/ec/policies/{id} # Get policy reference
346-
PUT /api/v2/ec/policies/{id} # Update policy reference (admin)
347-
DELETE /api/v2/ec/policies/{id} # Delete policy reference (admin)
344+
POST /api/v2/ec/policy # Create policy reference (admin)
345+
GET /api/v2/ec/policy # List policy references
346+
GET /api/v2/ec/policy/{id} # Get policy reference
347+
PUT /api/v2/ec/policy/{id} # Update policy reference (admin)
348+
DELETE /api/v2/ec/policy/{id} # Delete policy reference (admin)
348349
```
349350

350-
### Module Structure
351+
## Conforma HTTP Wrapper API Endpoints
352+
353+
### POST `/api/v1/validate`
354+
355+
Validate the uploaded SBOM file against the provided rule URL.
356+
357+
#### Response
358+
359+
- 200 - if the validation request was accepted
360+
- 401 - if the user was not authenticated
361+
362+
### Trustify Module Structure
351363

352364
```
353365
modules/ec/
@@ -369,6 +381,17 @@ modules/ec/
369381
└── error.rs # Error types
370382
```
371383

384+
### HTTP Wrapper Module Structure
385+
386+
```
387+
├── Cargo.toml
388+
└── server
389+
├── lib.rs
390+
├── endpoints/
391+
│ └── mod.rs # REST endpoints
392+
└── error.rs # Error types
393+
```
394+
372395
### Technical Considerations
373396

374397
#### Conforma CLI Execution (EC Wrapper)

0 commit comments

Comments
 (0)