Skip to content
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

fix(j-s): Defender Case File Access #15070

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

gudjong
Copy link
Member

@gudjong gudjong commented Jun 4, 2024

Defender Case File Access

[Verjendur sjá ekki staðfestar ákærur}(https://app.asana.com/0/1199153462262248/1207453585767576/f)

What

  • Displays a confirmed indictment to defenders for uploaded indictments.
  • Gives defenders access to case files in uncompleted indictment cases.

Why

  • Verified bug.

Screenshots / Gifs

Screen.Recording.2024-06-04.at.10.01.01.mov

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced data retrieval logic by refining the inclusion of indictmentReviewer for better query accuracy.
    • Introduced EventLog tracking with specific conditions to improve event monitoring in limited access cases.
  • Bug Fixes

    • Refined access control logic for case files based on user roles and case types, ensuring more accurate permissions.
  • Refactor

    • Adjusted guard configurations to streamline authorization checks for creating and updating case files.
    • Optimized test logic by updating guard checks and configurations for better coverage and accuracy.

@gudjong gudjong requested a review from a team as a code owner June 4, 2024 10:02
Copy link
Contributor

coderabbitai bot commented Jun 4, 2024

Walkthrough

The changes primarily focus on refining access control and data retrieval logic within the judicial system's backend services. Key modifications include adjustments to user role and case type conditions, updates to guard configurations, and enhancements to data inclusion for case and event logging. These improvements aim to streamline authorization processes and ensure accurate data handling.

Changes

File Path Change Summary
apps/.../case/case.service.ts Added indictmentReviewer entry while removing a duplicate in the include array.
apps/.../case/limitedAccessCase.service.ts Added imports for EventType and EventLog, initialized eventTypes, and added a new include block for EventLog.
apps/.../file/guards/limitedAccessViewCaseFile.guard.ts Revised access logic based on user roles and case types.
apps/.../file/guards/test/limitedAccessViewCaseFileGuard.spec.ts Replaced loop over completedCaseStates with iteration over all values of CaseState.
apps/.../file/limitedAccessFile.controller.ts Moved CaseCompletedGuard from class level to specific methods (createCaseFile, updateCaseFile).
apps/.../file/test/limitedAccessFileController/createCaseFileGuards.spec.ts Added CaseCompletedGuard to imports and modified guard configuration checks.
apps/.../file/test/limitedAccessFileController/createPresignedPostGuards.spec.ts Added CaseCompletedGuard to imports and adjusted guard configuration checks.
apps/.../file/test/limitedAccessFileController/deleteCaseFileGuards.spec.ts Added CaseCompletedGuard to imports, replaced CaseWriteGuard instantiation with CaseCompletedGuard, and adjusted guard checks.
apps/.../file/test/limitedAccessFileController/limitedAccessFileControllerGuards.spec.ts Removed CaseCompletedGuard from the list of guards, reducing the number of checked guards from 4 to 3.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant LimitedAccessViewCaseFileGuard
    participant CaseService
    participant FileController

    User->>LimitedAccessViewCaseFileGuard: Request access to case file
    LimitedAccessViewCaseFileGuard->>CaseService: Check user role and case type
    CaseService-->>LimitedAccessViewCaseFileGuard: Return access status
    LimitedAccessViewCaseFileGuard-->>User: Grant/Deny access

    User->>FileController: Create/Update case file
    FileController->>CaseCompletedGuard: Verify case completion
    CaseCompletedGuard-->>FileController: Return verification result
    FileController-->>User: Confirm action
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3795598 and f8339e7.

Files selected for processing (5)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/file/guards/limitedAccessViewCaseFile.guard.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts (5 hunks)
Additional context used
Path-based instructions (5)
apps/judicial-system/backend/src/app/modules/file/guards/limitedAccessViewCaseFile.guard.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (7)
apps/judicial-system/backend/src/app/modules/file/guards/limitedAccessViewCaseFile.guard.ts (1)

49-66: Refined access logic for different user roles and case types looks good.

Ensure that unit tests cover these new conditions to verify correct behavior.

#!/bin/bash
# Description: Verify unit tests for `LimitedAccessViewCaseFileGuard`.

# Test: Search for unit tests related to `LimitedAccessViewCaseFileGuard`.
rg --type typescript $'describe\\("Limited Access View Case File Guard"'

Also applies to: 68-74

apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts (3)

62-62: Addition of CaseCompletedGuard to createPresignedPost method enhances security by ensuring operations are only performed on completed cases.

#!/bin/bash
# Description: Verify integration of `createPresignedPost` with the front-end.

# Test: Search for front-end calls to `createPresignedPost`.
rg --type typescript $'createPresignedPost'

83-83: Addition of CaseCompletedGuard and LimitedAccessWriteCaseFileGuard to createCaseFile method correctly restricts file creation to appropriate cases and users.

#!/bin/bash
# Description: Verify integration of `createCaseFile` with the front-end.

# Test: Search for front-end calls to `createCaseFile`.
rg --type typescript $'createCaseFile'

126-126: Addition of multiple guards to deleteCaseFile method ensures secure and restricted file deletion in valid, completed cases.

#!/bin/bash
# Description: Verify integration of `deleteCaseFile` with the front-end.

# Test: Search for front-end calls to `deleteCaseFile`.
rg --type typescript $'deleteCaseFile'
apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts (1)

29-29: Enhancements in limitedAccessCase.service.ts with the addition of EventType, EventLog, and related logic improve event handling capabilities.

Ensure that unit tests cover these new functionalities to verify correct behavior.

#!/bin/bash
# Description: Verify unit tests for `LimitedAccessCaseService`.

# Test: Search for unit tests related to `LimitedAccessCaseService`.
rg --type typescript $'describe\\("Limited Access Case Service"'

Also applies to: 37-37, 115-198

apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts (1)

153-153: Expansion of test coverage in limitedAccessViewCaseFileGuard.spec.ts to include all values of CaseState is a positive change, ensuring comprehensive testing.

#!/bin/bash
# Description: Verify completeness of test coverage for `LimitedAccessViewCaseFileGuard`.

# Test: Search for test cases covering all `CaseState` values.
rg --type typescript $'it\\("should'
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

248-252: Duplicate entry for indictmentReviewer removed from the include array.

#!/bin/bash
# Description: Verify that the removal of the duplicate `indictmentReviewer` entry does not affect other functionalities.

# Test: Search for usage of `indictmentReviewer` in the application. Expect: No errors or missing data issues.
rg --type ts 'indictmentReviewer'

Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.12%. Comparing base (1566034) to head (6df8e20).

Current head 6df8e20 differs from pull request most recent head cae6c80

Please upload reports for the commit cae6c80 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15070      +/-   ##
==========================================
+ Coverage   37.10%   37.12%   +0.02%     
==========================================
  Files        6415     6406       -9     
  Lines      130585   130383     -202     
  Branches    37287    37195      -92     
==========================================
- Hits        48452    48405      -47     
+ Misses      82133    81978     -155     
Flag Coverage Δ
api 3.44% <ø> (ø)
api-domains-auth-admin 57.91% <ø> (ø)
application-system-api 41.97% <ø> (-0.03%) ⬇️
application-template-api-modules 24.22% <ø> (-0.04%) ⬇️
auth-api-lib 9.55% <ø> (+0.06%) ⬆️
judicial-system-backend 55.88% <100.00%> (+0.01%) ⬆️
services-user-notification 47.58% <ø> (+0.03%) ⬆️
services-user-profile 62.59% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ystem/backend/src/app/modules/case/case.service.ts 93.36% <ø> (ø)
.../src/app/modules/case/limitedAccessCase.service.ts 71.55% <100.00%> (+0.53%) ⬆️
...les/file/guards/limitedAccessViewCaseFile.guard.ts 100.00% <100.00%> (ø)
...c/app/modules/file/limitedAccessFile.controller.ts 100.00% <100.00%> (ø)

... and 68 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1566034...cae6c80. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 4, 2024

Datadog Report

All test runs 02e4735 🔗

12 Total Test Services: 0 Failed, 12 Passed
⬆️ Test Sessions change in coverage: 3 increased, 19 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 5.52s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 19.12s 1 no change Link
application-system-api 0 0 0 111 2 3m 41.02s 1 no change Link
application-template-api-modules 0 0 0 109 0 2m 2.81s 1 increased (+0.02%) Link
auth-api-lib 0 0 0 13 0 48.73s 1 increased (+0.04%) Link
judicial-system-backend 0 0 0 19276 0 20m 19.02s 1 no change Link
services-auth-admin-api 0 0 0 108 0 3m 48.53s 1 no change Link
services-auth-delegation-api 0 0 0 254 0 3m 51.88s 1 no change Link
services-auth-ids-api 0 0 0 201 0 1m 46.97s 1 no change Link
services-auth-personal-representative 0 0 0 59 0 1m 27.7s 1 no change Link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (4)
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/limitedAccessFileControllerGuards.spec.ts (1)

Line range hint 8-8: Replace any with a more specific type to enhance type safety.

- let guards: any[]
+ let guards: GuardType[] // Assuming GuardType is the correct type, replace with the actual type used for guards.
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostGuards.spec.ts (1)

Line range hint 15-15: Replace any with a more specific type to enhance type safety.

- let guards: any[]
+ let guards: GuardType[] // Assuming GuardType is the correct type, replace with the actual type used for guards.
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileGuards.spec.ts (1)

Line range hint 16-16: Replace any with a more specific type to enhance type safety.

- let guards: any[]
+ let guards: GuardType[] // Assuming GuardType is the correct type, replace with the actual type used for guards.
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileGuards.spec.ts (1)

Line range hint 17-17: Replace any with a more specific type to enhance type safety.

- let guards: any[]
+ let guards: GuardType[] // Assuming GuardType is the correct type, replace with the actual type used for guards.
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f8339e7 and 6df8e20.

Files selected for processing (4)
  • apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileGuards.spec.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostGuards.spec.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileGuards.spec.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/limitedAccessFileControllerGuards.spec.ts (2 hunks)
Additional context used
Path-based instructions (4)
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/limitedAccessFileControllerGuards.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostGuards.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileGuards.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileGuards.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Biome
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/limitedAccessFileControllerGuards.spec.ts

[error] 8-8: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)

