mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +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
@@ -57,6 +57,16 @@ test('environment API rejects execution controls and legacy rows stay out of tas
|
||||
{ id: 7, name: 'SAFE_VALUE', value: 'kept' },
|
||||
{ id: 8, name: 'bad\nname', value: 'untrusted' },
|
||||
{ id: 9, name: 'work_dir', value: '/tmp/untrusted' },
|
||||
{ id: 10, name: 'task_shell_params', value: 'other.sh' },
|
||||
{ id: 11, name: 'which_program', value: 'bash' },
|
||||
{ id: 12, name: 'script_params', value: 'other.sh' },
|
||||
{ id: 13, name: 'LOG_DIR', value: '../../config' },
|
||||
{ id: 14, name: 'EXPORTED_VARIABLES', value: 'PATH' },
|
||||
{ id: 15, name: 'begin_timestamp', value: 'a[$(printf BAD)]' },
|
||||
{ id: 16, name: 'is_macos', value: 'a[$(printf BAD)]' },
|
||||
{ id: 17, name: 'RandomDelayIgnoredMinutes', value: 'a[$(printf BAD)]' },
|
||||
{ id: 18, name: 'ID', value: '999' },
|
||||
{ id: 19, name: 'BASH_XTRACEFD', value: '2' },
|
||||
];
|
||||
const Env = load(path.resolve('back/services/env.ts'), {
|
||||
typedi: decorators,
|
||||
@@ -87,6 +97,10 @@ test('environment API rejects execution controls and legacy rows stay out of tas
|
||||
|
||||
for (const name of [
|
||||
'task_before', 'PREV_NODE_OPTIONS', 'GIT_SSH_COMMAND', 'work_dir',
|
||||
'task_shell_params', 'which_program', 'script_params', 'LOG_DIR',
|
||||
'EXPORTED_VARIABLES',
|
||||
'begin_timestamp', 'is_macos', 'RandomDelayIgnoredMinutes', 'ID',
|
||||
'BASH_XTRACEFD',
|
||||
]) {
|
||||
await assert.rejects(
|
||||
service.create([
|
||||
@@ -121,7 +135,7 @@ test('environment API rejects execution controls and legacy rows stay out of tas
|
||||
for (const contents of Object.values(output)) {
|
||||
assert.doesNotMatch(
|
||||
contents,
|
||||
/task_before|NODE_OPTIONS|GIT_SSH_COMMAND|PATH|work_dir/,
|
||||
/task_before|NODE_OPTIONS|GIT_SSH_COMMAND|PATH|work_dir|task_shell_params|which_program|script_params|LOG_DIR|EXPORTED_VARIABLES|begin_timestamp|is_macos|RandomDelayIgnoredMinutes|ID|BASH_XTRACEFD/,
|
||||
);
|
||||
assert.match(contents, /SAFE_VALUE/);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,9 @@ for (const customData of [false, true]) {
|
||||
);
|
||||
for (const name of [
|
||||
'token.json',
|
||||
'TOKEN.JSON',
|
||||
'grpc/client.key',
|
||||
'Grpc/client.key',
|
||||
'secret-link',
|
||||
'data/scripts/secret-link',
|
||||
'data/scripts/../config/token.json',
|
||||
@@ -181,7 +183,9 @@ test('log APIs allow configuration-like names while retaining directory boundari
|
||||
fs.writeFileSync(hidden, 'hidden task command');
|
||||
for (const values of [
|
||||
{ path: '.tmp', file: 'own_user.list', filename: 'own_user.list' },
|
||||
{ path: '.TMP', file: 'own_user.list', filename: 'own_user.list' },
|
||||
{ path: '', file: '.tmp/own_user.list', filename: '.tmp/own_user.list' },
|
||||
{ path: '', file: '.Tmp/own_user.list', filename: '.Tmp/own_user.list' },
|
||||
]) {
|
||||
for (const [method, route] of [
|
||||
['get', '/detail'],
|
||||
|
||||
@@ -24,11 +24,14 @@ test('file access enforces directory boundaries, blacklist descendants and symli
|
||||
'../config-other/secret',
|
||||
'/etc/passwd',
|
||||
'grpc/client.key',
|
||||
'GRPC/client.key',
|
||||
'alias/client.key',
|
||||
'outside/new.txt',
|
||||
'dangling',
|
||||
'auth.json',
|
||||
'AUTH.JSON',
|
||||
'nested/auth.json',
|
||||
'nested/Auth.Json',
|
||||
'',
|
||||
]) {
|
||||
assert.equal(
|
||||
|
||||
Reference in new issue
Block a user