Debian Codegraph @

testsuite/operator-path-files-from_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # --files-from symlink policy matrix (also covers the shared open site used by
3 # --include-from / --exclude-from / --filter merge in exclude.c / options.c).
4 # Already refuses a foreign-owned symlink but does not honor --insecure-links --
5 # RED on the insecure cells.
6
7 import subprocess
8
9 from rsyncfns import rsync_argv, run_symlink_matrix, plant_operator_symlink
10
11
12 def case(ctx):
13 src = ctx.base / 'src'
14 dest = ctx.base / 'dest'
15 src.mkdir()
16 dest.mkdir()
17 (src / 'sentinel').write_text("X\n")
18 opt, victim = plant_operator_symlink(ctx, ctx.base, kind='file')
19 victim.write_text("sentinel\n") # attacker-controlled transfer list
20 extra = ['--insecure-links'] if ctx.insecure else []
21 subprocess.run(
22 rsync_argv('-a', f'--files-from={opt}', *extra, 'src/', 'dest/'),
23 cwd=str(ctx.base), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
24 # Followed == rsync read the out-of-tree list and transferred its named file.
25 return (dest / 'sentinel').exists()
26
27
28 run_symlink_matrix('--files-from', case)
29 print("--files-from symlink policy matrix: enforced")