-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(j-s): Security&Integrity (#16863)
* Throws proper exceptions from digital mailbox * Refactors code * Refactors code * Refactors code * Removes unused imports * Removes unused imports * Removes unused import * Removes redundant code * Rewrites internal indictment case endpoint * Adds unit tests * Reorders query conditions * Rewrites defendant indictment cases endpoint * Adds civil claimant exists guard to update and delete civil claimant * Removes unused endpoint * Uses proper subpoena gueard for limited access subpoena controller * Splits subpoena exists guard and reorders controller decorators * Adds unit test * Renames variables for clarity * Uses correct http method when getting cases * Moves subpoena status updates to subpoena module * Removes comments * Removes comments * Adds unit tests * Renames unit test * Updates unit tests * Refactors code * Adds unit tests * Adds unit tests * Fixes subpoena refresh * Cleans up some code * Removes unnecessary export * Rmoves console log. * Update apps/judicial-system/backend/src/app/modules/case/guards/test/indictmentCaseExistsForDefendantGuard.spec.ts * Updates unit test * Fixes type import * Fixes typo * Fixes typo * Fixes type decorators * Fixes typo * Refactors code * Rewrites subpoena info diff --------- Co-authored-by: unakb <una@kolibri.is> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
04edebb
commit 9f4f9ae
Showing
73 changed files
with
1,246 additions
and
519 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export { PoliceCaseInfo } from './models/policeCaseInfo.model' | ||
export { SubpoenaStatus } from './models/subpoenaStatus.model' | ||
export { PoliceCaseFile } from './models/policeCaseFile.model' | ||
export { UploadPoliceCaseFileResponse } from './models/uploadPoliceCaseFile.response' |
21 changes: 0 additions & 21 deletions
21
apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 @@ | ||
export { Subpoena } from './models/subpoena.model' |
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
apps/judicial-system/api/src/app/modules/subpoena/subpoena.module.ts
This file contains 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,8 @@ | ||
import { Module } from '@nestjs/common' | ||
|
||
import { SubpoenaResolver } from './subpoena.resolver' | ||
|
||
@Module({ | ||
providers: [SubpoenaResolver], | ||
}) | ||
export class SubpoenaModule {} |
53 changes: 53 additions & 0 deletions
53
apps/judicial-system/api/src/app/modules/subpoena/subpoena.resolver.ts
This file contains 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,53 @@ | ||
import { Inject, UseGuards } from '@nestjs/common' | ||
import { Args, Context, Query, Resolver } from '@nestjs/graphql' | ||
|
||
import type { Logger } from '@island.is/logging' | ||
import { LOGGER_PROVIDER } from '@island.is/logging' | ||
|
||
import { | ||
AuditedAction, | ||
AuditTrailService, | ||
} from '@island.is/judicial-system/audit-trail' | ||
import { | ||
CurrentGraphQlUser, | ||
JwtGraphQlAuthGuard, | ||
} from '@island.is/judicial-system/auth' | ||
import type { User } from '@island.is/judicial-system/types' | ||
|
||
import { BackendService } from '../backend' | ||
import { SubpoenaQueryInput } from './dto/subpoena.input' | ||
import { Subpoena } from './models/subpoena.model' | ||
|
||
@UseGuards(JwtGraphQlAuthGuard) | ||
@Resolver() | ||
export class SubpoenaResolver { | ||
constructor( | ||
private readonly auditTrailService: AuditTrailService, | ||
@Inject(LOGGER_PROVIDER) | ||
private readonly logger: Logger, | ||
) {} | ||
|
||
@Query(() => Subpoena, { nullable: true }) | ||
subpoena( | ||
@Args('input', { type: () => SubpoenaQueryInput }) | ||
input: SubpoenaQueryInput, | ||
@CurrentGraphQlUser() user: User, | ||
@Context('dataSources') | ||
{ backendService }: { backendService: BackendService }, | ||
): Promise<Subpoena> { | ||
this.logger.debug( | ||
`Getting subpoena ${input.subpoenaId} for defendant ${input.defendantId} of case ${input.caseId}`, | ||
) | ||
|
||
return this.auditTrailService.audit( | ||
user.id, | ||
AuditedAction.GET_SUBPOENA, | ||
backendService.getSubpoena( | ||
input.caseId, | ||
input.defendantId, | ||
input.subpoenaId, | ||
), | ||
input.caseId, | ||
) | ||
} | ||
} |
This file contains 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
16 changes: 0 additions & 16 deletions
16
apps/judicial-system/backend/src/app/modules/case/dto/internalCases.dto.ts
This file was deleted.
Oops, something went wrong.
This file contains 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 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
37 changes: 37 additions & 0 deletions
37
...cial-system/backend/src/app/modules/case/guards/indictmentCaseExistsForDefendant.guard.ts
This file contains 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,37 @@ | ||
import { | ||
BadRequestException, | ||
CanActivate, | ||
ExecutionContext, | ||
Injectable, | ||
} from '@nestjs/common' | ||
|
||
import { InternalCaseService } from '../internalCase.service' | ||
|
||
@Injectable() | ||
export class IndictmentCaseExistsForDefendantGuard implements CanActivate { | ||
constructor(private readonly internalCaseService: InternalCaseService) {} | ||
|
||
async canActivate(context: ExecutionContext): Promise<boolean> { | ||
const request = context.switchToHttp().getRequest() | ||
|
||
const caseId = request.params.caseId | ||
|
||
if (!caseId) { | ||
throw new BadRequestException('Missing case id') | ||
} | ||
|
||
const defendantNationalId = request.params.defendantNationalId | ||
|
||
if (!defendantNationalId) { | ||
throw new BadRequestException('Missing defendant national id') | ||
} | ||
|
||
request.case = | ||
await this.internalCaseService.findByIdAndDefendantNationalId( | ||
caseId, | ||
defendantNationalId, | ||
) | ||
|
||
return true | ||
} | ||
} |
This file contains 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
Oops, something went wrong.