Files
probo/apps/console/src/routes.tsx
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

328 lines
10 KiB
TypeScript

// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.com>.
//
// 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.
import { Role } from "@probo/helpers";
import { lazy } from "@probo/react-lazy";
import { type AppRoute, routeFromAppRoute } from "@probo/routes";
import { CenteredLayout } from "@probo/ui";
import { use } from "react";
import {
createBrowserRouter,
Navigate,
redirect,
} from "react-router";
import { OrganizationErrorBoundary } from "./components/OrganizationErrorBoundary";
import { PageError } from "./components/PageError";
import { RootErrorBoundary } from "./components/RootErrorBoundary";
import { PageSkeleton } from "./components/skeletons/PageSkeleton";
import { ViewerLayoutLoading } from "./pages/iam/memberships/ViewerLayoutLoading";
import { peopleRoutes } from "./pages/iam/organizations/people/routes";
import { compliancePageRoutes } from "./pages/organizations/compliance-page/routes";
import { cookieBannerRoutes } from "./pages/organizations/cookie-banners/routes";
import { riskAssessmentRoutes } from "./pages/organizations/risk-assessments/routes";
import { riskRoutes } from "./pages/organizations/risks/routes";
import { CurrentUser } from "./providers/CurrentUser";
import { accessReviewRoutes } from "./routes/accessReviewRoutes";
import { assetRoutes } from "./routes/assetRoutes";
import { auditRoutes } from "./routes/auditRoutes";
import { contextRoutes } from "./routes/contextRoutes";
import { dataRoutes } from "./routes/dataRoutes";
import { documentsRoutes } from "./routes/documentsRoutes";
import { findingRoutes } from "./routes/findingRoutes";
import { frameworkRoutes } from "./routes/frameworkRoutes";
import { measureRoutes } from "./routes/measureRoutes";
import { obligationRoutes } from "./routes/obligationRoutes";
import { processingActivityRoutes } from "./routes/processingActivityRoutes";
import { rightsRequestRoutes } from "./routes/rightsRequestRoutes";
import { statementsOfApplicabilityRoutes } from "./routes/statementsOfApplicabilityRoutes";
import { taskRoutes } from "./routes/taskRoutes";
import { thirdPartyRoutes } from "./routes/thirdPartyRoutes";
const routes = [
{
path: "/auth",
Component: lazy(() => import("./pages/iam/auth/AuthLayout")),
children: [
{
path: "login",
Component: lazy(
() => import("./pages/iam/auth/sign-in/SignInPageLoader"),
),
},
{
path: "password-login",
Component: lazy(
() => import("./pages/iam/auth/sign-in/PasswordSignInPage"),
),
},
{
path: "sso-login",
Component: lazy(() => import("./pages/iam/auth/sign-in/SSOSignInPage")),
},
{
path: "register",
Component: lazy(() => import("./pages/iam/auth/SignUpPage")),
},
{
path: "verify-email",
Component: lazy(() => import("./pages/iam/auth/VerifyEmailPage")),
},
{
path: "activate-account",
Component: lazy(
() => import("./pages/iam/auth/ActivateAccountPage"),
),
},
{
path: "create-password",
Component: lazy(
() => import("./pages/iam/auth/CreatePasswordPage"),
),
},
{
path: "forgot-password",
Component: lazy(() => import("./pages/iam/auth/ForgotPasswordPage")),
},
{
path: "reset-password",
Component: lazy(() => import("./pages/iam/auth/ResetPasswordPage")),
},
{
path: "device",
ErrorBoundary: RootErrorBoundary,
Component: lazy(
() => import("./pages/iam/auth/DeviceActivationPageLoader"),
),
},
{
path: "consent",
ErrorBoundary: RootErrorBoundary,
Component: lazy(
() => import("./pages/iam/auth/ConsentPageLoader"),
),
},
],
},
{
path: "/",
ErrorBoundary: RootErrorBoundary,
children: [
{
Component: lazy(() => import("./pages/iam/memberships/ViewerLayoutLoader")),
Fallback: ViewerLayoutLoading,
children: [
{
index: true,
Component: lazy(
() => import("./pages/iam/memberships/MembershipsPageLoader"),
),
},
{
path: "me/api-keys",
Component: lazy(
() => import("./pages/iam/apiKeys/APIKeysPageLoader"),
),
},
{
Component: CenteredLayout,
children: [
{
path: "organizations/new",
Component: lazy(
() => import("./pages/iam/organizations/NewOrganizationPage"),
),
},
],
},
],
},
],
},
{
path: "/organizations/:organizationId",
children: [
{
path: "assume",
Component: lazy(() => import("./pages/iam/organizations/AssumePageLoader")),
},
{
path: "employee",
ErrorBoundary: OrganizationErrorBoundary,
Component: lazy(
() => import("./pages/organizations/employee/EmployeeLayoutLoader"),
),
children: [
{
index: true,
loader: ({ params: { organizationId } }) => {
// eslint-disable-next-line
throw redirect(`/organizations/${organizationId}/employee/signatures`);
},
Component: () => null,
},
{
Component: lazy(
() => import("./pages/organizations/employee/EmployeeTabsLayout"),
),
children: [
{
path: "signatures",
Component: lazy(
() =>
import("./pages/organizations/employee/EmployeeDocumentsPageLoader"),
),
},
{
path: "approvals",
Component: lazy(
() =>
import("./pages/organizations/employee/EmployeeApprovalsPageLoader"),
),
},
],
},
{
path: ":documentId",
loader: ({ params: { organizationId, documentId } }) => {
// eslint-disable-next-line
throw redirect(`/organizations/${organizationId}/employee/signatures/${documentId}`);
},
Component: () => null,
},
{
path: "signatures/:documentId",
Component: lazy(
() =>
import("./pages/organizations/employee/EmployeeDocumentSignaturePageLoader"),
),
},
{
path: "approvals/:documentId",
Component: lazy(
() =>
import("./pages/organizations/documents/approve/DocumentApprovePageLoader"),
),
},
],
},
{
Component: lazy(
() => import("./pages/iam/organizations/ViewerMembershipLayoutLoader"),
),
ErrorBoundary: OrganizationErrorBoundary,
children: [
{
path: "",
Component: () => {
const { role } = use(CurrentUser);
switch (role) {
case Role.EMPLOYEE:
return <Navigate to="employee" />;
case Role.AUDITOR:
return <Navigate to="measures" />;
default:
return <Navigate to="tasks" />;
}
},
},
{
path: "settings",
Fallback: PageSkeleton,
Component: lazy(
() => import("./pages/iam/organizations/settings/SettingsLayout"),
),
children: [
{
index: true,
loader: () => {
// eslint-disable-next-line
throw redirect("general");
},
},
{
path: "general",
Component: lazy(
() =>
import("./pages/iam/organizations/settings/GeneralSettingsPageLoader"),
),
},
{
path: "saml-sso",
Component: lazy(
() =>
import("./pages/iam/organizations/settings/SAMLSettingsPageLoader"),
),
},
{
path: "scim",
Component: lazy(
() =>
import("./pages/iam/organizations/settings/SCIMSettingsPageLoader"),
),
},
{
path: "webhooks",
Component: lazy(
() =>
import("./pages/iam/organizations/settings/WebhooksSettingsPageLoader"),
),
},
{
path: "audit-log",
Component: lazy(
() =>
import("./pages/iam/organizations/settings/AuditLogSettingsPageLoader"),
),
},
],
},
...peopleRoutes,
...riskRoutes,
...riskAssessmentRoutes,
...measureRoutes,
...documentsRoutes,
...thirdPartyRoutes,
...frameworkRoutes,
...taskRoutes,
...assetRoutes,
...dataRoutes,
...auditRoutes,
...contextRoutes,
...findingRoutes,
...obligationRoutes,
...rightsRequestRoutes,
...processingActivityRoutes,
...statementsOfApplicabilityRoutes,
...accessReviewRoutes,
...compliancePageRoutes,
...cookieBannerRoutes,
{
path: "*",
Component: PageError,
},
],
},
],
},
// Fallback URL to the NotFound Page
{
path: "*",
Component: PageError,
},
] satisfies AppRoute[];
export const router = createBrowserRouter(routes.map(routeFromAppRoute));