-
Notifications
You must be signed in to change notification settings - Fork 22
feat(gs): add email to userDataId lookup to debug tooling #3841
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
base: develop
Are you sure you want to change the base?
Changes from all commits
642c523
f197a69
ef4929a
199a00c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { IsNotEmpty, IsString, MaxLength } from 'class-validator'; | ||
| import { ComplianceSearchType } from 'src/subdomains/generic/support/dto/user-data-support.dto'; | ||
|
|
||
| export class DebugUserQueryDto { | ||
| @IsNotEmpty() | ||
| @IsString() | ||
| @MaxLength(256) | ||
| mail: string; | ||
| } | ||
|
|
||
| // Mirrors the compliance search result shape, but exposes only non-PII userDataIds. | ||
| export interface DebugUserResult { | ||
| type: ComplianceSearchType; | ||
| userDataIds: number[]; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { SwapService } from 'src/subdomains/core/buy-crypto/routes/swap/swap.ser | |
| import { RefRewardService } from 'src/subdomains/core/referral/reward/services/ref-reward.service'; | ||
| import { BuyFiatService } from 'src/subdomains/core/sell-crypto/process/services/buy-fiat.service'; | ||
| import { SellService } from 'src/subdomains/core/sell-crypto/route/sell.service'; | ||
| import { ComplianceSearchType } from 'src/subdomains/generic/support/dto/user-data-support.dto'; | ||
| import { BankTxRepeatService } from 'src/subdomains/supporting/bank-tx/bank-tx-repeat/bank-tx-repeat.service'; | ||
| import { BankTxType } from 'src/subdomains/supporting/bank-tx/bank-tx/entities/bank-tx.entity'; | ||
| import { BankTxService } from 'src/subdomains/supporting/bank-tx/bank-tx/services/bank-tx.service'; | ||
|
|
@@ -29,6 +30,7 @@ import { UserData } from '../user/models/user-data/user-data.entity'; | |
| import { UserDataService } from '../user/models/user-data/user-data.service'; | ||
| import { UserService } from '../user/models/user/user.service'; | ||
| import { DbQueryBaseDto, DbQueryDto, DbReturnData } from './dto/db-query.dto'; | ||
| import { DebugUserResult } from './dto/debug-user-query.dto'; | ||
| import { | ||
| DebugBlockedCols, | ||
| DebugBlockedSchemas, | ||
|
|
@@ -192,6 +194,22 @@ export class GsService { | |
| }; | ||
| } | ||
|
|
||
| // Sanctioned reverse lookup for the DEBUG tooling: the /gs/debug SQL endpoint blocks the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The queried email is deliberately omitted from the audit log, but every other debug operation logs what was queried (e.g. the SQL at line 247). For a reverse-lookup on PII this is the opposite of what you want — knowing who ran the lookup is less useful than knowing what was looked up when investigating misuse. Consider logging the mail here (the caller already has DEBUG role, so it's not an exposure risk in the log). |
||
| // user_data.mail column (PII), so an email cannot be resolved to a userDataId via SQL. This | ||
| // returns only non-PII identifiers, never the mail or any other personal data. | ||
| async resolveDebugUser(mail: string, userIdentifier: string): Promise<DebugUserResult> { | ||
| this.logger.verbose(`Debug user lookup by ${userIdentifier}`); | ||
|
|
||
| // Same resolution the compliance search uses for a mail; returns only userDataIds, no PII. | ||
| // No relations needed — only the id is read. | ||
| const userDataList = await this.userDataService.getUsersByMail(mail, false, {}); | ||
| const userDataIds = Util.toUniqueList(userDataList, 'id') | ||
| .map((userData) => userData.id) | ||
| .sort((a, b) => a - b); | ||
|
|
||
| return { type: ComplianceSearchType.MAIL, userDataIds }; | ||
| } | ||
|
|
||
| async executeDebugQuery(sql: string, userIdentifier: string): Promise<Record<string, unknown>[]> { | ||
| // 1. Parse SQL to AST for robust validation | ||
| let ast; | ||
|
|
||
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.
Missing
@IsEmail()— every other mail field in the codebase uses it (e.g.send-mail.dto.ts,kyc-data.dto.ts).@IsString()+@MaxLengthwon't rejectnot-an-emailas input.