any disables many type checking rules. Its use should be avoided.

apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostGuards.spec.ts

[error] 15-15: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)

any disables many type checking rules. Its use should be avoided.

apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileGuards.spec.ts

[error] 16-16: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)

any disables many type checking rules. Its use should be avoided.

apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileGuards.spec.ts

[error] 17-17: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)

any disables many type checking rules. Its use should be avoided.

Additional comments not posted (4)
apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/limitedAccessFileControllerGuards.spec.ts (1)

15-15: Ensure the guard configuration is correct.

The configuration of guards appears to be correctly updated to reflect the removal of CaseCompletedGuard from the class-level guards, aligning with the PR's objectives to refine access control logic.

apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostGuards.spec.ts (1)

25-31: Verify the updated guard configuration.

The guard configuration for creating presigned posts appears correctly updated to include CaseCompletedGuard, aligning with the PR's objectives.

Verification successful

The guard configuration for the createPresignedPost method includes CaseCompletedGuard, CaseWriteGuard, and CaseTypeGuard with the expected conditions. This aligns with the PR's objectives.

  • CaseTypeGuard with allowed case types [...restrictionCases, ...investigationCases]
  • CaseWriteGuard
  • CaseCompletedGuard
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the guard configuration for createPresignedPost matches the expected types and conditions.

