Add risk assessment boundary model

Introduce RiskAssessmentBoundary as a first-class, self-nesting entity that
groups nodes within a risk assessment scope, and thread it through every
surface.

- coredata: new risk_assessment_boundaries table + migration, boundary_id on
  nodes, self-referential parent_boundary_id, entity type registration
- riskmanagement: boundary CRUD service methods, boundary_id wiring on node
  create/update, scope-membership and self-parent validation, nested-subgraph
  Mermaid rendering
- IAM: core:risk-assessment-boundary:{get,list,create,update,delete} actions
  and viewer/auditor read policies
- console GraphQL: RiskAssessmentBoundary type, connection, order enum, CRUD
  mutations, boundaries field on scope, boundaryId on nodes
- CLI: risk-assessment boundary command group and --boundary-id on nodes
- MCP: boundary tools and boundary_id on node tools
- n8n: boundary operations and boundary fields on node operations
- console UI: boundary list/create/edit, boundary selector on nodes, diagram
  refetch on boundary changes

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-06-08 15:37:56 +02:00
parent b643c8eb6d
commit dbf915047d
44 changed files with 3620 additions and 79 deletions

View File

@@ -6497,6 +6497,7 @@ func (r *Resolver) AddRiskAssessmentNodeTool(ctx context.Context, req *mcp.CallT
n, err := r.riskManagement.CreateNode(ctx, scope, riskmanagement.CreateRiskAssessmentNodeRequest{
RiskAssessmentScopeID: input.RiskAssessmentScopeID,
BoundaryID: input.BoundaryID,
NodeType: input.NodeType,
Name: input.Name,
})
@@ -6515,10 +6516,16 @@ func (r *Resolver) UpdateRiskAssessmentNodeTool(ctx context.Context, req *mcp.Ca
return nil, types.UpdateRiskAssessmentNodeOutput{}, err
}
var boundaryID **gid.GID
if input.BoundaryID != nil {
boundaryID = &input.BoundaryID
}
n, err := r.riskManagement.UpdateNode(ctx, scope, riskmanagement.UpdateRiskAssessmentNodeRequest{
ID: input.ID,
NodeType: input.NodeType,
Name: input.Name,
ID: input.ID,
BoundaryID: boundaryID,
NodeType: input.NodeType,
Name: input.Name,
})
if err != nil {
return nil, types.UpdateRiskAssessmentNodeOutput{}, fmt.Errorf("failed to update risk assessment node: %w", err)
@@ -6930,3 +6937,106 @@ func (r *Resolver) GetRiskAssessmentScopeMermaidChartTool(ctx context.Context, r
MermaidChart: chart,
}, nil
}
func (r *Resolver) ListRiskAssessmentBoundariesTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListRiskAssessmentBoundariesInput) (*mcp.CallToolResult, types.ListRiskAssessmentBoundariesOutput, error) {
scope, err := r.Authorize(ctx, input.RiskAssessmentScopeID, probo.ActionRiskAssessmentBoundaryList)
if err != nil {
return nil, types.ListRiskAssessmentBoundariesOutput{}, err
}
pageOrderBy := page.OrderBy[coredata.RiskAssessmentBoundaryOrderField]{
Field: coredata.RiskAssessmentBoundaryOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if input.OrderBy != nil {
pageOrderBy = page.OrderBy[coredata.RiskAssessmentBoundaryOrderField]{
Field: input.OrderBy.Field,
Direction: input.OrderBy.Direction,
}
}
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
p, err := r.riskManagement.ListBoundariesForScopeID(ctx, scope, input.RiskAssessmentScopeID, cursor)
if err != nil {
panic(fmt.Errorf("cannot list risk assessment boundaries: %w", err))
}
return nil, types.NewListRiskAssessmentBoundariesOutput(p), nil
}
func (r *Resolver) GetRiskAssessmentBoundaryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetRiskAssessmentBoundaryInput) (*mcp.CallToolResult, types.GetRiskAssessmentBoundaryOutput, error) {
scope, err := r.Authorize(ctx, input.ID, probo.ActionRiskAssessmentBoundaryGet)
if err != nil {
return nil, types.GetRiskAssessmentBoundaryOutput{}, err
}
b, err := r.riskManagement.GetBoundary(ctx, scope, input.ID)
if err != nil {
return nil, types.GetRiskAssessmentBoundaryOutput{}, fmt.Errorf("failed to get risk assessment boundary: %w", err)
}
return nil, types.GetRiskAssessmentBoundaryOutput{
RiskAssessmentBoundary: types.NewRiskAssessmentBoundary(b),
}, nil
}
func (r *Resolver) AddRiskAssessmentBoundaryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddRiskAssessmentBoundaryInput) (*mcp.CallToolResult, types.AddRiskAssessmentBoundaryOutput, error) {
scope, err := r.Authorize(ctx, input.RiskAssessmentScopeID, probo.ActionRiskAssessmentBoundaryCreate)
if err != nil {
return nil, types.AddRiskAssessmentBoundaryOutput{}, err
}
b, err := r.riskManagement.CreateBoundary(ctx, scope, riskmanagement.CreateRiskAssessmentBoundaryRequest{
RiskAssessmentScopeID: input.RiskAssessmentScopeID,
ParentBoundaryID: input.ParentBoundaryID,
Name: input.Name,
})
if err != nil {
return nil, types.AddRiskAssessmentBoundaryOutput{}, fmt.Errorf("failed to create risk assessment boundary: %w", err)
}
return nil, types.AddRiskAssessmentBoundaryOutput{
RiskAssessmentBoundary: types.NewRiskAssessmentBoundary(b),
}, nil
}
func (r *Resolver) UpdateRiskAssessmentBoundaryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateRiskAssessmentBoundaryInput) (*mcp.CallToolResult, types.UpdateRiskAssessmentBoundaryOutput, error) {
scope, err := r.Authorize(ctx, input.ID, probo.ActionRiskAssessmentBoundaryUpdate)
if err != nil {
return nil, types.UpdateRiskAssessmentBoundaryOutput{}, err
}
var parentBoundaryID **gid.GID
if input.ParentBoundaryID != nil {
parentBoundaryID = &input.ParentBoundaryID
}
b, err := r.riskManagement.UpdateBoundary(ctx, scope, riskmanagement.UpdateRiskAssessmentBoundaryRequest{
ID: input.ID,
ParentBoundaryID: parentBoundaryID,
Name: input.Name,
})
if err != nil {
return nil, types.UpdateRiskAssessmentBoundaryOutput{}, fmt.Errorf("failed to update risk assessment boundary: %w", err)
}
return nil, types.UpdateRiskAssessmentBoundaryOutput{
RiskAssessmentBoundary: types.NewRiskAssessmentBoundary(b),
}, nil
}
func (r *Resolver) DeleteRiskAssessmentBoundaryTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteRiskAssessmentBoundaryInput) (*mcp.CallToolResult, types.DeleteRiskAssessmentBoundaryOutput, error) {
scope, err := r.Authorize(ctx, input.ID, probo.ActionRiskAssessmentBoundaryDelete)
if err != nil {
return nil, types.DeleteRiskAssessmentBoundaryOutput{}, err
}
if err := r.riskManagement.DeleteBoundary(ctx, scope, input.ID); err != nil {
return nil, types.DeleteRiskAssessmentBoundaryOutput{}, fmt.Errorf("failed to delete risk assessment boundary: %w", err)
}
return nil, types.DeleteRiskAssessmentBoundaryOutput{
DeletedRiskAssessmentBoundaryID: input.ID,
}, nil
}

