Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.get('/logfiles/', function(req, res, next) {
listLogFiles(app, (err, files) => {
if (err) {
console.error(err)
res.status(500)
res.send('Error reading logfiles list')
return
}
res.json(files)
})
})
app.get('/logfiles/:filename', function(req, res, next) {
return (providerId, data) => {
const plugin = app.pluginsMap[id]
if (
!_.isUndefined(plugin) &&
pluginsLoggingEnabled &&
plugin.enableLogging
) {
if (!plugin.logger) {
plugin.logger = getLogger(app, providerId)
}
plugin.logger(data)
}
app.handleMessage(id, data)
}
}
return (providerId: string, data: any) => {
const plugin = app.pluginsMap[id]
if (
!_.isUndefined(plugin) &&
pluginsLoggingEnabled &&
plugin.enableLogging
) {
if (!plugin.logger) {
plugin.logger = getLogger(app, providerId)
}
plugin.logger(data)
}
app.handleMessage(id, data)
}
}
app.get('/logfiles/:filename', function(req, res, next) {
const sanitizedLogfile = path
.join(getFullLogDir(app), req.params.filename)
.replace(/\.\./g, '')
res.sendFile(sanitizedLogfile)
})
}