mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Amend: scrub secrets from logs
Calls to `getFile` can now include S3 credentials in `opts`, so sanitize before writing to opts to log.
This commit is contained in:
parent
600ab3ce67
commit
336a38ec1e
1 changed files with 10 additions and 4 deletions
|
@ -7,7 +7,7 @@ KeyBuilder = require("./KeyBuilder")
|
||||||
async = require("async")
|
async = require("async")
|
||||||
ImageOptimiser = require("./ImageOptimiser")
|
ImageOptimiser = require("./ImageOptimiser")
|
||||||
|
|
||||||
module.exports =
|
module.exports = FileHandler =
|
||||||
|
|
||||||
insertFile: (bucket, key, stream, callback)->
|
insertFile: (bucket, key, stream, callback)->
|
||||||
convertedKey = KeyBuilder.getConvertedFolderKey key
|
convertedKey = KeyBuilder.getConvertedFolderKey key
|
||||||
|
@ -23,7 +23,8 @@ module.exports =
|
||||||
], callback
|
], callback
|
||||||
|
|
||||||
getFile: (bucket, key, opts = {}, callback)->
|
getFile: (bucket, key, opts = {}, callback)->
|
||||||
logger.log bucket:bucket, key:key, opts:opts, "getting file"
|
# In this call, opts can contain credentials
|
||||||
|
logger.log bucket:bucket, key:key, opts:@_scrubSecrets(opts), "getting file"
|
||||||
if !opts.format? and !opts.style?
|
if !opts.format? and !opts.style?
|
||||||
@_getStandardFile bucket, key, opts, callback
|
@_getStandardFile bucket, key, opts, callback
|
||||||
else
|
else
|
||||||
|
@ -32,7 +33,7 @@ module.exports =
|
||||||
_getStandardFile: (bucket, key, opts, callback)->
|
_getStandardFile: (bucket, key, opts, callback)->
|
||||||
PersistorManager.getFileStream bucket, key, opts, (err, fileStream)->
|
PersistorManager.getFileStream bucket, key, opts, (err, fileStream)->
|
||||||
if err?
|
if err?
|
||||||
logger.err bucket:bucket, key:key, opts:opts, "error getting fileStream"
|
logger.err bucket:bucket, key:key, opts:FileHandler._scrubSecrets(opts), "error getting fileStream"
|
||||||
callback err, fileStream
|
callback err, fileStream
|
||||||
|
|
||||||
_getConvertedFile: (bucket, key, opts, callback)->
|
_getConvertedFile: (bucket, key, opts, callback)->
|
||||||
|
@ -71,7 +72,7 @@ module.exports =
|
||||||
return callback(err)
|
return callback(err)
|
||||||
done = (err, destPath)->
|
done = (err, destPath)->
|
||||||
if err?
|
if err?
|
||||||
logger.err err:err, bucket:bucket, originalKey:originalKey, opts:opts, "error converting file"
|
logger.err err:err, bucket:bucket, originalKey:originalKey, opts:FileHandler._scrubSecrets(opts), "error converting file"
|
||||||
return callback(err)
|
return callback(err)
|
||||||
LocalFileWriter.deleteFile originalFsPath, ->
|
LocalFileWriter.deleteFile originalFsPath, ->
|
||||||
callback(err, destPath, originalFsPath)
|
callback(err, destPath, originalFsPath)
|
||||||
|
@ -98,3 +99,8 @@ module.exports =
|
||||||
if err?
|
if err?
|
||||||
logger.err bucket:bucket, project_id:project_id, "error getting size"
|
logger.err bucket:bucket, project_id:project_id, "error getting size"
|
||||||
callback err, size
|
callback err, size
|
||||||
|
|
||||||
|
_scrubSecrets: (opts)->
|
||||||
|
safe = Object.assign {}, opts
|
||||||
|
delete safe.credentials
|
||||||
|
safe
|
||||||
|
|
Loading…
Reference in a new issue