View File

@@ -10792,7 +10792,6 @@ components:
type: string
enum:
- ENTITY
- BOUNDARY
- ASSET
- DATA
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.RiskAssessmentNodeType
@@ -10851,6 +10850,24 @@ components:
direction:
$ref: "#/components/schemas/OrderDirection"
RiskAssessmentBoundaryOrderField:
type: string
enum:
- CREATED_AT
- NAME
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.RiskAssessmentBoundaryOrderField
RiskAssessmentBoundaryOrderBy:
type: object
required:
- field
- direction
properties:
field:
$ref: "#/components/schemas/RiskAssessmentBoundaryOrderField"
direction:
$ref: "#/components/schemas/OrderDirection"
RiskAssessmentProcessOrderField:
type: string
enum:
@@ -10973,6 +10990,9 @@ components:
$ref: "#/components/schemas/GID"
risk_assessment_scope_id:
$ref: "#/components/schemas/GID"
boundary_id:
$ref: "#/components/schemas/GID"
description: ID of the boundary that contains this node, if any
node_type:
$ref: "#/components/schemas/RiskAssessmentNodeType"
name:
@@ -10984,6 +11004,34 @@ components:
type: string
format: date-time
RiskAssessmentBoundary:
type: object
required:
- id
- organization_id
- risk_assessment_scope_id
- name
- created_at
- updated_at
properties:
id:
$ref: "#/components/schemas/GID"
organization_id:
$ref: "#/components/schemas/GID"
risk_assessment_scope_id:
$ref: "#/components/schemas/GID"
parent_boundary_id:
$ref: "#/components/schemas/GID"
description: ID of the parent boundary, if this boundary is nested
name:
type: string
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
RiskAssessmentProcess:
type: object
required:
@@ -11372,6 +11420,9 @@ components:
risk_assessment_scope_id:
$ref: "#/components/schemas/GID"
description: Risk assessment scope ID
boundary_id:
$ref: "#/components/schemas/GID"
description: ID of the boundary that contains this node (optional)
node_type:
$ref: "#/components/schemas/RiskAssessmentNodeType"
description: Node type
@@ -11395,6 +11446,9 @@ components:
id:
$ref: "#/components/schemas/GID"
description: Risk assessment node ID
boundary_id:
$ref: "#/components/schemas/GID"
description: ID of the boundary that contains this node (optional)
node_type:
$ref: "#/components/schemas/RiskAssessmentNodeType"
description: Node type
@@ -11428,6 +11482,119 @@ components:
$ref: "#/components/schemas/GID"
description: Deleted risk assessment node ID
ListRiskAssessmentBoundariesInput:
type: object
required:
- risk_assessment_scope_id
properties:
risk_assessment_scope_id:
$ref: "#/components/schemas/GID"
description: Risk assessment scope ID
order_by:
$ref: "#/components/schemas/RiskAssessmentBoundaryOrderBy"
description: Order by
size:
type: integer
description: Page size
cursor:
$ref: "#/components/schemas/CursorKey"
description: Page cursor
ListRiskAssessmentBoundariesOutput:
type: object
required:
- risk_assessment_boundaries
properties:
next_cursor:
$ref: "#/components/schemas/CursorKey"
description: Next cursor
risk_assessment_boundaries:
type: array
items:
$ref: "#/components/schemas/RiskAssessmentBoundary"
GetRiskAssessmentBoundaryInput:
type: object
required:
- id
properties:
id:
$ref: "#/components/schemas/GID"
description: Risk assessment boundary ID
GetRiskAssessmentBoundaryOutput:
type: object
required:
- risk_assessment_boundary
properties:
risk_assessment_boundary:
$ref: "#/components/schemas/RiskAssessmentBoundary"
AddRiskAssessmentBoundaryInput:
type: object
required:
- risk_assessment_scope_id
- name
properties:
risk_assessment_scope_id:
$ref: "#/components/schemas/GID"
description: Risk assessment scope ID
parent_boundary_id:
$ref: "#/components/schemas/GID"
description: ID of the parent boundary (optional, for nested boundaries)
name:
type: string
description: Risk assessment boundary name
AddRiskAssessmentBoundaryOutput:
type: object
required:
- risk_assessment_boundary
properties:
risk_assessment_boundary:
$ref: "#/components/schemas/RiskAssessmentBoundary"
UpdateRiskAssessmentBoundaryInput:
type: object
required:
- id
properties:
id:
$ref: "#/components/schemas/GID"
description: Risk assessment boundary ID
parent_boundary_id:
$ref: "#/components/schemas/GID"
description: ID of the parent boundary (optional, for nested boundaries)
name:
type: string
description: Risk assessment boundary name
UpdateRiskAssessmentBoundaryOutput:
type: object
required:
- risk_assessment_boundary
properties:
risk_assessment_boundary:
$ref: "#/components/schemas/RiskAssessmentBoundary"
DeleteRiskAssessmentBoundaryInput:
type: object
required:
- id
properties:
id:
$ref: "#/components/schemas/GID"
description: Risk assessment boundary ID
DeleteRiskAssessmentBoundaryOutput:
type: object
required:
- deleted_risk_assessment_boundary_id
properties:
deleted_risk_assessment_boundary_id:
$ref: "#/components/schemas/GID"
description: Deleted risk assessment boundary ID
ListRiskAssessmentProcessesInput:
type: object
required:
@@ -14005,6 +14172,49 @@ tools:
$ref: "#/components/schemas/DeleteRiskAssessmentNodeInput"
outputSchema:
$ref: "#/components/schemas/DeleteRiskAssessmentNodeOutput"
- name: listRiskAssessmentBoundaries
description: List all boundaries for a risk assessment scope
hints:
readonly: true
idempotent: true
inputSchema:
$ref: "#/components/schemas/ListRiskAssessmentBoundariesInput"
outputSchema:
$ref: "#/components/schemas/ListRiskAssessmentBoundariesOutput"
- name: getRiskAssessmentBoundary
description: Get a risk assessment boundary by ID
hints:
readonly: true
idempotent: true
inputSchema:
$ref: "#/components/schemas/GetRiskAssessmentBoundaryInput"
outputSchema:
$ref: "#/components/schemas/GetRiskAssessmentBoundaryOutput"
- name: addRiskAssessmentBoundary
description: Create a new risk assessment boundary
hints:
readonly: false
inputSchema:
$ref: "#/components/schemas/AddRiskAssessmentBoundaryInput"
outputSchema:
$ref: "#/components/schemas/AddRiskAssessmentBoundaryOutput"
- name: updateRiskAssessmentBoundary
description: Update an existing risk assessment boundary
hints:
readonly: false
inputSchema:
$ref: "#/components/schemas/UpdateRiskAssessmentBoundaryInput"
outputSchema:
$ref: "#/components/schemas/UpdateRiskAssessmentBoundaryOutput"
- name: deleteRiskAssessmentBoundary
description: Delete a risk assessment boundary
hints:
readonly: false
destructive: true
inputSchema:
$ref: "#/components/schemas/DeleteRiskAssessmentBoundaryInput"
outputSchema:
$ref: "#/components/schemas/DeleteRiskAssessmentBoundaryOutput"
- name: listRiskAssessmentProcesses
description: List all processes for a risk assessment scope
hints:

