Skip to content

[CSM Portal Microapp] Add Security Center (Security reports + Vulnerabilities) - #1211

Merged
rksk merged 17 commits into
wso2-open-operations:dev-app-csm-portalfrom
Hesara2003:feature/csm-microapp-security-center-page
Jul 23, 2026
Merged

rksk merged 17 commits into
wso2-open-operations:dev-app-csm-portalfrom
Hesara2003:feature/csm-microapp-security-center-page

Conversation

@Hesara2003

@Hesara2003 Hesara2003 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Ports the webapp's Security Center (CsmSecurityCenterPage) to the microapp: cross-customer security reports, product vulnerabilities, and creating a new security report — none of which existed in the microapp yet.

Goals

  • Security reports tab: cases of type security_report_analysis, search + State/Work state/Assignee/Project/Product filters, infinite-scrolled
  • Vulnerabilities tab: a separate, non-case-backed entity with its own detail page
  • New Security Report: Project → Deployment → Deployed Product cascade, auto-generated subject, required attachments, matching the webapp's CreateSecurityReportPage

Approach

  • pages/SecurityCenterPage.tsx — 2-tab shell, mirrors the webapp's tab split
  • components/security-center/{SecurityReportsTab,VulnerabilitiesTab,SecurityReportFiltersSheet}.tsx, pages/VulnerabilityDetailPage.tsx, services/{securityReports,vulnerabilities}.ts, types/vulnerability.{dto,model}.ts
  • pages/NewSecurityReportPage.tsx — reuses the same Project/Deployment/Product cascade pattern as NewCasePage.tsx, but attachments are embedded raw-base64 directly in the create payload (backend requires ≥1 for this case type) rather than uploaded separately afterward, and there's an aggregate 10 MiB body-size budget check matching the backend's actual cap
  • Fixed a real bug surfaced while testing this: POST /cases wraps its response in a { message, case } envelope (confirmed against the webapp's usePostCsmCase.ts) — the microapp's cases.create was reading .id off the wrapper instead of .case.id, so every case-create redirect (New Case and New Security Report both) landed on /cases/undefined. Fixed once at the services/cases.ts level.
  • Read-only for reports/vulnerabilities beyond creation — no report editing, matching the webapp's own scope

User stories

As a CSM engineer, I can browse security reports and product vulnerabilities, and file a new security report, from the microapp.

Release note

Added the Security Center feature (security reports, vulnerabilities, new-report creation) to the CSM Portal microapp.

Documentation

N/A — internal CSM portal UI, no external doc surface affected.

Automation tests

  • No test runner wired up yet for the microapp (matches the rest of this app's PRs)
  • npm run lint and npm run build passing locally
  • Manually verified in a local dev server: report/vulnerability lists load and filter, vulnerability detail navigates correctly, and the create-report flow (including the /cases/undefined redirect bug) was caught and fixed via live testing

Security checks

Test environment

  • npm run lint, npm run build all passing locally

Summary by CodeRabbit

  • New Features
    • Added Security Center with tabs for security reports and product vulnerabilities, including search, filters, and infinite scrolling.
    • Added security report creation page (project/deployment selection, description, attachments) with payload-size enforcement.
    • Added vulnerability list and vulnerability detail pages with priority and metadata.
  • Bug Fixes
    • Updated mobile metadata rows to use the shared presentation component across account, project, and deployment views for consistent display.
  • Documentation
    • Improved in-app component documentation for the shared metadata row component.

Now used by Security Center's vulnerability detail page too, not just
Customers — components/customers/MetaRow implied a scope it no longer has.
Security reports are cases of type "security_report_analysis" — ported
directly from the Engagements filter/service/sheet infrastructure (State,
Work state, Assignee, Project, Product), minus the engagement-type group,
which is engagement-only. Read-only for this pass, "New security report"
deliberately deferred.
VulnerabilityDto/Vulnerability (GET /products/vulnerabilities/{id} and the
search row share the same shape, like Account) plus the priority label/color
mapping — mirrors the webapp's csm-security-center/utils/vulnerabilities.ts.
Search (infinite scroll) + get by id. Applies a 50-row page limit
proactively rather than the spec's 100 — this backend has now shown the
same doc-vs-reality lie on four other search endpoints (comments,
products, deployments, deployed products).
Search + single-select priority filter, infinite-scrolled — mirrors the
webapp's ProductVulnerabilitiesTab/ProductVulnerabilityDetailPage.
Replaces the ComingSoonPage placeholder with Security reports |
Vulnerabilities tabs, plus the vulnerability detail route.
created.id was reading the wrapper's top level instead of .case.id, so
every case-create redirect (New Case, New Security Report) landed on
/cases/undefined and 400ed loading the detail page. Confirmed the real
response shape against the webapp's usePostCsmCase.ts, which already
unwraps res.case for the same reason — openapi.yaml's postCases 201
response doesn't reflect the envelope.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3bfae8d4-2721-444a-918d-c3c9533cb75c

📥 Commits

Reviewing files that changed from the base of the PR and between 714f2d0 and 938b1d5.

📒 Files selected for processing (2)
  • apps/csm-portal/microapp/src/components/security-center/VulnerabilitiesTab.tsx
  • apps/csm-portal/microapp/src/pages/NewSecurityReportPage.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/csm-portal/microapp/src/components/security-center/VulnerabilitiesTab.tsx
  • apps/csm-portal/microapp/src/pages/NewSecurityReportPage.tsx

📝 Walkthrough

Walkthrough

The Security Center now provides security report browsing and creation, product vulnerability browsing and detail views, paginated API services, filter controls, new routes, and shared attachment and metadata component updates.

Changes

Security Center data contracts and services

Layer / File(s) Summary
Contracts and API services
apps/csm-portal/microapp/src/types/*, services/securityReports.ts, services/vulnerabilities.ts, utils/securityReports.ts, utils/vulnerabilities.ts, config/endpoints.ts
Adds vulnerability DTOs/models, security report payloads and filters, API endpoints, React Query services, pagination handling, and display helpers.

Security report browsing

Layer / File(s) Summary
Security report browsing and filters
apps/csm-portal/microapp/src/components/security-center/SecurityReportsTab.tsx, SecurityReportFiltersSheet.tsx, pages/SecurityCenterPage.tsx
Replaces the placeholder Security Center with tabs, filtered security report results, async selectors, infinite scrolling, loading/error states, and report navigation.

Vulnerability experience

Layer / File(s) Summary
Vulnerability list and details
apps/csm-portal/microapp/src/components/security-center/VulnerabilitiesTab.tsx, pages/VulnerabilityDetailPage.tsx
Adds searchable, priority-filtered vulnerability cards with infinite scrolling and a query-driven detail page.

Security report creation

Layer / File(s) Summary
Security report creation and routing
apps/csm-portal/microapp/src/pages/NewSecurityReportPage.tsx, services/cases.ts, App.tsx
Adds the security report form, attachment size validation and base64 conversion, case creation response handling, and routes for report creation and vulnerability details.

Shared components

Layer / File(s) Summary
Shared component alignment
apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx, components/common/MetaRow.tsx, components/customers/DeploymentDetailDialog.tsx, pages/AccountDetailPage.tsx, pages/ProjectDetailPage.tsx
Makes attachment labels configurable and updates existing metadata consumers to use the common component.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant SecurityCenterPage
  participant SecurityReportsTab
  participant SecurityReportFiltersSheet
  participant securityReports
  participant CasesAPI

  Operator->>SecurityCenterPage: open Security Center
  SecurityCenterPage->>SecurityReportsTab: render reports tab
  SecurityReportsTab->>securityReports: request filtered reports
  securityReports->>CasesAPI: POST cases search
  CasesAPI-->>securityReports: paginated reports
  securityReports-->>SecurityReportsTab: report items
  Operator->>SecurityReportFiltersSheet: apply filters
  SecurityReportFiltersSheet-->>SecurityReportsTab: updated filters
Loading

Possibly related PRs

Suggested labels: Type/New Feature, Platform/Microapp, Area/Frontend, App/CSM Portal, Platform/Web

Suggested reviewers: rashmika998, cloby99, rksk

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding Security Center support for reports and vulnerabilities in the microapp.
Description check ✅ Passed The description follows the template well and covers the key required sections, with only some non-critical sections left empty.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/csm-portal/microapp/src/components/security-center/SecurityReportFiltersSheet.tsx (1)

58-144: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting a shared async multi-select helper.

ProjectMultiSelect, AssigneeMultiSelect, and ProductMultiSelect all repeat the same debounce → useQuery → dedupe-selected-into-options → Autocomplete wiring, differing only in the data source and value shape. A small generic wrapper (data source, label getter, equality fn) would reduce duplication and make future filter fields cheaper to add.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/csm-portal/microapp/src/components/security-center/SecurityReportFiltersSheet.tsx`
around lines 58 - 144, The three multi-select components duplicate Autocomplete
wiring and should be consolidated into a shared generic helper. Extract the
common debounce, query, selected-option merging, loading, equality, and
change-handling logic from ProjectMultiSelect, AssigneeMultiSelect, and
ProductMultiSelect, while allowing each caller to provide its data source and
value-shape-specific label, equality, and mapping behavior; preserve their
existing labels, search behavior, and selection results.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/csm-portal/microapp/src/components/security-center/VulnerabilitiesTab.tsx`:
- Around line 85-90: Update the debounced search setup in VulnerabilitiesTab to
pass filters.search.trim() into useDebouncedValue, matching SecurityReportsTab.
Keep the existing infiniteQuery call and filter behavior unchanged while
ensuring leading and trailing whitespace is removed before API requests.

In `@apps/csm-portal/microapp/src/pages/NewSecurityReportPage.tsx`:
- Around line 81-90: Update the size calculation in the NewSecurityReportPage
flow to construct the exact payload passed to mutateAsync, measure
TextEncoder().encode(JSON.stringify(payload)).length, and use that same payload
for submission. Replace the attachment-only overLimit logic around
attachmentBytes, nonAttachmentBytes, attachmentsBudget, and overLimit so JSON
syntax, IDs, names, and escaping are included.

---

Nitpick comments:
In
`@apps/csm-portal/microapp/src/components/security-center/SecurityReportFiltersSheet.tsx`:
- Around line 58-144: The three multi-select components duplicate Autocomplete
wiring and should be consolidated into a shared generic helper. Extract the
common debounce, query, selected-option merging, loading, equality, and
change-handling logic from ProjectMultiSelect, AssigneeMultiSelect, and
ProductMultiSelect, while allowing each caller to provide its data source and
value-shape-specific label, equality, and mapping behavior; preserve their
existing labels, search behavior, and selection results.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: be497e78-f7dd-4cae-8e3a-9cff93bc06d5

📥 Commits

Reviewing files that changed from the base of the PR and between 0bdf92f and 714f2d0.

📒 Files selected for processing (23)
  • apps/csm-portal/microapp/src/App.tsx
  • apps/csm-portal/microapp/src/components/common/MetaRow.tsx
  • apps/csm-portal/microapp/src/components/customers/DeploymentDetailDialog.tsx
  • apps/csm-portal/microapp/src/components/security-center/SecurityReportFiltersSheet.tsx
  • apps/csm-portal/microapp/src/components/security-center/SecurityReportsTab.tsx
  • apps/csm-portal/microapp/src/components/security-center/VulnerabilitiesTab.tsx
  • apps/csm-portal/microapp/src/components/support/AttachmentsField.tsx
  • apps/csm-portal/microapp/src/config/endpoints.ts
  • apps/csm-portal/microapp/src/pages/AccountDetailPage.tsx
  • apps/csm-portal/microapp/src/pages/NewSecurityReportPage.tsx
  • apps/csm-portal/microapp/src/pages/ProjectDetailPage.tsx
  • apps/csm-portal/microapp/src/pages/SecurityCenterPage.tsx
  • apps/csm-portal/microapp/src/pages/VulnerabilityDetailPage.tsx
  • apps/csm-portal/microapp/src/services/cases.ts
  • apps/csm-portal/microapp/src/services/securityReports.ts
  • apps/csm-portal/microapp/src/services/vulnerabilities.ts
  • apps/csm-portal/microapp/src/types/case.dto.ts
  • apps/csm-portal/microapp/src/types/index.ts
  • apps/csm-portal/microapp/src/types/vulnerability.dto.ts
  • apps/csm-portal/microapp/src/types/vulnerability.model.ts
  • apps/csm-portal/microapp/src/utils/attachments.ts
  • apps/csm-portal/microapp/src/utils/securityReports.ts
  • apps/csm-portal/microapp/src/utils/vulnerabilities.ts

Comment thread apps/csm-portal/microapp/src/pages/NewSecurityReportPage.tsx Outdated
…ating

The prior check summed subject/description bytes plus a flat 4KB buffer,
missing per-attachment JSON overhead (field names, braces, commas,
filenames) — a submission with several small attachments could slip
past overLimit and still 413 against the backend's real cap. Now
measures the actual JSON.stringify'd payload handleSubmit sends.
@s-sandali

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rksk
rksk merged commit 11bc744 into wso2-open-operations:dev-app-csm-portal Jul 23, 2026
1 check passed
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.

3 participants