-
Notifications
You must be signed in to change notification settings - Fork 4
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
add flash from file endpoint #93
base: master
Are you sure you want to change the base?
Conversation
Change-type: patch Signed-off-by: Ryan Cooke <[email protected]>
Change-type: patch Signed-off-by: Ryan Cooke <[email protected]>
Change-type: patch Signed-off-by: Ryan Cooke <[email protected]>
async (req: express.Request, res: express.Response) => { | ||
res.writeHead(202, { | ||
'Content-Type': 'text/event-stream', | ||
Connection: 'keep-alive', | ||
}); | ||
|
||
const timer = setInterval(() => { | ||
res.write('status: pending'); | ||
}, 5000); | ||
|
||
|
||
try { | ||
let FILENAME = req.body.filename; | ||
if(FILENAME.includes(`.gz`)){ | ||
console.log(`Unzipping file`) | ||
console.log(await execSync(`gunzip -f ${FILENAME}`)) | ||
FILENAME = FILENAME.replace(/\.gz$/, ''); | ||
} | ||
console.log(`Attempting to flash with file: ${FILENAME}...`); | ||
await worker.flash(FILENAME); | ||
clearInterval(timer); | ||
res.end() | ||
} catch (e) { | ||
//TODO: respdond with error instead of just doing nothing | ||
console.log(e); | ||
clearInterval(timer); | ||
res.end() | ||
} | ||
} |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a system command
let FILENAME = req.body.filename; | ||
if(FILENAME.includes(`.gz`)){ | ||
console.log(`Unzipping file`) | ||
console.log(await execSync(`gunzip -f ${FILENAME}`)) |
Check failure
Code scanning / CodeQL
Uncontrolled command line Critical
user-provided value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall, had some comments inline
lib/index.ts
Outdated
@@ -356,7 +362,7 @@ async function setup( | |||
|
|||
const timer = setInterval(() => { | |||
res.write('status: pending'); | |||
}, httpServer.keepAliveTimeout); | |||
}, 5000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for defining this. So helpful
|
||
|
||
try { | ||
let FILENAME = req.body.filename; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let FILENAME = req.body.filename; | |
const FILENAME = req.body.filename; |
if(FILENAME.includes(`.gz`)){ | ||
console.log(`Unzipping file`) | ||
console.log(await execSync(`gunzip -f ${FILENAME}`)) | ||
FILENAME = FILENAME.replace(/\.gz$/, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FILENAME = FILENAME.replace(/\.gz$/, ''); |
FILENAME = FILENAME.replace(/\.gz$/, ''); | ||
} | ||
console.log(`Attempting to flash with file: ${FILENAME}...`); | ||
await worker.flash(FILENAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await worker.flash(FILENAME); | |
await worker.flash(FILENAME.replace(/\.gz$/, '')); |
Are we deleting the zipped file after the unzipping. Just making sure the clean up happens.
allows to flash from a file on the worker without streaming it over http first