Skip to content

Commit

Permalink
Merge pull request #480 from oceanprotocol/issue-472-clean-logs-raw-data
Browse files Browse the repository at this point in the history
hide raw data on logging, when checking command data
  • Loading branch information
paulo-ocean authored May 28, 2024
2 parents 3618e5b + 50472fe commit 98fdc42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit 98fdc42

Please sign in to comment.