mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
fix: block case-variant secret paths and task runner env overrides
This commit is contained in:
1 parent
b49b0b63e6
commit
a23c5195ec
5 files changed
+46
-2
No files matched your search
@@ -24,8 +24,11 @@ export function resolveFileAccess(
|
||||
const resolvedRoot = path.resolve(root);
|
||||
const target = path.resolve(resolvedRoot, ...parts);
|
||||
if (target === resolvedRoot || !isWithin(resolvedRoot, target)) return '';
|
||||
// File systems such as default APFS can resolve a differently cased spelling
|
||||
// of the same entry. Check every protected name without case sensitivity.
|
||||
const blockedNames = new Set(blacklist.map((part) => part.toLowerCase()));
|
||||
const isBlocked = (relative: string) =>
|
||||
relative.split(path.sep).some((part) => blacklist.includes(part));
|
||||
relative.split(path.sep).some((part) => blockedNames.has(part.toLowerCase()));
|
||||
if (isBlocked(path.relative(resolvedRoot, target))) return '';
|
||||
try {
|
||||
const realRoot = fs.realpathSync(resolvedRoot);
|
||||
|
||||
@@ -7,6 +7,25 @@ const reservedNames = new Set([
|
||||
'TASK_BEFORE',
|
||||
'TASK_AFTER',
|
||||
'WORK_DIR',
|
||||
'TASK_SHELL_PARAMS',
|
||||
'SCRIPT_PARAMS',
|
||||
'WHICH_PROGRAM',
|
||||
'ISJSORPYTHONFILE',
|
||||
'EXPORTED_VARIABLES',
|
||||
'FOUND_DOUBLE_DASH',
|
||||
'LOG_DIR',
|
||||
'LOG_PATH',
|
||||
'ID',
|
||||
'BEGIN_TIMESTAMP',
|
||||
'TIME_FORMAT',
|
||||
'MTIME_FORMAT',
|
||||
'IS_MACOS',
|
||||
'RANDOMDELAY',
|
||||
'RANDOMDELAYFILEEXTENSIONS',
|
||||
'RANDOMDELAYIGNOREDMINUTES',
|
||||
'COMMAND_TIMEOUT_TIME',
|
||||
'SET_U_ON',
|
||||
'_TASK_EXIT_CODE',
|
||||
'PATH',
|
||||
'HOME',
|
||||
'SHELL',
|
||||
@@ -40,6 +59,7 @@ export function isAllowedTaskEnvName(name: unknown): name is string {
|
||||
const upper = name.toUpperCase();
|
||||
return (
|
||||
!reservedNames.has(upper) &&
|
||||
!upper.startsWith('BASH_') &&
|
||||
!upper.startsWith('QL') &&
|
||||
!upper.startsWith('FILE_') &&
|
||||
!upper.startsWith('DIR_') &&
|
||||
|
||||
Reference in new issue
Block a user