View File

@@ -88,6 +88,7 @@ func NewRiskAssessmentNode(n *coredata.RiskAssessmentNode) *RiskAssessmentNode {
ID: n.ID,
OrganizationID: n.OrganizationID,
RiskAssessmentScopeID: n.RiskAssessmentScopeID,
BoundaryID: n.BoundaryID,
NodeType: n.NodeType,
Name: n.Name,
CreatedAt: n.CreatedAt,
@@ -95,6 +96,39 @@ func NewRiskAssessmentNode(n *coredata.RiskAssessmentNode) *RiskAssessmentNode {
}
}
func NewRiskAssessmentBoundary(b *coredata.RiskAssessmentBoundary) *RiskAssessmentBoundary {
return &RiskAssessmentBoundary{
ID: b.ID,
OrganizationID: b.OrganizationID,
RiskAssessmentScopeID: b.RiskAssessmentScopeID,
ParentBoundaryID: b.ParentBoundaryID,
Name: b.Name,
CreatedAt: b.CreatedAt,
UpdatedAt: b.UpdatedAt,
}
}
func NewListRiskAssessmentBoundariesOutput(
p *page.Page[*coredata.RiskAssessmentBoundary, coredata.RiskAssessmentBoundaryOrderField],
) ListRiskAssessmentBoundariesOutput {
items := make([]*RiskAssessmentBoundary, 0, len(p.Data))
for _, v := range p.Data {
items = append(items, NewRiskAssessmentBoundary(v))
}
var nextCursor *page.CursorKey
if len(p.Data) > 0 {
cursorKey := p.Data[len(p.Data)-1].CursorKey(p.Cursor.OrderBy.Field)
nextCursor = &cursorKey
}
return ListRiskAssessmentBoundariesOutput{
NextCursor: nextCursor,
RiskAssessmentBoundaries: items,
}
}
func NewListRiskAssessmentNodesOutput(
p *page.Page[*coredata.RiskAssessmentNode, coredata.RiskAssessmentNodeOrderField],
) ListRiskAssessmentNodesOutput {