diff --git a/CHANGELOG.md b/CHANGELOG.md index 09df4b492..8f1d7f06a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,26 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### BREAKING CHANGES + +### BREAKING CHANGES + +- **BREAKING:** Renamed GraphQL mutations for control-mitigation mappings: + - `createControlMapping` → `createControlMitigationMapping` + - `deleteControlMapping` → `deleteControlMitigationMapping` + - Input and payload types have been updated accordingly + ### Added - Add import control <> mitigation mapping. - Add mitigation tasks import. - Add auto-scroll to opened category. +- Added support for mapping controls to policies: + - New GraphQL mutations `createControlPolicyMapping` and `deleteControlPolicyMapping` + - Controls can now be associated with both mitigations and policies + - New bidirectional relationships: + - Control objects now expose a `policies` field to list associated policies + - Policy objects now expose a `controls` field to list associated controls ### Changed diff --git a/apps/console/src/pages/organizations/frameworks/controls/Control.tsx b/apps/console/src/pages/organizations/frameworks/controls/Control.tsx index c77a49247..463b65e61 100644 --- a/apps/console/src/pages/organizations/frameworks/controls/Control.tsx +++ b/apps/console/src/pages/organizations/frameworks/controls/Control.tsx @@ -93,9 +93,9 @@ const organizationMitigationsQuery = graphql` // Mutation to create a mapping between a control and a mitigation const createMitigationMappingMutation = graphql` mutation ControlCreateMitigationMappingMutation( - $input: CreateControlMappingInput! + $input: CreateControlMitigationMappingInput! ) { - createControlMapping(input: $input) { + createControlMitigationMapping(input: $input) { success } } @@ -104,9 +104,9 @@ const createMitigationMappingMutation = graphql` // Mutation to delete a mapping between a control and a mitigation const deleteMitigationMappingMutation = graphql` mutation ControlDeleteMitigationMappingMutation( - $input: DeleteControlMappingInput! + $input: DeleteControlMitigationMappingInput! ) { - deleteControlMapping(input: $input) { + deleteControlMitigationMapping(input: $input) { success } } diff --git a/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlCreateMitigationMappingMutation.graphql.ts b/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlCreateMitigationMappingMutation.graphql.ts index 210342a59..20f83f3f4 100644 --- a/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlCreateMitigationMappingMutation.graphql.ts +++ b/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlCreateMitigationMappingMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<7598a6cf0314f71bab809d65acc60237>> + * @generated SignedSource<<2eea3e72c7001db14095958b3bcd750a>> * @lightSyntaxTransform * @nogrep */ @@ -9,15 +9,15 @@ // @ts-nocheck import { ConcreteRequest } from 'relay-runtime'; -export type CreateControlMappingInput = { +export type CreateControlMitigationMappingInput = { controlId: string; mitigationId: string; }; export type ControlCreateMitigationMappingMutation$variables = { - input: CreateControlMappingInput; + input: CreateControlMitigationMappingInput; }; export type ControlCreateMitigationMappingMutation$data = { - readonly createControlMapping: { + readonly createControlMitigationMapping: { readonly success: boolean; }; }; @@ -44,9 +44,9 @@ v1 = [ "variableName": "input" } ], - "concreteType": "CreateControlMappingPayload", + "concreteType": "CreateControlMitigationMappingPayload", "kind": "LinkedField", - "name": "createControlMapping", + "name": "createControlMitigationMapping", "plural": false, "selections": [ { @@ -78,16 +78,16 @@ return { "selections": (v1/*: any*/) }, "params": { - "cacheID": "57ab0bf99dd6ed3d2e980c51f185b9c0", + "cacheID": "955241a049e81cd7faed45d69ce3b145", "id": null, "metadata": {}, "name": "ControlCreateMitigationMappingMutation", "operationKind": "mutation", - "text": "mutation ControlCreateMitigationMappingMutation(\n $input: CreateControlMappingInput!\n) {\n createControlMapping(input: $input) {\n success\n }\n}\n" + "text": "mutation ControlCreateMitigationMappingMutation(\n $input: CreateControlMitigationMappingInput!\n) {\n createControlMitigationMapping(input: $input) {\n success\n }\n}\n" } }; })(); -(node as any).hash = "17ef8f09acabf19168dad896e4225e3d"; +(node as any).hash = "ffbcf187d7f2d3c65a2d1fb5c6a180bb"; export default node; diff --git a/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlDeleteMitigationMappingMutation.graphql.ts b/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlDeleteMitigationMappingMutation.graphql.ts index caf535624..f24e78a89 100644 --- a/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlDeleteMitigationMappingMutation.graphql.ts +++ b/apps/console/src/pages/organizations/frameworks/controls/__generated__/ControlDeleteMitigationMappingMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<7c4ad77e70fa42cf8257113897a607ec>> * @lightSyntaxTransform * @nogrep */ @@ -9,15 +9,15 @@ // @ts-nocheck import { ConcreteRequest } from 'relay-runtime'; -export type DeleteControlMappingInput = { +export type DeleteControlMitigationMappingInput = { controlId: string; mitigationId: string; }; export type ControlDeleteMitigationMappingMutation$variables = { - input: DeleteControlMappingInput; + input: DeleteControlMitigationMappingInput; }; export type ControlDeleteMitigationMappingMutation$data = { - readonly deleteControlMapping: { + readonly deleteControlMitigationMapping: { readonly success: boolean; }; }; @@ -44,9 +44,9 @@ v1 = [ "variableName": "input" } ], - "concreteType": "DeleteControlMappingPayload", + "concreteType": "DeleteControlMitigationMappingPayload", "kind": "LinkedField", - "name": "deleteControlMapping", + "name": "deleteControlMitigationMapping", "plural": false, "selections": [ { @@ -78,16 +78,16 @@ return { "selections": (v1/*: any*/) }, "params": { - "cacheID": "31dcbb70c0b32e78dcb3fd2a2dc1a58b", + "cacheID": "3d09a29c8ae06a97d098e565a7f2d172", "id": null, "metadata": {}, "name": "ControlDeleteMitigationMappingMutation", "operationKind": "mutation", - "text": "mutation ControlDeleteMitigationMappingMutation(\n $input: DeleteControlMappingInput!\n) {\n deleteControlMapping(input: $input) {\n success\n }\n}\n" + "text": "mutation ControlDeleteMitigationMappingMutation(\n $input: DeleteControlMitigationMappingInput!\n) {\n deleteControlMitigationMapping(input: $input) {\n success\n }\n}\n" } }; })(); -(node as any).hash = "6070b58009682dfa712e445363f0ebf5"; +(node as any).hash = "6905236aeeb313e5deed3e569a0c7c54"; export default node; diff --git a/apps/console/src/pages/organizations/mitigations/MitigationView.tsx b/apps/console/src/pages/organizations/mitigations/MitigationView.tsx index 7356874a3..88d8bc4ae 100644 --- a/apps/console/src/pages/organizations/mitigations/MitigationView.tsx +++ b/apps/console/src/pages/organizations/mitigations/MitigationView.tsx @@ -394,9 +394,9 @@ const linkedControlsQuery = graphql` const createControlMappingMutation = graphql` mutation MitigationViewCreateControlMappingMutation( - $input: CreateControlMappingInput! + $input: CreateControlMitigationMappingInput! ) { - createControlMapping(input: $input) { + createControlMitigationMapping(input: $input) { success } } @@ -404,9 +404,9 @@ const createControlMappingMutation = graphql` const deleteControlMappingMutation = graphql` mutation MitigationViewDeleteControlMappingMutation( - $input: DeleteControlMappingInput! + $input: DeleteControlMitigationMappingInput! ) { - deleteControlMapping(input: $input) { + deleteControlMitigationMapping(input: $input) { success } } diff --git a/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewCreateControlMappingMutation.graphql.ts b/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewCreateControlMappingMutation.graphql.ts index 9391e4df0..25f718178 100644 --- a/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewCreateControlMappingMutation.graphql.ts +++ b/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewCreateControlMappingMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<53f255c3852774870c7d294d64e6808d>> * @lightSyntaxTransform * @nogrep */ @@ -9,15 +9,15 @@ // @ts-nocheck import { ConcreteRequest } from 'relay-runtime'; -export type CreateControlMappingInput = { +export type CreateControlMitigationMappingInput = { controlId: string; mitigationId: string; }; export type MitigationViewCreateControlMappingMutation$variables = { - input: CreateControlMappingInput; + input: CreateControlMitigationMappingInput; }; export type MitigationViewCreateControlMappingMutation$data = { - readonly createControlMapping: { + readonly createControlMitigationMapping: { readonly success: boolean; }; }; @@ -44,9 +44,9 @@ v1 = [ "variableName": "input" } ], - "concreteType": "CreateControlMappingPayload", + "concreteType": "CreateControlMitigationMappingPayload", "kind": "LinkedField", - "name": "createControlMapping", + "name": "createControlMitigationMapping", "plural": false, "selections": [ { @@ -78,16 +78,16 @@ return { "selections": (v1/*: any*/) }, "params": { - "cacheID": "79290e466d2aa856113aae8a4e7a0035", + "cacheID": "fa46c5cf8b96b70117d12cf985247824", "id": null, "metadata": {}, "name": "MitigationViewCreateControlMappingMutation", "operationKind": "mutation", - "text": "mutation MitigationViewCreateControlMappingMutation(\n $input: CreateControlMappingInput!\n) {\n createControlMapping(input: $input) {\n success\n }\n}\n" + "text": "mutation MitigationViewCreateControlMappingMutation(\n $input: CreateControlMitigationMappingInput!\n) {\n createControlMitigationMapping(input: $input) {\n success\n }\n}\n" } }; })(); -(node as any).hash = "32a27dc5fdd06c261258e80db3db50fc"; +(node as any).hash = "af6e4d7933e5c428eec0e97cdf0b73dd"; export default node; diff --git a/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewDeleteControlMappingMutation.graphql.ts b/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewDeleteControlMappingMutation.graphql.ts index 04e5408e4..f32c96ae3 100644 --- a/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewDeleteControlMappingMutation.graphql.ts +++ b/apps/console/src/pages/organizations/mitigations/__generated__/MitigationViewDeleteControlMappingMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -9,15 +9,15 @@ // @ts-nocheck import { ConcreteRequest } from 'relay-runtime'; -export type DeleteControlMappingInput = { +export type DeleteControlMitigationMappingInput = { controlId: string; mitigationId: string; }; export type MitigationViewDeleteControlMappingMutation$variables = { - input: DeleteControlMappingInput; + input: DeleteControlMitigationMappingInput; }; export type MitigationViewDeleteControlMappingMutation$data = { - readonly deleteControlMapping: { + readonly deleteControlMitigationMapping: { readonly success: boolean; }; }; @@ -44,9 +44,9 @@ v1 = [ "variableName": "input" } ], - "concreteType": "DeleteControlMappingPayload", + "concreteType": "DeleteControlMitigationMappingPayload", "kind": "LinkedField", - "name": "deleteControlMapping", + "name": "deleteControlMitigationMapping", "plural": false, "selections": [ { @@ -78,16 +78,16 @@ return { "selections": (v1/*: any*/) }, "params": { - "cacheID": "824394c9cc09d7d428ad42835d3737ef", + "cacheID": "b18a11215ba33a6c770cc08c88a28769", "id": null, "metadata": {}, "name": "MitigationViewDeleteControlMappingMutation", "operationKind": "mutation", - "text": "mutation MitigationViewDeleteControlMappingMutation(\n $input: DeleteControlMappingInput!\n) {\n deleteControlMapping(input: $input) {\n success\n }\n}\n" + "text": "mutation MitigationViewDeleteControlMappingMutation(\n $input: DeleteControlMitigationMappingInput!\n) {\n deleteControlMitigationMapping(input: $input) {\n success\n }\n}\n" } }; })(); -(node as any).hash = "4d7bd098ed16e825abec0e5d996b06e9"; +(node as any).hash = "f4f01abb45a3288558d7e8a1d19ce1ed"; export default node; diff --git a/pkg/coredata/control.go b/pkg/coredata/control.go index 06a520ca2..6a22ae1d9 100644 --- a/pkg/coredata/control.go +++ b/pkg/coredata/control.go @@ -56,6 +56,66 @@ func (c Control) CursorKey(orderBy ControlOrderField) page.CursorKey { panic(fmt.Sprintf("unsupported order by: %s", orderBy)) } +func (c *Controls) LoadByPolicyID( + ctx context.Context, + conn pg.Conn, + scope Scoper, + policyID gid.GID, + cursor *page.Cursor[ControlOrderField], +) error { + q := ` +WITH ctrl AS ( + SELECT + c.id, + c.reference_id, + c.framework_id, + c.tenant_id, + c.name, + c.description, + c.created_at, + c.updated_at + FROM + controls c + INNER JOIN + controls_policies cp ON c.id = cp.control_id + WHERE + cp.policy_id = @policy_id +) +SELECT + id, + reference_id, + framework_id, + tenant_id, + name, + description, + created_at, + updated_at +FROM + ctrl +WHERE %s + AND %s +` + q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) + + args := pgx.NamedArgs{"policy_id": policyID} + maps.Copy(args, scope.SQLArguments()) + maps.Copy(args, cursor.SQLArguments()) + + rows, err := conn.Query(ctx, q, args) + if err != nil { + return fmt.Errorf("cannot query controls: %w", err) + } + + controls, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Control]) + if err != nil { + return fmt.Errorf("cannot collect controls: %w", err) + } + + *c = controls + + return nil +} + func (c *Controls) LoadByMitigationID( ctx context.Context, conn pg.Conn, diff --git a/pkg/coredata/control_policy.go b/pkg/coredata/control_policy.go new file mode 100644 index 000000000..4eaec6715 --- /dev/null +++ b/pkg/coredata/control_policy.go @@ -0,0 +1,95 @@ +// Copyright (c) 2025 Probo Inc . +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +// PERFORMANCE OF THIS SOFTWARE. + +package coredata + +import ( + "context" + "fmt" + "maps" + "time" + + "github.com/getprobo/probo/pkg/gid" + "github.com/jackc/pgx/v5" + "go.gearno.de/kit/pg" +) + +type ( + ControlPolicy struct { + ControlID gid.GID `db:"control_id"` + PolicyID gid.GID `db:"policy_id"` + TenantID gid.TenantID `db:"tenant_id"` + CreatedAt time.Time `db:"created_at"` + } + + ControlPolicies []*ControlPolicy +) + +func (cp ControlPolicy) Insert( + ctx context.Context, + conn pg.Conn, + scope Scoper, +) error { + q := ` +INSERT INTO + controls_mitigations ( + control_id, + policy_id, + tenant_id, + created_at + ) +VALUES ( + @control_id, + @policy_id, + @tenant_id, + @created_at +); +` + + args := pgx.StrictNamedArgs{ + "control_id": cp.ControlID, + "policy_id": cp.PolicyID, + "tenant_id": scope.GetTenantID(), + "created_at": cp.CreatedAt, + } + _, err := conn.Exec(ctx, q, args) + return err +} + +func (cp ControlPolicy) Delete( + ctx context.Context, + conn pg.Conn, + scope Scoper, +) error { + q := ` +DELETE +FROM + controls_mitigations +WHERE + %s + AND control_id = @control_id + AND policy_id = @policy_id; +` + + args := pgx.StrictNamedArgs{ + "control_id": cp.ControlID, + "policy_id": cp.PolicyID, + } + maps.Copy(args, scope.SQLArguments()) + + q = fmt.Sprintf(q, scope.SQLFragment()) + + _, err := conn.Exec(ctx, q, args) + return err +} diff --git a/pkg/coredata/migrations/20250408T205600Z.sql b/pkg/coredata/migrations/20250408T205600Z.sql new file mode 100644 index 000000000..5f94ed155 --- /dev/null +++ b/pkg/coredata/migrations/20250408T205600Z.sql @@ -0,0 +1,7 @@ +CREATE TABLE controls_policies ( + control_id TEXT NOT NULL REFERENCES controls(id), + policy_id TEXT NOT NULL REFERENCES policies(id), + tenant_id TEXT NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL, + PRIMARY KEY (control_id, policy_id) +); \ No newline at end of file diff --git a/pkg/coredata/policy.go b/pkg/coredata/policy.go index 105396892..2c580300b 100644 --- a/pkg/coredata/policy.go +++ b/pkg/coredata/policy.go @@ -271,3 +271,67 @@ RETURNING return nil } + +func (p *Policies) LoadByControlID( + ctx context.Context, + conn pg.Conn, + scope Scoper, + controlID gid.GID, + cursor *page.Cursor[PolicyOrderField], +) error { + q := ` +WITH plcs AS ( + SELECT + p.id, + p.tenant_id, + p.organization_id, + p.owner_id, + p.name, + p.content, + p.status, + p.review_date, + p.created_at, + p.updated_at + FROM + policies p + INNER JOIN + controls_policies cp ON p.id = cp.policy_id + WHERE + cp.control_id = @control_id +) +SELECT + id, + tenant_id, + organization_id, + owner_id, + name, + content, + status, + review_date, + created_at, + updated_at +FROM + plcs +WHERE %s + AND %s +` + q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) + + args := pgx.StrictNamedArgs{"control_id": controlID} + maps.Copy(args, scope.SQLArguments()) + maps.Copy(args, cursor.SQLArguments()) + + rows, err := conn.Query(ctx, q, args) + if err != nil { + return fmt.Errorf("cannot query policies: %w", err) + } + + policies, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Policy]) + if err != nil { + return fmt.Errorf("cannot collect policies: %w", err) + } + + *p = policies + + return nil +} diff --git a/pkg/probo/control_service.go b/pkg/probo/control_service.go index 00ddef838..62a4512fd 100644 --- a/pkg/probo/control_service.go +++ b/pkg/probo/control_service.go @@ -55,6 +55,27 @@ type ( } ) +func (s ControlService) ListForPolicyID( + ctx context.Context, + policyID gid.GID, + cursor *page.Cursor[coredata.ControlOrderField], +) (*page.Page[*coredata.Control, coredata.ControlOrderField], error) { + var controls coredata.Controls + + err := s.svc.pg.WithConn( + ctx, + func(conn pg.Conn) error { + return controls.LoadByPolicyID(ctx, conn, s.svc.scope, policyID, cursor) + }, + ) + + if err != nil { + return nil, fmt.Errorf("cannot list controls: %w", err) + } + + return page.NewPage(controls, cursor), nil +} + func (s ControlService) ListForMitigationID( ctx context.Context, mitigationID gid.GID, @@ -76,7 +97,7 @@ func (s ControlService) ListForMitigationID( return page.NewPage(controls, cursor), nil } -func (s ControlService) CreateMapping( +func (s ControlService) CreateMitigationMapping( ctx context.Context, controlID gid.GID, mitigationID gid.GID, @@ -96,7 +117,7 @@ func (s ControlService) CreateMapping( ) } -func (s ControlService) DeleteMapping( +func (s ControlService) DeleteMitigationMapping( ctx context.Context, controlID gid.GID, mitigationID gid.GID, @@ -116,6 +137,46 @@ func (s ControlService) DeleteMapping( ) } +func (s ControlService) CreatePolicyMapping( + ctx context.Context, + controlID gid.GID, + policyID gid.GID, +) error { + controlPolicy := &coredata.ControlPolicy{ + ControlID: controlID, + PolicyID: policyID, + TenantID: s.svc.scope.GetTenantID(), + CreatedAt: time.Now(), + } + + return s.svc.pg.WithConn( + ctx, + func(conn pg.Conn) error { + return controlPolicy.Insert(ctx, conn, s.svc.scope) + }, + ) +} + +func (s ControlService) DeletePolicyMapping( + ctx context.Context, + controlID gid.GID, + policyID gid.GID, +) error { + controlPolicy := &coredata.ControlPolicy{ + ControlID: controlID, + PolicyID: policyID, + TenantID: s.svc.scope.GetTenantID(), + CreatedAt: time.Now(), + } + + return s.svc.pg.WithConn( + ctx, + func(conn pg.Conn) error { + return controlPolicy.Delete(ctx, conn, s.svc.scope) + }, + ) +} + // Create creates a new control func (s ControlService) Create( ctx context.Context, diff --git a/pkg/probo/policy_service.go b/pkg/probo/policy_service.go index 83597b08d..fa0de7c19 100644 --- a/pkg/probo/policy_service.go +++ b/pkg/probo/policy_service.go @@ -168,3 +168,24 @@ func (s *PolicyService) ListByOrganizationID( return page.NewPage(policies, cursor), nil } + +func (s *PolicyService) ListForControlID( + ctx context.Context, + controlID gid.GID, + cursor *page.Cursor[coredata.PolicyOrderField], +) (*page.Page[*coredata.Policy, coredata.PolicyOrderField], error) { + var policies coredata.Policies + + err := s.svc.pg.WithConn( + ctx, + func(conn pg.Conn) error { + return policies.LoadByControlID(ctx, conn, s.svc.scope, controlID, cursor) + }, + ) + + if err != nil { + return nil, err + } + + return page.NewPage(policies, cursor), nil +} diff --git a/pkg/server/api/console/v1/schema.graphql b/pkg/server/api/console/v1/schema.graphql index e34020911..18fe2fd67 100644 --- a/pkg/server/api/console/v1/schema.graphql +++ b/pkg/server/api/console/v1/schema.graphql @@ -448,6 +448,14 @@ type Control implements Node { orderBy: MitigationOrder ): MitigationConnection! @goField(forceResolver: true) + policies( + first: Int + after: CursorKey + last: Int + before: CursorKey + orderBy: PolicyOrder + ): PolicyConnection! @goField(forceResolver: true) + createdAt: Datetime! updatedAt: Datetime! } @@ -530,6 +538,15 @@ type Policy implements Node { content: String! reviewDate: Datetime owner: People! @goField(forceResolver: true) + + controls( + first: Int + after: CursorKey + last: Int + before: CursorKey + orderBy: ControlOrder + ): ControlConnection! @goField(forceResolver: true) + createdAt: Datetime! updatedAt: Datetime! } @@ -727,12 +744,18 @@ type Mutation { importMitigation(input: ImportMitigationInput!): ImportMitigationPayload! # Control mutations - createControlMapping( - input: CreateControlMappingInput! - ): CreateControlMappingPayload! - deleteControlMapping( - input: DeleteControlMappingInput! - ): DeleteControlMappingPayload! + createControlMitigationMapping( + input: CreateControlMitigationMappingInput! + ): CreateControlMitigationMappingPayload! + createControlPolicyMapping( + input: CreateControlPolicyMappingInput! + ): CreateControlPolicyMappingPayload! + deleteControlMitigationMapping( + input: DeleteControlMitigationMappingInput! + ): DeleteControlMitigationMappingPayload! + deleteControlPolicyMapping( + input: DeleteControlPolicyMappingInput! + ): DeleteControlPolicyMappingPayload! # Task mutations createTask(input: CreateTaskInput!): CreateTaskPayload! @@ -897,16 +920,26 @@ input UnassignTaskInput { taskId: ID! } -input CreateControlMappingInput { +input CreateControlMitigationMappingInput { controlId: ID! mitigationId: ID! } -input DeleteControlMappingInput { +input CreateControlPolicyMappingInput { + controlId: ID! + policyId: ID! +} + +input DeleteControlMitigationMappingInput { controlId: ID! mitigationId: ID! } +input DeleteControlPolicyMappingInput { + controlId: ID! + policyId: ID! +} + input CreateRiskInput { organizationId: ID! name: String! @@ -1088,11 +1121,19 @@ type UnassignTaskPayload { task: Task! } -type CreateControlMappingPayload { +type CreateControlMitigationMappingPayload { success: Boolean! } -type DeleteControlMappingPayload { +type CreateControlPolicyMappingPayload { + success: Boolean! +} + +type DeleteControlMitigationMappingPayload { + success: Boolean! +} + +type DeleteControlPolicyMappingPayload { success: Boolean! } diff --git a/pkg/server/api/console/v1/schema/schema.go b/pkg/server/api/console/v1/schema/schema.go index 7d141a6a4..ef85115df 100644 --- a/pkg/server/api/console/v1/schema/schema.go +++ b/pkg/server/api/console/v1/schema/schema.go @@ -73,6 +73,7 @@ type ComplexityRoot struct { ID func(childComplexity int) int Mitigations func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MitigationOrderBy) int Name func(childComplexity int) int + Policies func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.PolicyOrderBy) int ReferenceID func(childComplexity int) int UpdatedAt func(childComplexity int) int } @@ -87,7 +88,11 @@ type ComplexityRoot struct { Node func(childComplexity int) int } - CreateControlMappingPayload struct { + CreateControlMitigationMappingPayload struct { + Success func(childComplexity int) int + } + + CreateControlPolicyMappingPayload struct { Success func(childComplexity int) int } @@ -131,7 +136,11 @@ type ComplexityRoot struct { VendorEdge func(childComplexity int) int } - DeleteControlMappingPayload struct { + DeleteControlMitigationMappingPayload struct { + Success func(childComplexity int) int + } + + DeleteControlPolicyMappingPayload struct { Success func(childComplexity int) int } @@ -255,44 +264,46 @@ type ComplexityRoot struct { } Mutation struct { - AssignTask func(childComplexity int, input types.AssignTaskInput) int - ConfirmEmail func(childComplexity int, input types.ConfirmEmailInput) int - CreateControlMapping func(childComplexity int, input types.CreateControlMappingInput) int - CreateEvidence func(childComplexity int, input types.CreateEvidenceInput) int - CreateFramework func(childComplexity int, input types.CreateFrameworkInput) int - CreateMitigation func(childComplexity int, input types.CreateMitigationInput) int - CreateOrganization func(childComplexity int, input types.CreateOrganizationInput) int - CreatePeople func(childComplexity int, input types.CreatePeopleInput) int - CreatePolicy func(childComplexity int, input types.CreatePolicyInput) int - CreateRisk func(childComplexity int, input types.CreateRiskInput) int - CreateRiskMapping func(childComplexity int, input types.CreateRiskMappingInput) int - CreateTask func(childComplexity int, input types.CreateTaskInput) int - CreateVendor func(childComplexity int, input types.CreateVendorInput) int - DeleteControlMapping func(childComplexity int, input types.DeleteControlMappingInput) int - DeleteEvidence func(childComplexity int, input types.DeleteEvidenceInput) int - DeleteFramework func(childComplexity int, input types.DeleteFrameworkInput) int - DeleteOrganization func(childComplexity int, input types.DeleteOrganizationInput) int - DeletePeople func(childComplexity int, input types.DeletePeopleInput) int - DeletePolicy func(childComplexity int, input types.DeletePolicyInput) int - DeleteRisk func(childComplexity int, input types.DeleteRiskInput) int - DeleteRiskMapping func(childComplexity int, input types.DeleteRiskMappingInput) int - DeleteTask func(childComplexity int, input types.DeleteTaskInput) int - DeleteVendor func(childComplexity int, input types.DeleteVendorInput) int - FulfillEvidence func(childComplexity int, input types.FulfillEvidenceInput) int - ImportFramework func(childComplexity int, input types.ImportFrameworkInput) int - ImportMitigation func(childComplexity int, input types.ImportMitigationInput) int - InviteUser func(childComplexity int, input types.InviteUserInput) int - RemoveUser func(childComplexity int, input types.RemoveUserInput) int - RequestEvidence func(childComplexity int, input types.RequestEvidenceInput) int - UnassignTask func(childComplexity int, input types.UnassignTaskInput) int - UpdateFramework func(childComplexity int, input types.UpdateFrameworkInput) int - UpdateMitigation func(childComplexity int, input types.UpdateMitigationInput) int - UpdateOrganization func(childComplexity int, input types.UpdateOrganizationInput) int - UpdatePeople func(childComplexity int, input types.UpdatePeopleInput) int - UpdatePolicy func(childComplexity int, input types.UpdatePolicyInput) int - UpdateRisk func(childComplexity int, input types.UpdateRiskInput) int - UpdateTask func(childComplexity int, input types.UpdateTaskInput) int - UpdateVendor func(childComplexity int, input types.UpdateVendorInput) int + AssignTask func(childComplexity int, input types.AssignTaskInput) int + ConfirmEmail func(childComplexity int, input types.ConfirmEmailInput) int + CreateControlMitigationMapping func(childComplexity int, input types.CreateControlMitigationMappingInput) int + CreateControlPolicyMapping func(childComplexity int, input types.CreateControlPolicyMappingInput) int + CreateEvidence func(childComplexity int, input types.CreateEvidenceInput) int + CreateFramework func(childComplexity int, input types.CreateFrameworkInput) int + CreateMitigation func(childComplexity int, input types.CreateMitigationInput) int + CreateOrganization func(childComplexity int, input types.CreateOrganizationInput) int + CreatePeople func(childComplexity int, input types.CreatePeopleInput) int + CreatePolicy func(childComplexity int, input types.CreatePolicyInput) int + CreateRisk func(childComplexity int, input types.CreateRiskInput) int + CreateRiskMapping func(childComplexity int, input types.CreateRiskMappingInput) int + CreateTask func(childComplexity int, input types.CreateTaskInput) int + CreateVendor func(childComplexity int, input types.CreateVendorInput) int + DeleteControlMitigationMapping func(childComplexity int, input types.DeleteControlMitigationMappingInput) int + DeleteControlPolicyMapping func(childComplexity int, input types.DeleteControlPolicyMappingInput) int + DeleteEvidence func(childComplexity int, input types.DeleteEvidenceInput) int + DeleteFramework func(childComplexity int, input types.DeleteFrameworkInput) int + DeleteOrganization func(childComplexity int, input types.DeleteOrganizationInput) int + DeletePeople func(childComplexity int, input types.DeletePeopleInput) int + DeletePolicy func(childComplexity int, input types.DeletePolicyInput) int + DeleteRisk func(childComplexity int, input types.DeleteRiskInput) int + DeleteRiskMapping func(childComplexity int, input types.DeleteRiskMappingInput) int + DeleteTask func(childComplexity int, input types.DeleteTaskInput) int + DeleteVendor func(childComplexity int, input types.DeleteVendorInput) int + FulfillEvidence func(childComplexity int, input types.FulfillEvidenceInput) int + ImportFramework func(childComplexity int, input types.ImportFrameworkInput) int + ImportMitigation func(childComplexity int, input types.ImportMitigationInput) int + InviteUser func(childComplexity int, input types.InviteUserInput) int + RemoveUser func(childComplexity int, input types.RemoveUserInput) int + RequestEvidence func(childComplexity int, input types.RequestEvidenceInput) int + UnassignTask func(childComplexity int, input types.UnassignTaskInput) int + UpdateFramework func(childComplexity int, input types.UpdateFrameworkInput) int + UpdateMitigation func(childComplexity int, input types.UpdateMitigationInput) int + UpdateOrganization func(childComplexity int, input types.UpdateOrganizationInput) int + UpdatePeople func(childComplexity int, input types.UpdatePeopleInput) int + UpdatePolicy func(childComplexity int, input types.UpdatePolicyInput) int + UpdateRisk func(childComplexity int, input types.UpdateRiskInput) int + UpdateTask func(childComplexity int, input types.UpdateTaskInput) int + UpdateVendor func(childComplexity int, input types.UpdateVendorInput) int } Organization struct { @@ -349,6 +360,7 @@ type ComplexityRoot struct { Policy struct { Content func(childComplexity int) int + Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) int CreatedAt func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int @@ -517,6 +529,7 @@ type ComplexityRoot struct { type ControlResolver interface { Mitigations(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.MitigationOrderBy) (*types.MitigationConnection, error) + Policies(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.PolicyOrderBy) (*types.PolicyConnection, error) } type EvidenceResolver interface { FileURL(ctx context.Context, obj *types.Evidence) (*string, error) @@ -549,8 +562,10 @@ type MutationResolver interface { CreateMitigation(ctx context.Context, input types.CreateMitigationInput) (*types.CreateMitigationPayload, error) UpdateMitigation(ctx context.Context, input types.UpdateMitigationInput) (*types.UpdateMitigationPayload, error) ImportMitigation(ctx context.Context, input types.ImportMitigationInput) (*types.ImportMitigationPayload, error) - CreateControlMapping(ctx context.Context, input types.CreateControlMappingInput) (*types.CreateControlMappingPayload, error) - DeleteControlMapping(ctx context.Context, input types.DeleteControlMappingInput) (*types.DeleteControlMappingPayload, error) + CreateControlMitigationMapping(ctx context.Context, input types.CreateControlMitigationMappingInput) (*types.CreateControlMitigationMappingPayload, error) + CreateControlPolicyMapping(ctx context.Context, input types.CreateControlPolicyMappingInput) (*types.CreateControlPolicyMappingPayload, error) + DeleteControlMitigationMapping(ctx context.Context, input types.DeleteControlMitigationMappingInput) (*types.DeleteControlMitigationMappingPayload, error) + DeleteControlPolicyMapping(ctx context.Context, input types.DeleteControlPolicyMappingInput) (*types.DeleteControlPolicyMappingPayload, error) CreateTask(ctx context.Context, input types.CreateTaskInput) (*types.CreateTaskPayload, error) UpdateTask(ctx context.Context, input types.UpdateTaskInput) (*types.UpdateTaskPayload, error) DeleteTask(ctx context.Context, input types.DeleteTaskInput) (*types.DeleteTaskPayload, error) @@ -581,6 +596,7 @@ type OrganizationResolver interface { } type PolicyResolver interface { Owner(ctx context.Context, obj *types.Policy) (*types.People, error) + Controls(ctx context.Context, obj *types.Policy, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) } type QueryResolver interface { Node(ctx context.Context, id gid.GID) (types.Node, error) @@ -670,6 +686,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Control.Name(childComplexity), true + case "Control.policies": + if e.complexity.Control.Policies == nil { + break + } + + args, err := ec.field_Control_policies_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Control.Policies(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.PolicyOrderBy)), true + case "Control.referenceId": if e.complexity.Control.ReferenceID == nil { break @@ -712,12 +740,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ControlEdge.Node(childComplexity), true - case "CreateControlMappingPayload.success": - if e.complexity.CreateControlMappingPayload.Success == nil { + case "CreateControlMitigationMappingPayload.success": + if e.complexity.CreateControlMitigationMappingPayload.Success == nil { break } - return e.complexity.CreateControlMappingPayload.Success(childComplexity), true + return e.complexity.CreateControlMitigationMappingPayload.Success(childComplexity), true + + case "CreateControlPolicyMappingPayload.success": + if e.complexity.CreateControlPolicyMappingPayload.Success == nil { + break + } + + return e.complexity.CreateControlPolicyMappingPayload.Success(childComplexity), true case "CreateEvidencePayload.evidenceEdge": if e.complexity.CreateEvidencePayload.EvidenceEdge == nil { @@ -789,12 +824,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CreateVendorPayload.VendorEdge(childComplexity), true - case "DeleteControlMappingPayload.success": - if e.complexity.DeleteControlMappingPayload.Success == nil { + case "DeleteControlMitigationMappingPayload.success": + if e.complexity.DeleteControlMitigationMappingPayload.Success == nil { break } - return e.complexity.DeleteControlMappingPayload.Success(childComplexity), true + return e.complexity.DeleteControlMitigationMappingPayload.Success(childComplexity), true + + case "DeleteControlPolicyMappingPayload.success": + if e.complexity.DeleteControlPolicyMappingPayload.Success == nil { + break + } + + return e.complexity.DeleteControlPolicyMappingPayload.Success(childComplexity), true case "DeleteEvidencePayload.deletedEvidenceId": if e.complexity.DeleteEvidencePayload.DeletedEvidenceID == nil { @@ -1211,17 +1253,29 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.ConfirmEmail(childComplexity, args["input"].(types.ConfirmEmailInput)), true - case "Mutation.createControlMapping": - if e.complexity.Mutation.CreateControlMapping == nil { + case "Mutation.createControlMitigationMapping": + if e.complexity.Mutation.CreateControlMitigationMapping == nil { break } - args, err := ec.field_Mutation_createControlMapping_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_createControlMitigationMapping_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.CreateControlMapping(childComplexity, args["input"].(types.CreateControlMappingInput)), true + return e.complexity.Mutation.CreateControlMitigationMapping(childComplexity, args["input"].(types.CreateControlMitigationMappingInput)), true + + case "Mutation.createControlPolicyMapping": + if e.complexity.Mutation.CreateControlPolicyMapping == nil { + break + } + + args, err := ec.field_Mutation_createControlPolicyMapping_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateControlPolicyMapping(childComplexity, args["input"].(types.CreateControlPolicyMappingInput)), true case "Mutation.createEvidence": if e.complexity.Mutation.CreateEvidence == nil { @@ -1343,17 +1397,29 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.CreateVendor(childComplexity, args["input"].(types.CreateVendorInput)), true - case "Mutation.deleteControlMapping": - if e.complexity.Mutation.DeleteControlMapping == nil { + case "Mutation.deleteControlMitigationMapping": + if e.complexity.Mutation.DeleteControlMitigationMapping == nil { break } - args, err := ec.field_Mutation_deleteControlMapping_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_deleteControlMitigationMapping_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.DeleteControlMapping(childComplexity, args["input"].(types.DeleteControlMappingInput)), true + return e.complexity.Mutation.DeleteControlMitigationMapping(childComplexity, args["input"].(types.DeleteControlMitigationMappingInput)), true + + case "Mutation.deleteControlPolicyMapping": + if e.complexity.Mutation.DeleteControlPolicyMapping == nil { + break + } + + args, err := ec.field_Mutation_deleteControlPolicyMapping_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteControlPolicyMapping(childComplexity, args["input"].(types.DeleteControlPolicyMappingInput)), true case "Mutation.deleteEvidence": if e.complexity.Mutation.DeleteEvidence == nil { @@ -1902,6 +1968,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Policy.Content(childComplexity), true + case "Policy.controls": + if e.complexity.Policy.Controls == nil { + break + } + + args, err := ec.field_Policy_controls_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Policy.Controls(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.ControlOrderBy)), true + case "Policy.createdAt": if e.complexity.Policy.CreatedAt == nil { break @@ -2486,7 +2564,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputAssignTaskInput, ec.unmarshalInputConfirmEmailInput, ec.unmarshalInputControlOrder, - ec.unmarshalInputCreateControlMappingInput, + ec.unmarshalInputCreateControlMitigationMappingInput, + ec.unmarshalInputCreateControlPolicyMappingInput, ec.unmarshalInputCreateEvidenceInput, ec.unmarshalInputCreateFrameworkInput, ec.unmarshalInputCreateMitigationInput, @@ -2497,7 +2576,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputCreateRiskMappingInput, ec.unmarshalInputCreateTaskInput, ec.unmarshalInputCreateVendorInput, - ec.unmarshalInputDeleteControlMappingInput, + ec.unmarshalInputDeleteControlMitigationMappingInput, + ec.unmarshalInputDeleteControlPolicyMappingInput, ec.unmarshalInputDeleteEvidenceInput, ec.unmarshalInputDeleteFrameworkInput, ec.unmarshalInputDeleteOrganizationInput, @@ -3079,6 +3159,14 @@ type Control implements Node { orderBy: MitigationOrder ): MitigationConnection! @goField(forceResolver: true) + policies( + first: Int + after: CursorKey + last: Int + before: CursorKey + orderBy: PolicyOrder + ): PolicyConnection! @goField(forceResolver: true) + createdAt: Datetime! updatedAt: Datetime! } @@ -3161,6 +3249,15 @@ type Policy implements Node { content: String! reviewDate: Datetime owner: People! @goField(forceResolver: true) + + controls( + first: Int + after: CursorKey + last: Int + before: CursorKey + orderBy: ControlOrder + ): ControlConnection! @goField(forceResolver: true) + createdAt: Datetime! updatedAt: Datetime! } @@ -3358,12 +3455,18 @@ type Mutation { importMitigation(input: ImportMitigationInput!): ImportMitigationPayload! # Control mutations - createControlMapping( - input: CreateControlMappingInput! - ): CreateControlMappingPayload! - deleteControlMapping( - input: DeleteControlMappingInput! - ): DeleteControlMappingPayload! + createControlMitigationMapping( + input: CreateControlMitigationMappingInput! + ): CreateControlMitigationMappingPayload! + createControlPolicyMapping( + input: CreateControlPolicyMappingInput! + ): CreateControlPolicyMappingPayload! + deleteControlMitigationMapping( + input: DeleteControlMitigationMappingInput! + ): DeleteControlMitigationMappingPayload! + deleteControlPolicyMapping( + input: DeleteControlPolicyMappingInput! + ): DeleteControlPolicyMappingPayload! # Task mutations createTask(input: CreateTaskInput!): CreateTaskPayload! @@ -3528,16 +3631,26 @@ input UnassignTaskInput { taskId: ID! } -input CreateControlMappingInput { +input CreateControlMitigationMappingInput { controlId: ID! mitigationId: ID! } -input DeleteControlMappingInput { +input CreateControlPolicyMappingInput { + controlId: ID! + policyId: ID! +} + +input DeleteControlMitigationMappingInput { controlId: ID! mitigationId: ID! } +input DeleteControlPolicyMappingInput { + controlId: ID! + policyId: ID! +} + input CreateRiskInput { organizationId: ID! name: String! @@ -3719,11 +3832,19 @@ type UnassignTaskPayload { task: Task! } -type CreateControlMappingPayload { +type CreateControlMitigationMappingPayload { success: Boolean! } -type DeleteControlMappingPayload { +type CreateControlPolicyMappingPayload { + success: Boolean! +} + +type DeleteControlMitigationMappingPayload { + success: Boolean! +} + +type DeleteControlPolicyMappingPayload { success: Boolean! } @@ -3889,6 +4010,101 @@ func (ec *executionContext) field_Control_mitigations_argsOrderBy( return zeroVal, nil } +func (ec *executionContext) field_Control_policies_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Control_policies_argsFirst(ctx, rawArgs) + if err != nil { + return nil, err + } + args["first"] = arg0 + arg1, err := ec.field_Control_policies_argsAfter(ctx, rawArgs) + if err != nil { + return nil, err + } + args["after"] = arg1 + arg2, err := ec.field_Control_policies_argsLast(ctx, rawArgs) + if err != nil { + return nil, err + } + args["last"] = arg2 + arg3, err := ec.field_Control_policies_argsBefore(ctx, rawArgs) + if err != nil { + return nil, err + } + args["before"] = arg3 + arg4, err := ec.field_Control_policies_argsOrderBy(ctx, rawArgs) + if err != nil { + return nil, err + } + args["orderBy"] = arg4 + return args, nil +} +func (ec *executionContext) field_Control_policies_argsFirst( + ctx context.Context, + rawArgs map[string]any, +) (*int, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + if tmp, ok := rawArgs["first"]; ok { + return ec.unmarshalOInt2ᚖint(ctx, tmp) + } + + var zeroVal *int + return zeroVal, nil +} + +func (ec *executionContext) field_Control_policies_argsAfter( + ctx context.Context, + rawArgs map[string]any, +) (*page.CursorKey, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + if tmp, ok := rawArgs["after"]; ok { + return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) + } + + var zeroVal *page.CursorKey + return zeroVal, nil +} + +func (ec *executionContext) field_Control_policies_argsLast( + ctx context.Context, + rawArgs map[string]any, +) (*int, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) + if tmp, ok := rawArgs["last"]; ok { + return ec.unmarshalOInt2ᚖint(ctx, tmp) + } + + var zeroVal *int + return zeroVal, nil +} + +func (ec *executionContext) field_Control_policies_argsBefore( + ctx context.Context, + rawArgs map[string]any, +) (*page.CursorKey, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) + if tmp, ok := rawArgs["before"]; ok { + return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) + } + + var zeroVal *page.CursorKey + return zeroVal, nil +} + +func (ec *executionContext) field_Control_policies_argsOrderBy( + ctx context.Context, + rawArgs map[string]any, +) (*types.PolicyOrderBy, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) + if tmp, ok := rawArgs["orderBy"]; ok { + return ec.unmarshalOPolicyOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPolicyOrderBy(ctx, tmp) + } + + var zeroVal *types.PolicyOrderBy + return zeroVal, nil +} + func (ec *executionContext) field_Framework_controls_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -4315,26 +4531,49 @@ func (ec *executionContext) field_Mutation_confirmEmail_argsInput( return zeroVal, nil } -func (ec *executionContext) field_Mutation_createControlMapping_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Mutation_createControlMitigationMapping_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := ec.field_Mutation_createControlMapping_argsInput(ctx, rawArgs) + arg0, err := ec.field_Mutation_createControlMitigationMapping_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } -func (ec *executionContext) field_Mutation_createControlMapping_argsInput( +func (ec *executionContext) field_Mutation_createControlMitigationMapping_argsInput( ctx context.Context, rawArgs map[string]any, -) (types.CreateControlMappingInput, error) { +) (types.CreateControlMitigationMappingInput, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { - return ec.unmarshalNCreateControlMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMappingInput(ctx, tmp) + return ec.unmarshalNCreateControlMitigationMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMitigationMappingInput(ctx, tmp) } - var zeroVal types.CreateControlMappingInput + var zeroVal types.CreateControlMitigationMappingInput + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_createControlPolicyMapping_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_createControlPolicyMapping_argsInput(ctx, rawArgs) + if err != nil { + return nil, err + } + args["input"] = arg0 + return args, nil +} +func (ec *executionContext) field_Mutation_createControlPolicyMapping_argsInput( + ctx context.Context, + rawArgs map[string]any, +) (types.CreateControlPolicyMappingInput, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + if tmp, ok := rawArgs["input"]; ok { + return ec.unmarshalNCreateControlPolicyMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlPolicyMappingInput(ctx, tmp) + } + + var zeroVal types.CreateControlPolicyMappingInput return zeroVal, nil } @@ -4568,26 +4807,49 @@ func (ec *executionContext) field_Mutation_createVendor_argsInput( return zeroVal, nil } -func (ec *executionContext) field_Mutation_deleteControlMapping_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Mutation_deleteControlMitigationMapping_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := ec.field_Mutation_deleteControlMapping_argsInput(ctx, rawArgs) + arg0, err := ec.field_Mutation_deleteControlMitigationMapping_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } -func (ec *executionContext) field_Mutation_deleteControlMapping_argsInput( +func (ec *executionContext) field_Mutation_deleteControlMitigationMapping_argsInput( ctx context.Context, rawArgs map[string]any, -) (types.DeleteControlMappingInput, error) { +) (types.DeleteControlMitigationMappingInput, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { - return ec.unmarshalNDeleteControlMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMappingInput(ctx, tmp) + return ec.unmarshalNDeleteControlMitigationMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMitigationMappingInput(ctx, tmp) } - var zeroVal types.DeleteControlMappingInput + var zeroVal types.DeleteControlMitigationMappingInput + return zeroVal, nil +} + +func (ec *executionContext) field_Mutation_deleteControlPolicyMapping_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Mutation_deleteControlPolicyMapping_argsInput(ctx, rawArgs) + if err != nil { + return nil, err + } + args["input"] = arg0 + return args, nil +} +func (ec *executionContext) field_Mutation_deleteControlPolicyMapping_argsInput( + ctx context.Context, + rawArgs map[string]any, +) (types.DeleteControlPolicyMappingInput, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + if tmp, ok := rawArgs["input"]; ok { + return ec.unmarshalNDeleteControlPolicyMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlPolicyMappingInput(ctx, tmp) + } + + var zeroVal types.DeleteControlPolicyMappingInput return zeroVal, nil } @@ -5808,6 +6070,101 @@ func (ec *executionContext) field_Organization_vendors_argsOrderBy( return zeroVal, nil } +func (ec *executionContext) field_Policy_controls_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := ec.field_Policy_controls_argsFirst(ctx, rawArgs) + if err != nil { + return nil, err + } + args["first"] = arg0 + arg1, err := ec.field_Policy_controls_argsAfter(ctx, rawArgs) + if err != nil { + return nil, err + } + args["after"] = arg1 + arg2, err := ec.field_Policy_controls_argsLast(ctx, rawArgs) + if err != nil { + return nil, err + } + args["last"] = arg2 + arg3, err := ec.field_Policy_controls_argsBefore(ctx, rawArgs) + if err != nil { + return nil, err + } + args["before"] = arg3 + arg4, err := ec.field_Policy_controls_argsOrderBy(ctx, rawArgs) + if err != nil { + return nil, err + } + args["orderBy"] = arg4 + return args, nil +} +func (ec *executionContext) field_Policy_controls_argsFirst( + ctx context.Context, + rawArgs map[string]any, +) (*int, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + if tmp, ok := rawArgs["first"]; ok { + return ec.unmarshalOInt2ᚖint(ctx, tmp) + } + + var zeroVal *int + return zeroVal, nil +} + +func (ec *executionContext) field_Policy_controls_argsAfter( + ctx context.Context, + rawArgs map[string]any, +) (*page.CursorKey, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + if tmp, ok := rawArgs["after"]; ok { + return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) + } + + var zeroVal *page.CursorKey + return zeroVal, nil +} + +func (ec *executionContext) field_Policy_controls_argsLast( + ctx context.Context, + rawArgs map[string]any, +) (*int, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) + if tmp, ok := rawArgs["last"]; ok { + return ec.unmarshalOInt2ᚖint(ctx, tmp) + } + + var zeroVal *int + return zeroVal, nil +} + +func (ec *executionContext) field_Policy_controls_argsBefore( + ctx context.Context, + rawArgs map[string]any, +) (*page.CursorKey, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) + if tmp, ok := rawArgs["before"]; ok { + return ec.unmarshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋpageᚐCursorKey(ctx, tmp) + } + + var zeroVal *page.CursorKey + return zeroVal, nil +} + +func (ec *executionContext) field_Policy_controls_argsOrderBy( + ctx context.Context, + rawArgs map[string]any, +) (*types.ControlOrderBy, error) { + ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) + if tmp, ok := rawArgs["orderBy"]; ok { + return ec.unmarshalOControlOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlOrderBy(ctx, tmp) + } + + var zeroVal *types.ControlOrderBy + return zeroVal, nil +} + func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -6584,6 +6941,67 @@ func (ec *executionContext) fieldContext_Control_mitigations(ctx context.Context return fc, nil } +func (ec *executionContext) _Control_policies(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Control_policies(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Control().Policies(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.PolicyOrderBy)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*types.PolicyConnection) + fc.Result = res + return ec.marshalNPolicyConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPolicyConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Control_policies(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Control", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_PolicyConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_PolicyConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PolicyConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Control_policies_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Control_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Control) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Control_createdAt(ctx, field) if err != nil { @@ -6869,6 +7287,8 @@ func (ec *executionContext) fieldContext_ControlEdge_node(_ context.Context, fie return ec.fieldContext_Control_description(ctx, field) case "mitigations": return ec.fieldContext_Control_mitigations(ctx, field) + case "policies": + return ec.fieldContext_Control_policies(ctx, field) case "createdAt": return ec.fieldContext_Control_createdAt(ctx, field) case "updatedAt": @@ -6880,8 +7300,8 @@ func (ec *executionContext) fieldContext_ControlEdge_node(_ context.Context, fie return fc, nil } -func (ec *executionContext) _CreateControlMappingPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.CreateControlMappingPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CreateControlMappingPayload_success(ctx, field) +func (ec *executionContext) _CreateControlMitigationMappingPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.CreateControlMitigationMappingPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateControlMitigationMappingPayload_success(ctx, field) if err != nil { return graphql.Null } @@ -6911,9 +7331,53 @@ func (ec *executionContext) _CreateControlMappingPayload_success(ctx context.Con return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CreateControlMappingPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CreateControlMitigationMappingPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "CreateControlMappingPayload", + Object: "CreateControlMitigationMappingPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CreateControlPolicyMappingPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.CreateControlPolicyMappingPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateControlPolicyMappingPayload_success(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Success, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CreateControlPolicyMappingPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CreateControlPolicyMappingPayload", Field: field, IsMethod: false, IsResolver: false, @@ -7418,8 +7882,8 @@ func (ec *executionContext) fieldContext_CreateVendorPayload_vendorEdge(_ contex return fc, nil } -func (ec *executionContext) _DeleteControlMappingPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.DeleteControlMappingPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_DeleteControlMappingPayload_success(ctx, field) +func (ec *executionContext) _DeleteControlMitigationMappingPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.DeleteControlMitigationMappingPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeleteControlMitigationMappingPayload_success(ctx, field) if err != nil { return graphql.Null } @@ -7449,9 +7913,53 @@ func (ec *executionContext) _DeleteControlMappingPayload_success(ctx context.Con return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DeleteControlMappingPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DeleteControlMitigationMappingPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "DeleteControlMappingPayload", + Object: "DeleteControlMitigationMappingPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DeleteControlPolicyMappingPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.DeleteControlPolicyMappingPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeleteControlPolicyMappingPayload_success(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Success, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_DeleteControlPolicyMappingPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DeleteControlPolicyMappingPayload", Field: field, IsMethod: false, IsResolver: false, @@ -11105,8 +11613,8 @@ func (ec *executionContext) fieldContext_Mutation_importMitigation(ctx context.C return fc, nil } -func (ec *executionContext) _Mutation_createControlMapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createControlMapping(ctx, field) +func (ec *executionContext) _Mutation_createControlMitigationMapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createControlMitigationMapping(ctx, field) if err != nil { return graphql.Null } @@ -11119,7 +11627,7 @@ func (ec *executionContext) _Mutation_createControlMapping(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateControlMapping(rctx, fc.Args["input"].(types.CreateControlMappingInput)) + return ec.resolvers.Mutation().CreateControlMitigationMapping(rctx, fc.Args["input"].(types.CreateControlMitigationMappingInput)) }) if err != nil { ec.Error(ctx, err) @@ -11131,12 +11639,12 @@ func (ec *executionContext) _Mutation_createControlMapping(ctx context.Context, } return graphql.Null } - res := resTmp.(*types.CreateControlMappingPayload) + res := resTmp.(*types.CreateControlMitigationMappingPayload) fc.Result = res - return ec.marshalNCreateControlMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMappingPayload(ctx, field.Selections, res) + return ec.marshalNCreateControlMitigationMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMitigationMappingPayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createControlMapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createControlMitigationMapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -11145,9 +11653,9 @@ func (ec *executionContext) fieldContext_Mutation_createControlMapping(ctx conte Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "success": - return ec.fieldContext_CreateControlMappingPayload_success(ctx, field) + return ec.fieldContext_CreateControlMitigationMappingPayload_success(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type CreateControlMappingPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CreateControlMitigationMappingPayload", field.Name) }, } defer func() { @@ -11157,15 +11665,15 @@ func (ec *executionContext) fieldContext_Mutation_createControlMapping(ctx conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createControlMapping_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createControlMitigationMapping_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteControlMapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteControlMapping(ctx, field) +func (ec *executionContext) _Mutation_createControlPolicyMapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createControlPolicyMapping(ctx, field) if err != nil { return graphql.Null } @@ -11178,7 +11686,7 @@ func (ec *executionContext) _Mutation_deleteControlMapping(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteControlMapping(rctx, fc.Args["input"].(types.DeleteControlMappingInput)) + return ec.resolvers.Mutation().CreateControlPolicyMapping(rctx, fc.Args["input"].(types.CreateControlPolicyMappingInput)) }) if err != nil { ec.Error(ctx, err) @@ -11190,12 +11698,12 @@ func (ec *executionContext) _Mutation_deleteControlMapping(ctx context.Context, } return graphql.Null } - res := resTmp.(*types.DeleteControlMappingPayload) + res := resTmp.(*types.CreateControlPolicyMappingPayload) fc.Result = res - return ec.marshalNDeleteControlMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMappingPayload(ctx, field.Selections, res) + return ec.marshalNCreateControlPolicyMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlPolicyMappingPayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteControlMapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createControlPolicyMapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -11204,9 +11712,9 @@ func (ec *executionContext) fieldContext_Mutation_deleteControlMapping(ctx conte Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "success": - return ec.fieldContext_DeleteControlMappingPayload_success(ctx, field) + return ec.fieldContext_CreateControlPolicyMappingPayload_success(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type DeleteControlMappingPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CreateControlPolicyMappingPayload", field.Name) }, } defer func() { @@ -11216,7 +11724,125 @@ func (ec *executionContext) fieldContext_Mutation_deleteControlMapping(ctx conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteControlMapping_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createControlPolicyMapping_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteControlMitigationMapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteControlMitigationMapping(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteControlMitigationMapping(rctx, fc.Args["input"].(types.DeleteControlMitigationMappingInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*types.DeleteControlMitigationMappingPayload) + fc.Result = res + return ec.marshalNDeleteControlMitigationMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMitigationMappingPayload(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteControlMitigationMapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "success": + return ec.fieldContext_DeleteControlMitigationMappingPayload_success(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DeleteControlMitigationMappingPayload", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteControlMitigationMapping_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteControlPolicyMapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteControlPolicyMapping(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteControlPolicyMapping(rctx, fc.Args["input"].(types.DeleteControlPolicyMappingInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*types.DeleteControlPolicyMappingPayload) + fc.Result = res + return ec.marshalNDeleteControlPolicyMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlPolicyMappingPayload(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_deleteControlPolicyMapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "success": + return ec.fieldContext_DeleteControlPolicyMappingPayload_success(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DeleteControlPolicyMappingPayload", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteControlPolicyMapping_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -14051,6 +14677,67 @@ func (ec *executionContext) fieldContext_Policy_owner(_ context.Context, field g return fc, nil } +func (ec *executionContext) _Policy_controls(ctx context.Context, field graphql.CollectedField, obj *types.Policy) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Policy_controls(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Policy().Controls(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.ControlOrderBy)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*types.ControlConnection) + fc.Result = res + return ec.marshalNControlConnection2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐControlConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Policy_controls(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Policy", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_ControlConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ControlConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ControlConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Policy_controls_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Policy_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Policy) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Policy_createdAt(ctx, field) if err != nil { @@ -14338,6 +15025,8 @@ func (ec *executionContext) fieldContext_PolicyEdge_node(_ context.Context, fiel return ec.fieldContext_Policy_reviewDate(ctx, field) case "owner": return ec.fieldContext_Policy_owner(ctx, field) + case "controls": + return ec.fieldContext_Policy_controls(ctx, field) case "createdAt": return ec.fieldContext_Policy_createdAt(ctx, field) case "updatedAt": @@ -16354,6 +17043,8 @@ func (ec *executionContext) fieldContext_UpdatePolicyPayload_policy(_ context.Co return ec.fieldContext_Policy_reviewDate(ctx, field) case "owner": return ec.fieldContext_Policy_owner(ctx, field) + case "controls": + return ec.fieldContext_Policy_controls(ctx, field) case "createdAt": return ec.fieldContext_Policy_createdAt(ctx, field) case "updatedAt": @@ -19926,8 +20617,8 @@ func (ec *executionContext) unmarshalInputControlOrder(ctx context.Context, obj return it, nil } -func (ec *executionContext) unmarshalInputCreateControlMappingInput(ctx context.Context, obj any) (types.CreateControlMappingInput, error) { - var it types.CreateControlMappingInput +func (ec *executionContext) unmarshalInputCreateControlMitigationMappingInput(ctx context.Context, obj any) (types.CreateControlMitigationMappingInput, error) { + var it types.CreateControlMitigationMappingInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19960,6 +20651,40 @@ func (ec *executionContext) unmarshalInputCreateControlMappingInput(ctx context. return it, nil } +func (ec *executionContext) unmarshalInputCreateControlPolicyMappingInput(ctx context.Context, obj any) (types.CreateControlPolicyMappingInput, error) { + var it types.CreateControlPolicyMappingInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"controlId", "policyId"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "controlId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("controlId")) + data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v) + if err != nil { + return it, err + } + it.ControlID = data + case "policyId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("policyId")) + data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v) + if err != nil { + return it, err + } + it.PolicyID = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputCreateEvidenceInput(ctx context.Context, obj any) (types.CreateEvidenceInput, error) { var it types.CreateEvidenceInput asMap := map[string]any{} @@ -20510,8 +21235,8 @@ func (ec *executionContext) unmarshalInputCreateVendorInput(ctx context.Context, return it, nil } -func (ec *executionContext) unmarshalInputDeleteControlMappingInput(ctx context.Context, obj any) (types.DeleteControlMappingInput, error) { - var it types.DeleteControlMappingInput +func (ec *executionContext) unmarshalInputDeleteControlMitigationMappingInput(ctx context.Context, obj any) (types.DeleteControlMitigationMappingInput, error) { + var it types.DeleteControlMitigationMappingInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -20544,6 +21269,40 @@ func (ec *executionContext) unmarshalInputDeleteControlMappingInput(ctx context. return it, nil } +func (ec *executionContext) unmarshalInputDeleteControlPolicyMappingInput(ctx context.Context, obj any) (types.DeleteControlPolicyMappingInput, error) { + var it types.DeleteControlPolicyMappingInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"controlId", "policyId"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "controlId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("controlId")) + data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v) + if err != nil { + return it, err + } + it.ControlID = data + case "policyId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("policyId")) + data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v) + if err != nil { + return it, err + } + it.PolicyID = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputDeleteEvidenceInput(ctx context.Context, obj any) (types.DeleteEvidenceInput, error) { var it types.DeleteEvidenceInput asMap := map[string]any{} @@ -22099,6 +22858,42 @@ func (ec *executionContext) _Control(ctx context.Context, sel ast.SelectionSet, continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "policies": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Control_policies(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "createdAt": out.Values[i] = ec._Control_createdAt(ctx, field, obj) @@ -22221,19 +23016,58 @@ func (ec *executionContext) _ControlEdge(ctx context.Context, sel ast.SelectionS return out } -var createControlMappingPayloadImplementors = []string{"CreateControlMappingPayload"} +var createControlMitigationMappingPayloadImplementors = []string{"CreateControlMitigationMappingPayload"} -func (ec *executionContext) _CreateControlMappingPayload(ctx context.Context, sel ast.SelectionSet, obj *types.CreateControlMappingPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, createControlMappingPayloadImplementors) +func (ec *executionContext) _CreateControlMitigationMappingPayload(ctx context.Context, sel ast.SelectionSet, obj *types.CreateControlMitigationMappingPayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, createControlMitigationMappingPayloadImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("CreateControlMappingPayload") + out.Values[i] = graphql.MarshalString("CreateControlMitigationMappingPayload") case "success": - out.Values[i] = ec._CreateControlMappingPayload_success(ctx, field, obj) + out.Values[i] = ec._CreateControlMitigationMappingPayload_success(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var createControlPolicyMappingPayloadImplementors = []string{"CreateControlPolicyMappingPayload"} + +func (ec *executionContext) _CreateControlPolicyMappingPayload(ctx context.Context, sel ast.SelectionSet, obj *types.CreateControlPolicyMappingPayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, createControlPolicyMappingPayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CreateControlPolicyMappingPayload") + case "success": + out.Values[i] = ec._CreateControlPolicyMappingPayload_success(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -22650,19 +23484,58 @@ func (ec *executionContext) _CreateVendorPayload(ctx context.Context, sel ast.Se return out } -var deleteControlMappingPayloadImplementors = []string{"DeleteControlMappingPayload"} +var deleteControlMitigationMappingPayloadImplementors = []string{"DeleteControlMitigationMappingPayload"} -func (ec *executionContext) _DeleteControlMappingPayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeleteControlMappingPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, deleteControlMappingPayloadImplementors) +func (ec *executionContext) _DeleteControlMitigationMappingPayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeleteControlMitigationMappingPayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, deleteControlMitigationMappingPayloadImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("DeleteControlMappingPayload") + out.Values[i] = graphql.MarshalString("DeleteControlMitigationMappingPayload") case "success": - out.Values[i] = ec._DeleteControlMappingPayload_success(ctx, field, obj) + out.Values[i] = ec._DeleteControlMitigationMappingPayload_success(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var deleteControlPolicyMappingPayloadImplementors = []string{"DeleteControlPolicyMappingPayload"} + +func (ec *executionContext) _DeleteControlPolicyMappingPayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeleteControlPolicyMappingPayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, deleteControlPolicyMappingPayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("DeleteControlPolicyMappingPayload") + case "success": + out.Values[i] = ec._DeleteControlPolicyMappingPayload_success(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -24003,16 +24876,30 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "createControlMapping": + case "createControlMitigationMapping": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createControlMapping(ctx, field) + return ec._Mutation_createControlMitigationMapping(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "deleteControlMapping": + case "createControlPolicyMapping": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_deleteControlMapping(ctx, field) + return ec._Mutation_createControlPolicyMapping(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteControlMitigationMapping": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteControlMitigationMapping(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteControlPolicyMapping": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteControlPolicyMapping(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -24859,6 +25746,42 @@ func (ec *executionContext) _Policy(ctx context.Context, sel ast.SelectionSet, o continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "controls": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Policy_controls(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "createdAt": out.Values[i] = ec._Policy_createdAt(ctx, field, obj) @@ -26852,23 +27775,42 @@ var ( } ) -func (ec *executionContext) unmarshalNCreateControlMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMappingInput(ctx context.Context, v any) (types.CreateControlMappingInput, error) { - res, err := ec.unmarshalInputCreateControlMappingInput(ctx, v) +func (ec *executionContext) unmarshalNCreateControlMitigationMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMitigationMappingInput(ctx context.Context, v any) (types.CreateControlMitigationMappingInput, error) { + res, err := ec.unmarshalInputCreateControlMitigationMappingInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNCreateControlMappingPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMappingPayload(ctx context.Context, sel ast.SelectionSet, v types.CreateControlMappingPayload) graphql.Marshaler { - return ec._CreateControlMappingPayload(ctx, sel, &v) +func (ec *executionContext) marshalNCreateControlMitigationMappingPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMitigationMappingPayload(ctx context.Context, sel ast.SelectionSet, v types.CreateControlMitigationMappingPayload) graphql.Marshaler { + return ec._CreateControlMitigationMappingPayload(ctx, sel, &v) } -func (ec *executionContext) marshalNCreateControlMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMappingPayload(ctx context.Context, sel ast.SelectionSet, v *types.CreateControlMappingPayload) graphql.Marshaler { +func (ec *executionContext) marshalNCreateControlMitigationMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlMitigationMappingPayload(ctx context.Context, sel ast.SelectionSet, v *types.CreateControlMitigationMappingPayload) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._CreateControlMappingPayload(ctx, sel, v) + return ec._CreateControlMitigationMappingPayload(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNCreateControlPolicyMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlPolicyMappingInput(ctx context.Context, v any) (types.CreateControlPolicyMappingInput, error) { + res, err := ec.unmarshalInputCreateControlPolicyMappingInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNCreateControlPolicyMappingPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlPolicyMappingPayload(ctx context.Context, sel ast.SelectionSet, v types.CreateControlPolicyMappingPayload) graphql.Marshaler { + return ec._CreateControlPolicyMappingPayload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNCreateControlPolicyMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateControlPolicyMappingPayload(ctx context.Context, sel ast.SelectionSet, v *types.CreateControlPolicyMappingPayload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CreateControlPolicyMappingPayload(ctx, sel, v) } func (ec *executionContext) unmarshalNCreateEvidenceInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateEvidenceInput(ctx context.Context, v any) (types.CreateEvidenceInput, error) { @@ -27091,23 +28033,42 @@ func (ec *executionContext) marshalNDatetime2timeᚐTime(ctx context.Context, se return res } -func (ec *executionContext) unmarshalNDeleteControlMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMappingInput(ctx context.Context, v any) (types.DeleteControlMappingInput, error) { - res, err := ec.unmarshalInputDeleteControlMappingInput(ctx, v) +func (ec *executionContext) unmarshalNDeleteControlMitigationMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMitigationMappingInput(ctx context.Context, v any) (types.DeleteControlMitigationMappingInput, error) { + res, err := ec.unmarshalInputDeleteControlMitigationMappingInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNDeleteControlMappingPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMappingPayload(ctx context.Context, sel ast.SelectionSet, v types.DeleteControlMappingPayload) graphql.Marshaler { - return ec._DeleteControlMappingPayload(ctx, sel, &v) +func (ec *executionContext) marshalNDeleteControlMitigationMappingPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMitigationMappingPayload(ctx context.Context, sel ast.SelectionSet, v types.DeleteControlMitigationMappingPayload) graphql.Marshaler { + return ec._DeleteControlMitigationMappingPayload(ctx, sel, &v) } -func (ec *executionContext) marshalNDeleteControlMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMappingPayload(ctx context.Context, sel ast.SelectionSet, v *types.DeleteControlMappingPayload) graphql.Marshaler { +func (ec *executionContext) marshalNDeleteControlMitigationMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlMitigationMappingPayload(ctx context.Context, sel ast.SelectionSet, v *types.DeleteControlMitigationMappingPayload) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._DeleteControlMappingPayload(ctx, sel, v) + return ec._DeleteControlMitigationMappingPayload(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNDeleteControlPolicyMappingInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlPolicyMappingInput(ctx context.Context, v any) (types.DeleteControlPolicyMappingInput, error) { + res, err := ec.unmarshalInputDeleteControlPolicyMappingInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNDeleteControlPolicyMappingPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlPolicyMappingPayload(ctx context.Context, sel ast.SelectionSet, v types.DeleteControlPolicyMappingPayload) graphql.Marshaler { + return ec._DeleteControlPolicyMappingPayload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNDeleteControlPolicyMappingPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteControlPolicyMappingPayload(ctx context.Context, sel ast.SelectionSet, v *types.DeleteControlPolicyMappingPayload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._DeleteControlPolicyMappingPayload(ctx, sel, v) } func (ec *executionContext) unmarshalNDeleteEvidenceInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteEvidenceInput(ctx context.Context, v any) (types.DeleteEvidenceInput, error) { diff --git a/pkg/server/api/console/v1/types/types.go b/pkg/server/api/console/v1/types/types.go index 34097687b..0fb9e8acf 100644 --- a/pkg/server/api/console/v1/types/types.go +++ b/pkg/server/api/console/v1/types/types.go @@ -42,6 +42,7 @@ type Control struct { Name string `json:"name"` Description string `json:"description"` Mitigations *MitigationConnection `json:"mitigations"` + Policies *PolicyConnection `json:"policies"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } @@ -59,12 +60,21 @@ type ControlEdge struct { Node *Control `json:"node"` } -type CreateControlMappingInput struct { +type CreateControlMitigationMappingInput struct { ControlID gid.GID `json:"controlId"` MitigationID gid.GID `json:"mitigationId"` } -type CreateControlMappingPayload struct { +type CreateControlMitigationMappingPayload struct { + Success bool `json:"success"` +} + +type CreateControlPolicyMappingInput struct { + ControlID gid.GID `json:"controlId"` + PolicyID gid.GID `json:"policyId"` +} + +type CreateControlPolicyMappingPayload struct { Success bool `json:"success"` } @@ -188,12 +198,21 @@ type CreateVendorPayload struct { VendorEdge *VendorEdge `json:"vendorEdge"` } -type DeleteControlMappingInput struct { +type DeleteControlMitigationMappingInput struct { ControlID gid.GID `json:"controlId"` MitigationID gid.GID `json:"mitigationId"` } -type DeleteControlMappingPayload struct { +type DeleteControlMitigationMappingPayload struct { + Success bool `json:"success"` +} + +type DeleteControlPolicyMappingInput struct { + ControlID gid.GID `json:"controlId"` + PolicyID gid.GID `json:"policyId"` +} + +type DeleteControlPolicyMappingPayload struct { Success bool `json:"success"` } @@ -458,6 +477,7 @@ type Policy struct { Content string `json:"content"` ReviewDate *time.Time `json:"reviewDate,omitempty"` Owner *People `json:"owner"` + Controls *ControlConnection `json:"controls"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } diff --git a/pkg/server/api/console/v1/v1_resolver.go b/pkg/server/api/console/v1/v1_resolver.go index 035630acb..e6254dc5b 100644 --- a/pkg/server/api/console/v1/v1_resolver.go +++ b/pkg/server/api/console/v1/v1_resolver.go @@ -44,6 +44,31 @@ func (r *controlResolver) Mitigations(ctx context.Context, obj *types.Control, f return types.NewMitigationConnection(page), nil } +// Policies is the resolver for the policies field. +func (r *controlResolver) Policies(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.PolicyOrderBy) (*types.PolicyConnection, error) { + svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID()) + + pageOrderBy := page.OrderBy[coredata.PolicyOrderField]{ + Field: coredata.PolicyOrderFieldCreatedAt, + Direction: page.OrderDirectionDesc, + } + if orderBy != nil { + pageOrderBy = page.OrderBy[coredata.PolicyOrderField]{ + Field: orderBy.Field, + Direction: orderBy.Direction, + } + } + + cursor := types.NewCursor(first, after, last, before, pageOrderBy) + + page, err := svc.Policies.ListForControlID(ctx, obj.ID, cursor) + if err != nil { + return nil, fmt.Errorf("cannot list policies: %w", err) + } + + return types.NewPolicyConnection(page), nil +} + // FileURL is the resolver for the fileUrl field. func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (*string, error) { svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID()) @@ -521,30 +546,58 @@ func (r *mutationResolver) ImportMitigation(ctx context.Context, input types.Imp }, nil } -// CreateControlMapping is the resolver for the createControlMapping field. -func (r *mutationResolver) CreateControlMapping(ctx context.Context, input types.CreateControlMappingInput) (*types.CreateControlMappingPayload, error) { +// CreateControlMitigationMapping is the resolver for the createControlMitigationMapping field. +func (r *mutationResolver) CreateControlMitigationMapping(ctx context.Context, input types.CreateControlMitigationMappingInput) (*types.CreateControlMitigationMappingPayload, error) { svc := r.GetTenantServiceIfAuthorized(ctx, input.MitigationID.TenantID()) - err := svc.Controls.CreateMapping(ctx, input.ControlID, input.MitigationID) + err := svc.Controls.CreateMitigationMapping(ctx, input.ControlID, input.MitigationID) if err != nil { - return nil, fmt.Errorf("cannot create control mapping: %w", err) + panic(fmt.Errorf("cannot create control mitigation mapping: %w", err)) } - return &types.CreateControlMappingPayload{ + return &types.CreateControlMitigationMappingPayload{ Success: true, }, nil } -// DeleteControlMapping is the resolver for the deleteControlMapping field. -func (r *mutationResolver) DeleteControlMapping(ctx context.Context, input types.DeleteControlMappingInput) (*types.DeleteControlMappingPayload, error) { - svc := r.GetTenantServiceIfAuthorized(ctx, input.MitigationID.TenantID()) +// CreateControlPolicyMapping is the resolver for the createControlPolicyMapping field. +func (r *mutationResolver) CreateControlPolicyMapping(ctx context.Context, input types.CreateControlPolicyMappingInput) (*types.CreateControlPolicyMappingPayload, error) { + svc := r.GetTenantServiceIfAuthorized(ctx, input.PolicyID.TenantID()) - err := svc.Controls.DeleteMapping(ctx, input.ControlID, input.MitigationID) + err := svc.Controls.CreatePolicyMapping(ctx, input.ControlID, input.PolicyID) if err != nil { - return nil, fmt.Errorf("cannot delete control mapping: %w", err) + panic(fmt.Errorf("cannot create control policy mapping: %w", err)) } - return &types.DeleteControlMappingPayload{ + return &types.CreateControlPolicyMappingPayload{ + Success: true, + }, nil +} + +// DeleteControlMitigationMapping is the resolver for the deleteControlMitigationMapping field. +func (r *mutationResolver) DeleteControlMitigationMapping(ctx context.Context, input types.DeleteControlMitigationMappingInput) (*types.DeleteControlMitigationMappingPayload, error) { + svc := r.GetTenantServiceIfAuthorized(ctx, input.MitigationID.TenantID()) + + err := svc.Controls.DeleteMitigationMapping(ctx, input.ControlID, input.MitigationID) + if err != nil { + panic(fmt.Errorf("cannot delete control mitigation mapping: %w", err)) + } + + return &types.DeleteControlMitigationMappingPayload{ + Success: true, + }, nil +} + +// DeleteControlPolicyMapping is the resolver for the deleteControlPolicyMapping field. +func (r *mutationResolver) DeleteControlPolicyMapping(ctx context.Context, input types.DeleteControlPolicyMappingInput) (*types.DeleteControlPolicyMappingPayload, error) { + svc := r.GetTenantServiceIfAuthorized(ctx, input.PolicyID.TenantID()) + + err := svc.Controls.DeletePolicyMapping(ctx, input.ControlID, input.PolicyID) + if err != nil { + panic(fmt.Errorf("cannot delete control policy mapping: %w", err)) + } + + return &types.DeleteControlPolicyMappingPayload{ Success: true, }, nil } @@ -1067,6 +1120,31 @@ func (r *policyResolver) Owner(ctx context.Context, obj *types.Policy) (*types.P return types.NewPeople(owner), nil } +// Controls is the resolver for the controls field. +func (r *policyResolver) Controls(ctx context.Context, obj *types.Policy, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) { + svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID()) + + pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ + Field: coredata.ControlOrderFieldCreatedAt, + Direction: page.OrderDirectionDesc, + } + if orderBy != nil { + pageOrderBy = page.OrderBy[coredata.ControlOrderField]{ + Field: orderBy.Field, + Direction: orderBy.Direction, + } + } + + cursor := types.NewCursor(first, after, last, before, pageOrderBy) + + page, err := svc.Controls.ListForPolicyID(ctx, obj.ID, cursor) + if err != nil { + panic(fmt.Errorf("cannot list policy controls: %w", err)) + } + + return types.NewControlConnection(page), nil +} + // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) { svc := r.GetTenantServiceIfAuthorized(ctx, id.TenantID())