Add logic to warning when unsupported extended attributes are found in validate-modern.py (#12827)
Blue committed
Apr 15, 2025 at 21:22 UTC
a99369981d381a1587bd159ab8f7ccb5301afc7f
1 file changed
+21
distributions/validate-modern.py
+21
@@ -34,6 +34,8 @@ DISCOURAGED_SYSTEM_UNITS = ['systemd-resolved.service',
34
'NetworkManager.service',
35
'networking.service']
36
37
+WSL1_UNSUPPORTED_XATTRS = ['security.selinux', 'security.ima', 'security.evm']
38
+
39
errors = {}
40
warnings = {}
41
@@ -322,6 +324,21 @@ def get_tar_file(tar, path: str, follow_symlink=False, symlink_depth=10):
324
325
return None, None
326
327
+def find_unsupported_attrs(tar):
328
+ found_xattrs = set()
329
+ first_file = None
330
+
331
+ for e in tar.getmembers():
332
+ for name in e.pax_headers:
333
+ if any(name.startswith('SCHILY.xattr.' + xattr) for xattr in WSL1_UNSUPPORTED_XATTRS):
334
+ found_xattrs.add(name.replace('SCHILY.xattr.', ''))
335
+
336
+ if first_file is None:
337
+ first_file = e.name
338
+
339
+ return first_file, found_xattrs
340
+
341
+
342
def read_tar(node, file, elf_magic: str):
343
with tarfile.open(fileobj=file) as tar:
344
@@ -426,6 +443,10 @@ def read_tar(node, file, elf_magic: str):
443
if unit in DISCOURAGED_SYSTEM_UNITS:
444
warning(node, f'Found discouraged system unit: {path}')
445
446
+ first_file, found_xattrs = find_unsupported_attrs(tar)
447
+ if first_file is not None:
448
+ warning(node, f'Found extended attributes that are not supported in WSL1: {found_xattrs}. Sample file: {first_file}')
449
+
450
def read_url(url: dict, elf_magic):
451
hash = hashlib.sha256()
452
address = url['Url']()