# Test: Check the guard types and conditions.
rg --type typescript $'createPresignedPost' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 159



Script:

#!/bin/bash
# Description: Verify that the guard configuration for createPresignedPost matches the expected types and conditions.

# Test: Check the guard types and conditions.
rg --type ts 'createPresignedPost' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 345



Script:

#!/bin/bash
# Description: Verify the guards applied to the createPresignedPost method.

# Test: Check for decorators applied to the createPresignedPost method.
rg --type ts '@UseGuards' -A 5 apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 1129

apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileGuards.spec.ts (1)

26-33: Verify the updated guard configuration.

The guard configuration for creating case files appears correctly updated to include CaseCompletedGuard and LimitedAccessWriteCaseFileGuard, aligning with the PR's objectives.

Verification successful

The guard configuration for the createCaseFile method in the LimitedAccessFileController is correctly updated to include CaseCompletedGuard and LimitedAccessWriteCaseFileGuard, aligning with the PR's objectives.

  • LimitedAccessFileController class uses @UseGuards with JwtAuthGuard, RolesGuard, and LimitedAccessCaseExistsGuard.
  • The createCaseFile method specifically uses @UseGuards with CaseTypeGuard, CaseWriteGuard, CaseCompletedGuard, and LimitedAccessWriteCaseFileGuard.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the guard configuration for createCaseFile matches the expected types and conditions.

