Skip to content

CS-413 [BUG] SoA shows "unavailable" to auditor account#2925

Open
github-actions[bot] wants to merge 8 commits into
mainfrom
chas/soa-as-auditor
Open

CS-413 [BUG] SoA shows "unavailable" to auditor account#2925
github-actions[bot] wants to merge 8 commits into
mainfrom
chas/soa-as-auditor

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 25, 2026

This is an automated pull request to merge chas/soa-as-auditor into dev.
It was created by the [Auto Pull Request] action.


Summary by cubic

Allow auditors to view the Statement of Applicability without creating data by adding a read-only get-setup API (audit:read) and updating the app to use it when the user lacks audit:create (CS-413). Also pass the trusted org ID to the service, enforce ISO 27001-only support, and show a clear empty state when setup is missing.

Written for commit ee5ff4f. Summary will update on new commits. Review in cubic

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comp-framework-editor Ready Ready Preview, Comment May 26, 2026 5:09pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
app Skipped Skipped May 26, 2026 5:09pm
portal Skipped Skipped May 26, 2026 5:09pm

Request Review

@chasprowebdev chasprowebdev changed the title [dev] [chasprowebdev] chas/soa-as-auditor CS-413 [BUG] SoA shows "unavailable" to auditor account May 25, 2026
@linear
Copy link
Copy Markdown

linear Bot commented May 25, 2026

CS-413

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Confidence score: 2/5

  • There is a concrete security/authorization risk: ensure-setup in apps/api/src/soa/soa.controller.ts can create SOA records while only requiring audit:read, which permits mutation under a read-level scope.
  • Given the high severity (7/10) and high confidence (9/10), this is likely user-impacting and raises regression risk if merged without tightening permissions for the endpoint.
  • Pay close attention to apps/api/src/soa/soa.controller.ts - align endpoint authorization with write/create behavior to avoid privilege escalation.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/api/src/soa/soa.controller.ts Outdated
@chasprowebdev
Copy link
Copy Markdown
Contributor

@cubic-dev-ai please review it

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented May 25, 2026

@cubic-dev-ai please review it

@chasprowebdev I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 8 files

Confidence score: 2/5

  • There is a high-risk tenant isolation issue in apps/api/src/soa/soa.controller.ts: trusting organizationId from the request body instead of enforcing @OrganizationId() can allow cross-tenant access/update behavior.
  • apps/app/src/app/(app)/[orgId]/documents/statement-of-applicability/components/SOAFrameworkTabs.tsx also has a user-facing regression risk where getSOASetup can leave tabs stuck in a perpetual loading spinner when setup is missing or fetch fails.
  • Given the high severity (8/10) and high confidence (9/10) on the API scoping issue, this is not quite safe to merge without fixes.
  • Pay close attention to apps/api/src/soa/soa.controller.ts, apps/app/src/app/(app)/[orgId]/documents/statement-of-applicability/components/SOAFrameworkTabs.tsx - enforce tenant scoping in the controller and ensure loading/error fallback exits spinner state.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/api/src/soa/soa.controller.ts
@vercel vercel Bot temporarily deployed to Preview – app May 26, 2026 17:07 Inactive
@vercel vercel Bot temporarily deployed to Preview – portal May 26, 2026 17:07 Inactive
@tofikwest
Copy link
Copy Markdown
Contributor

@cubic-dev-ai review it

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented May 26, 2026

@cubic-dev-ai review it

@tofikwest I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 8 files

Confidence score: 3/5

  • There is a concrete user-facing regression risk in apps/app/src/app/(app)/[orgId]/documents/statement-of-applicability/page.tsx: when get-setup returns a valid null for read-only users, the page treats it as an error and can show auditors a failure state instead of a missing-setup state.
  • This is moderate merge risk (severity 6/10, high confidence), while the apps/api/src/soa/soa.service.ts concern is lower-impact technical debt focused on duplicated lookup logic and future drift risk.
  • Pay close attention to apps/app/src/app/(app)/[orgId]/documents/statement-of-applicability/page.tsx and apps/api/src/soa/soa.service.ts - fix null-setup handling for read-only flows and consider consolidating setup lookup logic to reduce divergence.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/api/src/soa/soa.service.ts">

<violation number="1" location="apps/api/src/soa/soa.service.ts:322">
P2: `getSetup` duplicates existing SOA setup lookup logic instead of reusing a shared helper, which increases drift and maintenance risk.</violation>
</file>

<file name="apps/app/src/app/(app)/[orgId]/documents/statement-of-applicability/page.tsx">

<violation number="1" location="apps/app/src/app/(app)/[orgId]/documents/statement-of-applicability/page.tsx:97">
P2: Using `get-setup` for read-only users can produce valid `null` setup data, but the existing flow still converts that into an error state. This will show a failure message for auditors when setup is simply missing.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

return { success: true, configuration, document };
}

async getSetup(dto: EnsureSOASetupDto) {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: getSetup duplicates existing SOA setup lookup logic instead of reusing a shared helper, which increases drift and maintenance risk.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/src/soa/soa.service.ts, line 322:

<comment>`getSetup` duplicates existing SOA setup lookup logic instead of reusing a shared helper, which increases drift and maintenance risk.</comment>

<file context>
@@ -319,6 +319,47 @@ export class SOAService {
     return { success: true, configuration, document };
   }
 
+  async getSetup(dto: EnsureSOASetupDto) {
+    const framework = await db.frameworkEditorFramework.findUnique({
+      where: { id: dto.frameworkId },
</file context>
Fix with Cubic

const userPermissions = await resolveCurrentUserPermissions(organizationId);
const canCreateSetup =
!!userPermissions && hasPermission(userPermissions, 'audit', 'create');
const setupEndpoint = canCreateSetup
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Using get-setup for read-only users can produce valid null setup data, but the existing flow still converts that into an error state. This will show a failure message for auditors when setup is simply missing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/app/src/app/(app)/[orgId]/documents/statement-of-applicability/page.tsx, line 97:

<comment>Using `get-setup` for read-only users can produce valid `null` setup data, but the existing flow still converts that into an error state. This will show a failure message for auditors when setup is simply missing.</comment>

<file context>
@@ -90,12 +91,19 @@ export default async function StatementOfApplicabilityPage({
+      const userPermissions = await resolveCurrentUserPermissions(organizationId);
+      const canCreateSetup =
+        !!userPermissions && hasPermission(userPermissions, 'audit', 'create');
+      const setupEndpoint = canCreateSetup
+        ? '/v1/soa/ensure-setup'
+        : '/v1/soa/get-setup';
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants