Files
probo/pkg/server/api/console/v1/graphql/risk.graphql
Sacha Al Himdani b9262b5150 Add risk assessment system
Introduce a hierarchical risk assessment model with six entity types:

- Risk Assessment: top-level container scoped to an organization
- Risk Assessment Scope: sub-container for scoping threat modeling
  exercises within an assessment
- Risk Assessment Node: DFD elements typed as ENTITY, BOUNDARY,
  ASSET, or DATA within a scope
- Risk Assessment Process: directed data flows between two nodes
- Risk Assessment Threat: descriptive threats attached to a process
  with a free-text category (e.g. Confidentiality, Integrity)
- Risk Scenario: thin join linking a threat to a risk from the
  register, carrying only a name and description

Risk scoring (likelihood, impact, treatment) remains on the existing
Risk entity. Threats are purely descriptive. Risk Scenarios connect
the threat model to the risk register without duplicating scores.

Backend: migration with PG enum for node types, coredata structs,
service layer with full CRUD and validation, GraphQL schema with
18 mutations and paginated connections, authorization actions and
policies, and base_resolvers.go Node dispatch for all entity types.

Frontend: Risk Assessments list page with create dialog, detail page
showing scopes as cards with nodes/processes/threats tables, inline
create/edit/delete actions on all entities, and a Scenarios tab on
the Risk detail page linking threats to risks. Existing RiskGraph.ts
hook file removed in favor of colocated queries in page files.

E2E tests cover CRUD for all entity types, RBAC, and tenant
isolation.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
2026-05-19 21:44:27 +02:00

279 lines
6.6 KiB
GraphQL

enum RiskTreatment
@goModel(model: "go.probo.inc/probo/pkg/coredata.RiskTreatment") {
MITIGATED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.RiskTreatmentMitigated")
ACCEPTED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.RiskTreatmentAccepted")
AVOIDED
@goEnum(value: "go.probo.inc/probo/pkg/coredata.RiskTreatmentAvoided")
TRANSFERRED
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.RiskTreatmentTransferred"
)
}
enum RiskOrderField
@goModel(model: "go.probo.inc/probo/pkg/coredata.RiskOrderField") {
CREATED_AT
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldCreatedAt"
)
UPDATED_AT
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldUpdatedAt"
)
NAME @goEnum(value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldName")
CATEGORY
@goEnum(value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldCategory")
TREATMENT
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldTreatment"
)
INHERENT_RISK_SCORE
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldInherentRiskScore"
)
RESIDUAL_RISK_SCORE
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldResidualRiskScore"
)
OWNER_FULL_NAME
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.RiskOrderFieldOwnerFullName"
)
}
input RiskOrder
@goModel(
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.RiskOrderBy"
) {
direction: OrderDirection!
field: RiskOrderField!
}
input RiskFilter {
query: String
}
type Risk implements Node {
id: ID!
name: String!
description: String
category: String!
treatment: RiskTreatment!
inherentLikelihood: Int!
inherentImpact: Int!
inherentRiskScore: Int!
residualLikelihood: Int!
residualImpact: Int!
residualRiskScore: Int!
note: String!
owner: Profile @goField(forceResolver: true)
organization: Organization! @goField(forceResolver: true)
measures(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: MeasureOrder
filter: MeasureFilter
): MeasureConnection! @goField(forceResolver: true)
documents(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: DocumentOrder
filter: DocumentFilter
): DocumentConnection! @goField(forceResolver: true)
controls(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: ControlOrder
filter: ControlFilter
): ControlConnection! @goField(forceResolver: true)
obligations(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: ObligationOrder
): ObligationConnection! @goField(forceResolver: true)
scenarios(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: RiskAssessmentScenarioOrder
): RiskAssessmentScenarioConnection! @goField(forceResolver: true)
createdAt: Datetime!
updatedAt: Datetime!
permission(action: String!): Boolean! @goField(forceResolver: true)
}
type RiskConnection
@goModel(
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.RiskConnection"
) {
totalCount: Int! @goField(forceResolver: true)
edges: [RiskEdge!]!
pageInfo: PageInfo!
}
type RiskEdge {
cursor: CursorKey!
node: Risk!
}
extend type Mutation {
createRisk(input: CreateRiskInput!): CreateRiskPayload!
updateRisk(input: UpdateRiskInput!): UpdateRiskPayload!
deleteRisk(input: DeleteRiskInput!): DeleteRiskPayload!
createRiskMeasureMapping(
input: CreateRiskMeasureMappingInput!
): CreateRiskMeasureMappingPayload!
deleteRiskMeasureMapping(
input: DeleteRiskMeasureMappingInput!
): DeleteRiskMeasureMappingPayload!
createRiskDocumentMapping(
input: CreateRiskDocumentMappingInput!
): CreateRiskDocumentMappingPayload!
deleteRiskDocumentMapping(
input: DeleteRiskDocumentMappingInput!
): DeleteRiskDocumentMappingPayload!
createRiskObligationMapping(
input: CreateRiskObligationMappingInput!
): CreateRiskObligationMappingPayload!
deleteRiskObligationMapping(
input: DeleteRiskObligationMappingInput!
): DeleteRiskObligationMappingPayload!
publishRiskList(
input: PublishRiskListInput!
): PublishRiskListPayload!
}
input PublishRiskListInput {
organizationId: ID!
approverIds: [ID!]
minor: Boolean!
}
type PublishRiskListPayload {
documentEdge: DocumentEdge!
documentVersionEdge: DocumentVersionEdge!
}
input CreateRiskInput {
organizationId: ID!
name: String!
description: String
category: String!
ownerId: ID
treatment: RiskTreatment!
inherentLikelihood: Int!
inherentImpact: Int!
residualLikelihood: Int
residualImpact: Int
note: String
}
input UpdateRiskInput {
id: ID!
name: String
description: String @goField(omittable: true)
category: String
ownerId: ID @goField(omittable: true)
treatment: RiskTreatment
inherentLikelihood: Int
inherentImpact: Int
residualLikelihood: Int
residualImpact: Int
note: String
}
input DeleteRiskInput {
riskId: ID!
}
input CreateRiskMeasureMappingInput {
riskId: ID!
measureId: ID!
}
input DeleteRiskMeasureMappingInput {
riskId: ID!
measureId: ID!
}
input CreateRiskDocumentMappingInput {
riskId: ID!
documentId: ID!
}
input DeleteRiskDocumentMappingInput {
riskId: ID!
documentId: ID!
}
input CreateRiskObligationMappingInput {
riskId: ID!
obligationId: ID!
}
input DeleteRiskObligationMappingInput {
riskId: ID!
obligationId: ID!
}
type CreateRiskPayload {
riskEdge: RiskEdge!
}
type UpdateRiskPayload {
risk: Risk!
}
type DeleteRiskPayload {
deletedRiskId: ID!
}
type CreateRiskMeasureMappingPayload {
riskEdge: RiskEdge!
measureEdge: MeasureEdge!
}
type DeleteRiskMeasureMappingPayload {
deletedMeasureId: ID!
deletedRiskId: ID!
}
type CreateRiskDocumentMappingPayload {
riskEdge: RiskEdge!
documentEdge: DocumentEdge!
}
type DeleteRiskDocumentMappingPayload {
deletedRiskId: ID!
deletedDocumentId: ID!
}
type CreateRiskObligationMappingPayload {
riskEdge: RiskEdge!
obligationEdge: ObligationEdge!
}
type DeleteRiskObligationMappingPayload {
deletedRiskId: ID!
deletedObligationId: ID!
}