# Test: Check the guard types and conditions.
rg --type typescript $'createCaseFile' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 154



Script:

#!/bin/bash
# Description: Verify that the guard configuration for createCaseFile matches the expected types and conditions.

# Test: Check the guard types and conditions.
rg 'createCaseFile' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 189



Script:

#!/bin/bash
# Description: Verify the guard configuration for createCaseFile in the limitedAccessFile.controller.ts file.

# Search for the guard configuration in the limitedAccessFile.controller.ts file.
rg 'guards' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 472



Script:

#!/bin/bash
# Description: Verify the guard configuration for createCaseFile in the limitedAccessFile.controller.ts file.

# Search for the createCaseFile method definition and its decorators in the limitedAccessFile.controller.ts file.
rg -A 10 'createCaseFile' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 713



Script:

#!/bin/bash
# Description: Verify the guard configuration for createCaseFile in the limitedAccessFile.controller.ts file.

# Search for the controller class definition and its decorators in the limitedAccessFile.controller.ts file.
rg -A 10 '@UseGuards' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 1686

apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileGuards.spec.ts (1)

27-35: Verify the updated guard configuration.

The guard configuration for deleting case files appears correctly updated to include CaseCompletedGuard, CaseFileExistsGuard, and LimitedAccessWriteCaseFileGuard, aligning with the PR's objectives.

Verification successful

The guard configuration for the deleteCaseFile method in limitedAccessFile.controller.ts includes the following guards:

  • CaseTypeGuard
  • CaseWriteGuard
  • CaseCompletedGuard
  • CaseFileExistsGuard
  • LimitedAccessWriteCaseFileGuard

This matches the expected configuration as outlined in the review comment.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the guard configuration for deleteCaseFile matches the expected types and conditions.

# Test: Check the guard types and conditions.
rg --type typescript $'deleteCaseFile' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 154



Script:

#!/bin/bash
# Description: Verify that the guard configuration for deleteCaseFile matches the expected types and conditions.

# Test: Check the guard types and conditions.
rg 'deleteCaseFile' apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 181



Script:

#!/bin/bash
# Description: Verify the guard configuration for deleteCaseFile in the limitedAccessFile.controller.ts file.

# Test: Check the guard configuration.
rg 'deleteCaseFile' -A 10 apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 447



Script:

#!/bin/bash
# Description: Verify the guard configuration for deleteCaseFile in the limitedAccessFile.controller.ts file.

# Test: Check for the @UseGuards decorator.
rg '@UseGuards' -A 5 apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts

Length of output: 1119

@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Jun 4, 2024
@kodiakhq kodiakhq bot merged commit c9801ff into main Jun 4, 2024
24 checks passed
@kodiakhq kodiakhq bot deleted the j-s/fix-defender-confirmed-uploaded-indictment branch June 4, 2024 21:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts (1)

Line range hint 273-292: Consider replacing forEach with for...of for better performance and readability.

- theCase.caseFiles?.forEach((caseFile) => {
+ for (const caseFile of theCase.caseFiles ?? []) {
    const message = {
      type: MessageType.DELIVERY_TO_COURT_CASE_FILE,
      user,
      caseId: theCase.id,
      elementId: caseFile.id,
    }
    messages.push(message)
  }
+ }
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6df8e20 and cae6c80.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts (3 hunks)
Additional context used
Path-based instructions (1)
apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Biome
apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts

[error] 226-226: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 227-227: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 273-292: Prefer for...of instead of forEach. (lint/complexity/noForEach)

forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.

Additional comments not posted (3)
apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts (3)

29-29: Added imports for EventType and EventLog enhance the functionality by allowing event logging.

Also applies to: 37-37


116-116: Initialization of eventTypes constant is a good practice for managing event types centrally.


192-199: The addition of EventLog to the include array with specific conditions is a significant improvement for filtering event logs based on type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants