-
Notifications
You must be signed in to change notification settings - Fork 91
feat: add endpoint to report false Blockaid scan results (COR-636) #2815
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8ec5207
feat: add endpoint to report false Blockaid scan results (COR-636)
08b1545
feat: add request_id to threat analysis response
1144e18
refactor: address PR review comments for COR-636
d2bd22c
refactor: update request_id handling and logging in SafeShield and Th…
Fbartoli 1723bb0
test: update mock response in ThreatAnalysisService tests to handle u…
Fbartoli dab3d17
refactor: update reportTransaction method to use ReportEvent type
Fbartoli ea89619
chore: trigger CI
Fbartoli 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
71 changes: 71 additions & 0 deletions
71
src/modules/safe-shield/entities/dtos/report-false-result.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,71 @@ | ||
| import { ApiProperty } from '@nestjs/swagger'; | ||
| import { z } from 'zod'; | ||
|
|
||
| /** | ||
| * Event types for reporting false Blockaid scan results. | ||
| * | ||
| * - FALSE_POSITIVE: Transaction was flagged as malicious but is actually safe | ||
| * - FALSE_NEGATIVE: Transaction was not flagged but should have been | ||
| */ | ||
| export const ReportEvent = ['FALSE_POSITIVE', 'FALSE_NEGATIVE'] as const; | ||
|
|
||
| /** | ||
| * Zod schema for validating ReportEvent enum values. | ||
| */ | ||
| export const ReportEventSchema = z.enum(ReportEvent); | ||
|
|
||
| export type ReportEvent = z.infer<typeof ReportEventSchema>; | ||
|
|
||
| /** | ||
| * Zod schema for validating report false result requests. | ||
| * | ||
| * The 1000 character limit on details is a CGW-imposed safeguard | ||
| * to prevent abuse, as Blockaid does not enforce a specific limit. | ||
| */ | ||
| export const ReportFalseResultRequestSchema = z.object({ | ||
| event: ReportEventSchema, | ||
| request_id: z.string().uuid(), | ||
| details: z.string().min(1).max(1000), | ||
| }); | ||
|
|
||
| export type ReportFalseResultRequest = z.infer< | ||
| typeof ReportFalseResultRequestSchema | ||
| >; | ||
|
|
||
| /** | ||
| * DTO for reporting false Blockaid scan results. | ||
| * Used to submit feedback when a transaction was incorrectly classified. | ||
| */ | ||
| export class ReportFalseResultRequestDto implements ReportFalseResultRequest { | ||
| @ApiProperty({ | ||
| enum: [...ReportEvent], | ||
| description: | ||
| 'Type of report: FALSE_POSITIVE if flagged incorrectly, FALSE_NEGATIVE if should have been flagged', | ||
| }) | ||
| public readonly event!: ReportEvent; | ||
|
|
||
| @ApiProperty({ | ||
| description: 'The request_id from the original Blockaid scan response', | ||
| example: '11111111-1111-1111-1111-111111111111', | ||
| }) | ||
| public readonly request_id!: string; | ||
|
|
||
| @ApiProperty({ | ||
| description: 'Details about why this is a false result', | ||
| maxLength: 1000, | ||
| example: 'This transaction was incorrectly flagged as malicious', | ||
| }) | ||
| public readonly details!: string; | ||
| } | ||
|
|
||
| /** | ||
| * DTO for report false result response. | ||
| * Indicates whether the report was successfully submitted to Blockaid. | ||
| */ | ||
| export class ReportFalseResultResponseDto { | ||
| @ApiProperty({ | ||
| description: 'Whether the report was submitted successfully', | ||
| example: true, | ||
| }) | ||
| public readonly success!: boolean; | ||
| } | ||
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
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
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
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.