refactor: fix file condition checks

This commit is contained in:
wancat committed 2024-02-19 18:35:39 +08:00
1 parent 64215d3ef1
commit 4ab3096fa5
5 files changed
+16 -20

No files matched your search

@@ -1,13 +1,14 @@
import { execFile } from 'child_process'
import { buildFileCheckCmd } from '@linux-odyssey/utils'
import type { IFileCondition } from '@linux-odyssey/models'
function sanitizeId(id) {
function sanitizeId(id: string) {
return id.replace(/[^a-zA-Z0-9]/g, '')
}
// eslint-disable-next-line import/prefer-default-export
export function checkFile(id, file) {
export function checkFile(id: string, file: IFileCondition) {
return new Promise((resolve, reject) => {
const cmd = buildFileCheckCmd(file)
// WARNING: This is vulnerable to command injection