-
Notifications
You must be signed in to change notification settings - Fork 296
[comp] Production Deploy #2650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
[comp] Production Deploy #2650
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
11d6c3b
chore: merge release v3.30.0 back to main [skip ci]
github-actions[bot] 7518075
feat: enabled framework versioning and updating existing frameworks w…
github-actions[bot] 4d340ad
fix(db): exclude *.spec.ts from tsc build (#2651)
Marfuen 3ae8f5e
chore: fix rollback bug
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
apps/api/src/framework-editor-versions/dto/publish-version.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { IsOptional, IsString, Matches, MaxLength } from 'class-validator'; | ||
|
|
||
| export class PublishVersionDto { | ||
| // Semver major.minor.patch. Accepts things like "1.0.0", "2.3.11". | ||
| @IsString() | ||
| @Matches(/^\d+\.\d+\.\d+$/, { message: 'version must be MAJOR.MINOR.PATCH' }) | ||
| version!: string; | ||
|
|
||
| @IsOptional() | ||
| @IsString() | ||
| @MaxLength(10_000) | ||
| releaseNotes?: string; | ||
| } |
106 changes: 106 additions & 0 deletions
106
apps/api/src/framework-editor-versions/framework-manifest-builder.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import { buildManifestForFramework } from './framework-manifest-builder'; | ||
|
|
||
| jest.mock('@db', () => ({ | ||
| db: { | ||
| frameworkEditorFramework: { findUnique: jest.fn() }, | ||
| }, | ||
| })); | ||
| import { db } from '@db'; | ||
|
|
||
| describe('buildManifestForFramework', () => { | ||
| beforeEach(() => jest.clearAllMocks()); | ||
|
|
||
| it('produces a manifest with framework, requirements, controls, policies, tasks', async () => { | ||
| // Shape of the mocked result reflects the REAL schema: requirements -> controlTemplates -> policyTemplates/taskTemplates. | ||
| (db.frameworkEditorFramework.findUnique as jest.Mock).mockResolvedValue({ | ||
| id: 'frk_soc2', | ||
| name: 'SOC 2', | ||
| version: 'TSC 2017 (rev 2022)', | ||
| description: null, | ||
| requirements: [ | ||
| { | ||
| id: 'frk_rq_cc61', | ||
| identifier: 'CC6.1', | ||
| name: 'Logical Access', | ||
| description: 'x', | ||
| controlTemplates: [ | ||
| { | ||
| id: 'frk_ct_logical_access', | ||
| name: 'Logical Access Controls', | ||
| description: 'desc', | ||
| requirements: [{ id: 'frk_rq_cc61' }], | ||
| policyTemplates: [ | ||
| { id: 'frk_pt_acc', name: 'Access Policy', description: null, content: [{}], frequency: 'yearly', department: 'it' }, | ||
| ], | ||
| taskTemplates: [ | ||
| { id: 'frk_tt_rev', name: 'Review Access', description: 'Review quarterly', frequency: 'quarterly', department: 'it' }, | ||
| ], | ||
| documentTypes: ['rbac_matrix'], | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| const manifest = await buildManifestForFramework('frk_soc2'); | ||
|
|
||
| expect(manifest.framework.id).toBe('frk_soc2'); | ||
| expect(manifest.framework.catalogVersion).toBe('TSC 2017 (rev 2022)'); | ||
| expect(manifest.requirements).toHaveLength(1); | ||
| expect(manifest.requirements[0].identifier).toBe('CC6.1'); | ||
| expect(manifest.controls).toHaveLength(1); | ||
| expect(manifest.controls[0].id).toBe('frk_ct_logical_access'); | ||
| expect(manifest.controls[0].requirementIds).toEqual(['frk_rq_cc61']); | ||
| expect(manifest.controls[0].policyIds).toEqual(['frk_pt_acc']); | ||
| expect(manifest.controls[0].taskIds).toEqual(['frk_tt_rev']); | ||
| expect(manifest.policies).toHaveLength(1); | ||
| expect(manifest.tasks).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('dedupes controls/policies/tasks that appear under multiple requirements', async () => { | ||
| (db.frameworkEditorFramework.findUnique as jest.Mock).mockResolvedValue({ | ||
| id: 'frk_iso', | ||
| name: 'ISO 27001', | ||
| version: '2022', | ||
| description: null, | ||
| requirements: [ | ||
| { | ||
| id: 'rq_a', identifier: 'A', name: 'A', description: null, | ||
| controlTemplates: [ | ||
| { | ||
| id: 'ct_shared', name: 'Shared', description: 'd', | ||
| requirements: [{ id: 'rq_a' }, { id: 'rq_b' }], | ||
| policyTemplates: [{ id: 'pt_shared', name: 'P', description: null, content: [], frequency: null, department: null }], | ||
| taskTemplates: [{ id: 'tt_shared', name: 'T', description: '', frequency: null, department: null }], | ||
| documentTypes: [], | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| id: 'rq_b', identifier: 'B', name: 'B', description: null, | ||
| controlTemplates: [ | ||
| { | ||
| id: 'ct_shared', name: 'Shared', description: 'd', | ||
| requirements: [{ id: 'rq_a' }, { id: 'rq_b' }], | ||
| policyTemplates: [{ id: 'pt_shared', name: 'P', description: null, content: [], frequency: null, department: null }], | ||
| taskTemplates: [{ id: 'tt_shared', name: 'T', description: '', frequency: null, department: null }], | ||
| documentTypes: [], | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| const manifest = await buildManifestForFramework('frk_iso'); | ||
|
|
||
| expect(manifest.controls).toHaveLength(1); | ||
| expect(manifest.controls[0].requirementIds.sort()).toEqual(['rq_a', 'rq_b']); | ||
| expect(manifest.policies).toHaveLength(1); | ||
| expect(manifest.tasks).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('throws when framework not found', async () => { | ||
| (db.frameworkEditorFramework.findUnique as jest.Mock).mockResolvedValue(null); | ||
| await expect(buildManifestForFramework('missing')).rejects.toThrow('Framework not found'); | ||
| }); | ||
| }); |
98 changes: 98 additions & 0 deletions
98
apps/api/src/framework-editor-versions/framework-manifest-builder.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { NotFoundException } from '@nestjs/common'; | ||
| import { db } from '@db'; | ||
| import type { | ||
| FrameworkManifest, | ||
| ManifestControl, | ||
| ManifestPolicy, | ||
| ManifestTask, | ||
| } from '../frameworks/framework-versioning/manifest.types'; | ||
|
|
||
| export async function buildManifestForFramework(frameworkId: string): Promise<FrameworkManifest> { | ||
| const framework = await db.frameworkEditorFramework.findUnique({ | ||
| where: { id: frameworkId }, | ||
| include: { | ||
| requirements: { | ||
| include: { | ||
| controlTemplates: { | ||
| include: { | ||
| requirements: { select: { id: true } }, | ||
| policyTemplates: true, | ||
| taskTemplates: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| if (!framework) throw new NotFoundException('Framework not found'); | ||
|
|
||
| // Collect all unique control templates across all requirements, deduped by id. | ||
| const controlsMap = new Map<string, ManifestControl>(); | ||
| const policiesMap = new Map<string, ManifestPolicy>(); | ||
| const tasksMap = new Map<string, ManifestTask>(); | ||
|
|
||
| // A control template's `requirements` relation spans every framework that | ||
| // has mapped it — filter down to requirements belonging to THIS framework | ||
| // so the manifest doesn't reference IDs that aren't in its own `requirements`. | ||
| const ownRequirementIds = new Set(framework.requirements.map((r) => r.id)); | ||
|
|
||
| for (const req of framework.requirements) { | ||
| for (const ct of req.controlTemplates) { | ||
| if (!controlsMap.has(ct.id)) { | ||
| controlsMap.set(ct.id, { | ||
| id: ct.id, | ||
| name: ct.name, | ||
| description: ct.description, | ||
| requirementIds: ct.requirements | ||
| .map((r) => r.id) | ||
| .filter((id) => ownRequirementIds.has(id)), | ||
| policyIds: ct.policyTemplates.map((p) => p.id), | ||
| taskIds: ct.taskTemplates.map((t) => t.id), | ||
| documentTypes: [...ct.documentTypes], | ||
| }); | ||
| } | ||
| for (const pt of ct.policyTemplates) { | ||
| if (!policiesMap.has(pt.id)) { | ||
| policiesMap.set(pt.id, { | ||
| id: pt.id, | ||
| name: pt.name, | ||
| description: pt.description, | ||
| content: pt.content, | ||
| frequency: pt.frequency, | ||
| department: pt.department, | ||
| }); | ||
| } | ||
| } | ||
| for (const tt of ct.taskTemplates) { | ||
| if (!tasksMap.has(tt.id)) { | ||
| tasksMap.set(tt.id, { | ||
| id: tt.id, | ||
| name: tt.name, | ||
| description: tt.description, | ||
| frequency: tt.frequency, | ||
| department: tt.department, | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| framework: { | ||
| id: framework.id, | ||
| name: framework.name, | ||
| catalogVersion: framework.version, | ||
| description: framework.description, | ||
| }, | ||
| requirements: framework.requirements.map((r) => ({ | ||
| id: r.id, | ||
| identifier: r.identifier, | ||
| name: r.name, | ||
| description: r.description, | ||
| })), | ||
| controls: [...controlsMap.values()], | ||
| policies: [...policiesMap.values()], | ||
| tasks: [...tasksMap.values()], | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Policy queries still omit
isArchived: falsein modified paths, so user-archived policies can be linked or returned despite the new archival rule.Prompt for AI agents