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

hide raw data on logging, when checking command data #480

Merged
merged 5 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/core/compute/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ export class ComputeInitializeHandler extends Handler {
}

async handle(task: ComputeInitializeCommand): Promise<P2PCommandResponse> {
console.log('BEFORE: ', task)
const validationResponse = await this.verifyParamsAndRateLimits(task)
if (this.shouldDenyTaskHandling(validationResponse)) {
return validationResponse
}
console.log('AFTER: ', task)

try {
let foundValidCompute = null
Expand Down
9 changes: 7 additions & 2 deletions src/components/httpRoutes/validateCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ export function validateCommandParameters(
return buildInvalidRequestMessage(`Invalid or unrecognized command: "${commandStr}"`)
}

const logCommandData = commandData
// deep copy
const logCommandData = structuredClone(commandData)

if (commandStr === PROTOCOL_COMMANDS.ENCRYPT) {
logCommandData.files = [] // hide files data for logging
logCommandData.files = [] // hide files data (sensitive) + rawData (long buffer) from logging
} else if (commandStr === PROTOCOL_COMMANDS.ENCRYPT_FILE && commandData.rawData) {
logCommandData.rawData = []
}

CORE_LOGGER.info(
`Checking received command data for Command "${commandStr}": ${JSON.stringify(
logCommandData,
Expand Down
Loading