feat: execute files check via docker cli

WARNING: possible command injection vunerability.
This commit is contained in:
Lin, Hung-Shin authored and wancat committed 2023-10-29 17:41:38 +08:00
1 parent 38f3dbcd65
commit 50b1fe5124
4 files changed
+17 -53

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
import { exec } from 'child_process'
import { buildFileCheckCmd } from '@linux-odyssey/utils'
// eslint-disable-next-line import/prefer-default-export
export function checkFiles(id, files) {
return new Promise((resolve) => {
const cmd = buildFileCheckCmd(files)
// WARNING: This is not secure!
exec(`docker exec ${id} ${cmd}`, (error, stdout, stderr) => {
console.log('stdout', stdout)
console.log('stderr', stderr)
resolve(!error)
})
})
}