mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-03 23:36:17 +02:00
fix(security): sanitize verbose errors in benchmark controller
This commit is contained in:
parent
fa1036bd31
commit
a85a38e922
|
|
@ -5,6 +5,7 @@ import { runBenchmarkValidator, submitBenchmarkValidator } from '#validators/ben
|
||||||
import { RunBenchmarkJob } from '#jobs/run_benchmark_job'
|
import { RunBenchmarkJob } from '#jobs/run_benchmark_job'
|
||||||
import type { BenchmarkType } from '../../types/benchmark.js'
|
import type { BenchmarkType } from '../../types/benchmark.js'
|
||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
import logger from '@adonisjs/core/services/logger'
|
||||||
|
|
||||||
@inject()
|
@inject()
|
||||||
export default class BenchmarkController {
|
export default class BenchmarkController {
|
||||||
|
|
@ -52,9 +53,10 @@ export default class BenchmarkController {
|
||||||
result,
|
result,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
logger.error({ err: error }, '[BenchmarkController] Benchmark run failed')
|
||||||
return response.status(500).send({
|
return response.status(500).send({
|
||||||
success: false,
|
success: false,
|
||||||
error: error.message,
|
error: 'An internal error occurred while running the benchmark.',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -181,9 +183,10 @@ export default class BenchmarkController {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Pass through the status code from the service if available, otherwise default to 400
|
// Pass through the status code from the service if available, otherwise default to 400
|
||||||
const statusCode = (error as any).statusCode || 400
|
const statusCode = (error as any).statusCode || 400
|
||||||
|
logger.error({ err: error }, '[BenchmarkController] Benchmark submit failed')
|
||||||
return response.status(statusCode).send({
|
return response.status(statusCode).send({
|
||||||
success: false,
|
success: false,
|
||||||
error: error.message,
|
error: 'Failed to submit benchmark results.',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user