diff --git a/src/lib/api/discovery.ts b/src/lib/api/discovery.ts index b22680d..2b4d155 100644 --- a/src/lib/api/discovery.ts +++ b/src/lib/api/discovery.ts @@ -1,33 +1,12 @@ -import { throwError } from './errors'; + import { clouditorize } from './util'; -export interface GraphEdge { - id: string; - source: string; - target: string; -} export interface StartDiscoveryResponse { successful: boolean; } -export interface QueryResponse { - results: Resource[]; -} - -export interface ListGraphEdgesResponse { - edges: GraphEdge[]; -} - -export interface ListResourcesRequest { - filter?: Filter; - orderBy?: string; -} -export interface Filter { - cloudServiceId?: string; - type?: string; -} export interface HttpEndpoint { transportEncryption?: TransportEncryption; @@ -40,21 +19,6 @@ export interface TransportEncryption { tlsVersion: string; } -export interface ResourceProperties { - name: string; - raw: string; - type: string[]; - serviceId: string; - id: string; - labels: object; -} - -export interface Resource { - id: string; - cloudServiceId: string; - resourceType: string; - properties: ResourceProperties; -} export async function startDiscovery(): Promise { const apiUrl = clouditorize(`/v1/discovery/start`); @@ -71,44 +35,4 @@ export async function startDiscovery(): Promise { }); } -export async function listResources( - filteredServiceId?: string, - type = '', - fetch = window.fetch -): Promise { - let apiUrl = - clouditorize(`/v1/discovery/resources?filter.cloudServiceId=${filteredServiceId}&pageSize=1500&orderBy=resource_type&asc=true - `); - - if (type != '') { - apiUrl += `&filter.type=${type}`; - } - - return fetch(apiUrl, { - method: 'GET', - headers: { - Authorization: `Bearer ${localStorage.token}` - } - }) - .then(throwError) - .then((res) => res.json()) - .then((response: QueryResponse) => { - return response.results; - }); -} - -export async function listGraphEdges(fetch = window.fetch): Promise { - const apiUrl = clouditorize(`/v1experimental/discovery/graph/edges?&pageSize=1500`); - return fetch(apiUrl, { - method: 'GET', - headers: { - Authorization: `Bearer ${localStorage.token}` - } - }) - .then(throwError) - .then((res) => res.json()) - .then((response: ListGraphEdgesResponse) => { - return response.edges; - }); -} diff --git a/src/lib/api/evaluation.ts b/src/lib/api/evaluation.ts index 950c72d..d799c52 100644 --- a/src/lib/api/evaluation.ts +++ b/src/lib/api/evaluation.ts @@ -20,7 +20,7 @@ export type ComplianceStatus = export interface EvaluationResult { id: string; - cloudServiceId: string; + targetOfEvaluationId: string; status: ComplianceStatus; controlCatalogId: string; controlCategoryName?: string; @@ -45,7 +45,7 @@ export async function startEvaluation(auditScope: AuditScope): Promise { const apiUrl = clouditorize( - `/v1/evaluation/evaluate/${auditScope.certificationTargetId}/${auditScope.catalogId}/stop` + `/v1/evaluation/evaluate/${auditScope.id}/stop` ); return fetch(apiUrl, { @@ -57,10 +57,12 @@ export async function stopEvaluation(auditScope: AuditScope): Promise<{}> { } export interface ListEvaluationResultsFilter { - cloudServiceId?: string; + targetOfEvaluationId?: string; catalogId?: string; controlId?: string; + subControls?: string; parentsOnly?: boolean; + validManualOnly?: boolean; } export async function listEvaluationResults( @@ -70,8 +72,8 @@ export async function listEvaluationResults( ): Promise { let apiUrl = clouditorize(`/v1/evaluation/results?`); - if (filter?.cloudServiceId != undefined) { - apiUrl += `&filter.certification_target_id=${filter?.cloudServiceId}`; + if (filter?.targetOfEvaluationId != undefined) { + apiUrl += `&filter.target_of_evaluation_id=${filter?.targetOfEvaluationId}`; } if (filter?.catalogId != undefined) { apiUrl += `&filter.catalog_id=${filter?.catalogId}`; diff --git a/src/lib/api/evidence_store.ts b/src/lib/api/evidence_store.ts new file mode 100644 index 0000000..e7ebfb5 --- /dev/null +++ b/src/lib/api/evidence_store.ts @@ -0,0 +1,93 @@ +import { throwError } from './errors'; +import { clouditorize } from './util'; + + +export interface GraphEdge { + id: string; + source: string; + target: string; + type: string; +} + +export interface ListGraphEdgesRequest { + + orderBy?: string; + pageSize?: number; + asc?: boolean; +} +export interface ListGraphEdgesResponse { + edges: GraphEdge[]; +} + +export interface ListResourcesRequest { + filter?: Filter; + orderBy?: string; +} + +export interface ListResourcesResponse { + results: Resource[]; +} + + +export interface Filter { + targetOfEvaluationId?: string; + type?: string; +} + +export interface ResourceProperties { + name: string; + raw: string; + type: string[]; + serviceId: string; + id: string; + labels: object; +} + +export interface Resource { + id: string; + targetOfEvaluationId: string; + resourceType: string; + properties: ResourceProperties; +} + +export async function listResources( + filteredTargetOfEvaluationId?: string, + type = '', + fetch = window.fetch +): Promise { + let apiUrl = + clouditorize(`/v1/evidence_store/resources?filter.targetOfEvaluationId=${filteredTargetOfEvaluationId}&pageSize=1500&orderBy=resource_type&asc=true + `); + + if (type != '') { + apiUrl += `&filter.type=${type}`; + } + + return fetch(apiUrl, { + method: 'GET', + headers: { + Authorization: `Bearer ${localStorage.token}` + } + }) + .then(throwError) + .then((res) => res.json()) + .then((response: ListResourcesResponse) => { + return response.results; + }); +} + +export async function listGraphEdges(fetch = window.fetch): Promise { + const apiUrl = clouditorize(`/v1experimental/evidence/graph/edges`);//?pageSize=1500`); + + return fetch(apiUrl, { + method: 'GET', + headers: { + Authorization: `Bearer ${localStorage.token}` + } + }) + .then(throwError) + .then((res) => res.json()) + .then((response: ListGraphEdgesResponse) => { + return response.edges; + }); +} \ No newline at end of file diff --git a/src/lib/api/orchestrator.ts b/src/lib/api/orchestrator.ts index 2ad05b8..0422045 100644 --- a/src/lib/api/orchestrator.ts +++ b/src/lib/api/orchestrator.ts @@ -22,12 +22,13 @@ export interface Tag { tag: object; } -export interface CertificationTarget { +export interface TargetOfEvaluation { id: string; name: string; description?: string; metadata: { labels?: Tag[] | string; + icon?: string; }; createdAt: string; updatedAt: string; @@ -35,14 +36,14 @@ export interface CertificationTarget { export interface AuditScope { id: string; - certificationTargetId: string; + name: string; + targetOfEvaluationId: string; catalogId: string; assuranceLevel?: string; - controlsInScope?: Control[]; } export interface ControlInScope { - auditScopeCertificationTargetId: string; + auditScopeTargetOfEvaluationId: string; auditScopeCatalogId: string; controlId: string; controlCategoryName: string; @@ -105,7 +106,7 @@ export interface ListMetricConfigurationsResponse { export interface Certificate { id: string; name: string; - certificationTargetId: string; + targetOfEvaluationId: string; issueDate: string; expirationDate: string; standard: string; @@ -139,8 +140,8 @@ export interface ListAssessmentResultsResponse { results: AssessmentResult[]; } -export interface ListCertificationTargetsResponse { - targets: CertificationTarget[]; +export interface ListTargetsOfEvaluationResponse { + targets: TargetOfEvaluation[]; } export interface ListAuditScopesResponse { @@ -182,7 +183,7 @@ export async function listAssessmentResults( latestByResourceId = false ): Promise { const apiUrl = clouditorize( - `/v1/orchestrator/assessment_results?pageSize=1500&latestByResourceId=${latestByResourceId}&orderBy=timestamp&asc=false` + `/v1/orchestrator/assessment_results?pageSize=1500&latestByResourceId=${latestByResourceId}&asc=false` ); return fetch(apiUrl, { @@ -203,12 +204,12 @@ export async function listAssessmentResults( * * @returns an array of {@link AssessmentResult}s. */ -export async function listCertificationTargetAssessmentResults( +export async function listTargetOfEvaluationAssessmentResults( serviceId: string, fetch = window.fetch ): Promise { const apiUrl = clouditorize( - `/v1/orchestrator/assessment_results?pageSize=1000&filter.certificationTargetId=${serviceId}&orderBy=timestamp&asc=false` + `/v1/orchestrator/assessment_results?pageSize=1000&filter.targetOfEvaluationId=${serviceId}&asc=false` ); return fetch(apiUrl, { @@ -271,7 +272,7 @@ export async function getMetricImplementation(id: string): Promise { const apiUrl = clouditorize( - `/v1/orchestrator/certification_targets/${serviceId}/metric_configurations/${metricId}` + `/v1/orchestrator/targets_of_evaluation/${serviceId}/metric_configurations/${metricId}` ); return fetch(apiUrl, { @@ -307,7 +308,7 @@ export async function listMetricConfigurations( skipDefault = false ): Promise> { const apiUrl = clouditorize( - `/v1/orchestrator/certification_targets/${serviceId}/metric_configurations` + `/v1/orchestrator/targets_of_evaluation/${serviceId}/metric_configurations` ); return fetch(apiUrl, { @@ -332,12 +333,12 @@ export async function listMetricConfigurations( } /** - * Creates a new certification target + * Creates a new Target of Evaluation */ -export async function registerCertificationTarget( - service: CertificationTarget -): Promise { - const apiUrl = clouditorize(`/v1/orchestrator/certification_targets`); +export async function registerTargetOfEvaluation( + service: TargetOfEvaluation +): Promise { + const apiUrl = clouditorize(`/v1/orchestrator/targets_of_evaluation`); return fetch(apiUrl, { method: 'POST', @@ -348,16 +349,16 @@ export async function registerCertificationTarget( }) .then(throwError) .then((res) => res.json()) - .then((response: CertificationTarget) => { + .then((response: TargetOfEvaluation) => { return response; }); } /** - * Removes a certification target. + * Removes a Target of Evaluation. */ -export async function removeCertificationTarget(targetId: string): Promise { - const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${targetId}`); +export async function removeTargetOfEvaluation(targetId: string): Promise { + const apiUrl = clouditorize(`/v1/orchestrator/targets_of_evaluation/${targetId}`); return fetch(apiUrl, { method: 'DELETE', @@ -370,14 +371,14 @@ export async function removeCertificationTarget(targetId: string): Promise } /** - * Retrieves a list of certification targets from the orchestrator service. + * Retrieves a list of Targets of Evaluation from the orchestrator service. * - * @returns an array of {@link CertificationTarget}s. + * @returns an array of {@link TargetOfEvaluation}s. */ -export async function listCertificationTargets( +export async function listTargetsOfEvaluation( fetch = window.fetch -): Promise { - const apiUrl = clouditorize(`/v1/orchestrator/certification_targets`); +): Promise { + const apiUrl = clouditorize(`/v1/orchestrator/targets_of_evaluation`); return fetch(apiUrl, { method: 'GET', @@ -387,13 +388,13 @@ export async function listCertificationTargets( }) .then(throwError) .then((res) => res.json()) - .then((response: ListCertificationTargetsResponse) => { + .then((response: ListTargetsOfEvaluationResponse) => { return response.targets; }); } /** - * Creates a new target of evaluation. + * Creates a new Audit Scope. */ export async function createAuditScope(target: AuditScope): Promise { const apiUrl = clouditorize(`/v1/orchestrator/audit_scopes`); @@ -410,7 +411,7 @@ export async function createAuditScope(target: AuditScope): Promise } /** - * Removes a target of evaluation. + * Removes an Audit Scope. */ export async function removeAuditScope(target: AuditScope): Promise { const apiUrl = clouditorize(`/v1/orchestrator/audit_scopes/${target.id}`); @@ -427,7 +428,7 @@ export async function removeAuditScope(target: AuditScope): Promise } /** - * Retrieves a list of targets of evaluation from the orchestrator service. + * Retrieves a list of Audit Scopes from the orchestrator service. * * @returns an array of {@link AuditScope}s. */ @@ -436,7 +437,7 @@ export async function listAuditScopes( fetch = window.fetch ): Promise { const apiUrl = clouditorize( - `/v1/orchestrator/audit_scopes?filter.certificationTargetId=${serviceId}` + `/v1/orchestrator/audit_scopes?filter.targetOfEvaluationId=${serviceId}` ); return fetch(apiUrl, { @@ -535,15 +536,15 @@ export async function listControls( } /** - * Retrieve a certification target from the orchestrator service using its ID. + * Retrieve a Target of Evaluation from the orchestrator service using its ID. * - * @returns the certification target + * @returns the Target of Evaluation */ -export async function getCertificationTarget( +export async function getTargetOfEvaluation( id: string, fetch = window.fetch -): Promise { - const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${id}`); +): Promise { + const apiUrl = clouditorize(`/v1/orchestrator/targets_of_evaluation/${id}`); return fetch(apiUrl, { method: 'GET', @@ -555,11 +556,11 @@ export async function getCertificationTarget( .then((res) => res.json()); } -export async function updateCertificationTarget( - service: CertificationTarget, +export async function updateTargetOfEvaluation( + service: TargetOfEvaluation, fetch = window.fetch -): Promise { - const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${service.id}`); +): Promise { + const apiUrl = clouditorize(`/v1/orchestrator/targets_of_evaluation/${service.id}`); return fetch(apiUrl, { method: 'PUT', @@ -570,7 +571,7 @@ export async function updateCertificationTarget( }) .then(throwError) .then((res) => res.json()) - .then((response: CertificationTarget) => { + .then((response: TargetOfEvaluation) => { return response; }); } @@ -578,9 +579,9 @@ export async function updateCertificationTarget( export async function updateControlInScope( scope: ControlInScope, fetch = window.fetch -): Promise { +): Promise { const apiUrl = clouditorize( - `/v1/orchestrator/certification_targets/${scope.auditScopeCertificationTargetId}/audit_scopes/${scope.auditScopeCatalogId}/controls_in_scope/categories/${scope.controlCategoryName}/controls/${scope.controlId}` + `/v1/orchestrator/targets_of_evaluation/${scope.auditScopeTargetOfEvaluationId}/audit_scopes/${scope.auditScopeCatalogId}/controls_in_scope/categories/${scope.controlCategoryName}/controls/${scope.controlId}` ); return fetch(apiUrl, { @@ -592,7 +593,7 @@ export async function updateControlInScope( }) .then(throwError) .then((res) => res.json()) - .then((response: CertificationTarget) => { + .then((response: TargetOfEvaluation) => { return response; }); } diff --git a/src/lib/components/CatalogComplianceItem.svelte b/src/lib/components/CatalogComplianceItem.svelte index d72382b..ce80794 100644 --- a/src/lib/components/CatalogComplianceItem.svelte +++ b/src/lib/components/CatalogComplianceItem.svelte @@ -30,7 +30,7 @@
  • - +
    {catalog.name}
    {catalog.description}
    diff --git a/src/lib/components/ComplianceChart.svelte b/src/lib/components/ComplianceChart.svelte index edb1faf..ea50bfc 100644 --- a/src/lib/components/ComplianceChart.svelte +++ b/src/lib/components/ComplianceChart.svelte @@ -67,7 +67,7 @@ } goto( - `/cloud/${auditScope.certificationTargetId}/compliance/${auditScope.catalogId}?${params.toString()}` + `/cloud/${auditScope.targetOfEvaluationId}/compliance/${auditScope.catalogId}?${params.toString()}` ); } }; diff --git a/src/lib/components/GraphEdge.svelte b/src/lib/components/GraphEdge.svelte index 8b85574..f7e0265 100644 --- a/src/lib/components/GraphEdge.svelte +++ b/src/lib/components/GraphEdge.svelte @@ -3,7 +3,7 @@ let { edge } = $props(); - const { getCyInstance } = getContext('graphSharedState'); + const { getCyInstance } = getContext<{ getCyInstance: () => any }>('graphSharedState'); const cy = getCyInstance(); try { diff --git a/src/lib/components/GraphNode.svelte b/src/lib/components/GraphNode.svelte index c8f0bf3..7718819 100644 --- a/src/lib/components/GraphNode.svelte +++ b/src/lib/components/GraphNode.svelte @@ -3,7 +3,7 @@ let { node } = $props(); - const { getCyInstance } = getContext('graphSharedState'); + const { getCyInstance } = getContext<{ getCyInstance: () => any }>('graphSharedState'); const cy = getCyInstance(); cy.add({ diff --git a/src/lib/components/NodeDetail.svelte b/src/lib/components/NodeDetail.svelte index eaa58cd..93bc056 100644 --- a/src/lib/components/NodeDetail.svelte +++ b/src/lib/components/NodeDetail.svelte @@ -2,7 +2,7 @@ import { run } from 'svelte/legacy'; import type { AssessmentResult, Metric } from '$lib/api/assessment'; - import type { Resource, listResources } from '$lib/api/discovery'; + import type { Resource } from '$lib/api/evidence_store'; import AssessmentIcon from './AssessmentIcon.svelte'; import { flatten } from 'flat'; @@ -127,7 +127,7 @@