1
- import unittest
2
- import re
3
1
import os
2
+ import re
3
+ import unittest
4
4
5
5
6
6
class ImportLoadLibs (unittest .TestCase ):
@@ -11,71 +11,71 @@ class ImportLoadLibs(unittest.TestCase):
11
11
# The whitelist is a list of regex expressions that mark wanted libraries
12
12
# Note that the regex has to result in an exact match with the library name.
13
13
known_libs = [
14
- # libCore and dependencies
15
- ' libCore' ,
16
- ' libm' ,
17
- ' liblz4' ,
18
- ' libxxhash' ,
19
- ' liblzma' ,
20
- ' libzstd' ,
21
- ' libz' ,
22
- ' libpthread' ,
23
- ' libc' ,
24
- ' libdl' ,
25
- ' libpcre' ,
26
- ' libpcre2-8' ,
27
- # libCling and dependencies
28
- ' libCling.*' ,
29
- ' librt' ,
30
- ' libncurses.*' ,
31
- ' libtinfo' , # by libncurses (on some older platforms)
32
- # libTree and dependencies
33
- ' libTree' ,
34
- ' libThread' ,
35
- ' libRIO' ,
36
- ' libNet' ,
37
- ' libImt' ,
38
- ' libMathCore' ,
39
- ' libMultiProc' ,
40
- ' libssl' ,
41
- ' libcrypt.*' , # by libssl
42
- ' libtbb' ,
43
- ' libtbb_debug' ,
44
- ' libtbbmalloc' ,
45
- ' liburing' , # by libRIO if uring option is enabled
46
- ' libgomp' , # by adaptivecpp
47
- # On centos7 libssl links against kerberos pulling in all dependencies below, removed with libssl1.1.0
48
- ' libgssapi_krb5' ,
49
- ' libkrb5' ,
50
- ' libk5crypto' ,
51
- ' libkrb5support' ,
52
- ' libselinux' ,
53
- ' libkeyutils' ,
54
- ' libcom_err' ,
55
- ' libresolv' ,
56
- # cppyy and Python libraries
57
- ' libcppyy.*' ,
58
- ' libROOTPythonizations.*' ,
59
- ' libpython.*' ,
60
- ' libutil.*' ,
61
- ' .*cpython.*' ,
62
- ' _.*' ,
63
- ' .*module' ,
64
- ' operator' ,
65
- ' cStringIO' ,
66
- ' binascii' ,
67
- ' libbz2' ,
68
- ' libexpat' ,
69
- ' ISO8859-1' ,
70
- # System libraries and others
71
- ' libnss_.*' ,
72
- ' ld.*' ,
73
- ' libffi' ,
74
- ' libgcc_s' ,
75
- # AddressSanitizer runtime and ROOT configuration
76
- ' libclang_rt.asan-.*' ,
77
- ' libROOTSanitizerConfig' ,
78
- ]
14
+ # libCore and dependencies
15
+ " libCore" ,
16
+ " libm" ,
17
+ " liblz4" ,
18
+ " libxxhash" ,
19
+ " liblzma" ,
20
+ " libzstd" ,
21
+ " libz" ,
22
+ " libpthread" ,
23
+ " libc" ,
24
+ " libdl" ,
25
+ " libpcre" ,
26
+ " libpcre2-8" ,
27
+ # libCling and dependencies
28
+ " libCling.*" ,
29
+ " librt" ,
30
+ " libncurses.*" ,
31
+ " libtinfo" , # by libncurses (on some older platforms)
32
+ # libTree and dependencies
33
+ " libTree" ,
34
+ " libThread" ,
35
+ " libRIO" ,
36
+ " libNet" ,
37
+ " libImt" ,
38
+ " libMathCore" ,
39
+ " libMultiProc" ,
40
+ " libssl" ,
41
+ " libcrypt.*" , # by libssl
42
+ " libtbb" ,
43
+ " libtbb_debug" ,
44
+ " libtbbmalloc" ,
45
+ " liburing" , # by libRIO if uring option is enabled
46
+ " libgomp" , # by adaptivecpp
47
+ # On centos7 libssl links against kerberos pulling in all dependencies below, removed with libssl1.1.0
48
+ " libgssapi_krb5" ,
49
+ " libkrb5" ,
50
+ " libk5crypto" ,
51
+ " libkrb5support" ,
52
+ " libselinux" ,
53
+ " libkeyutils" ,
54
+ " libcom_err" ,
55
+ " libresolv" ,
56
+ # cppyy and Python libraries
57
+ " libcppyy.*" ,
58
+ " libROOTPythonizations.*" ,
59
+ " libpython.*" ,
60
+ " libutil.*" ,
61
+ " .*cpython.*" ,
62
+ " _.*" ,
63
+ " .*module" ,
64
+ " operator" ,
65
+ " cStringIO" ,
66
+ " binascii" ,
67
+ " libbz2" ,
68
+ " libexpat" ,
69
+ " ISO8859-1" ,
70
+ # System libraries and others
71
+ " libnss_.*" ,
72
+ " ld.*" ,
73
+ " libffi" ,
74
+ " libgcc_s" ,
75
+ # AddressSanitizer runtime and ROOT configuration
76
+ " libclang_rt.asan-.*" ,
77
+ " libROOTSanitizerConfig" ,
78
+ ]
79
79
80
80
# Verbose mode of the test
81
81
verbose = False
@@ -94,30 +94,30 @@ def test_import(self):
94
94
libs = libs .split (' ' )
95
95
96
96
# Get library name without full path and .so* suffix
97
- libs = [os .path .basename (l ).split ('.so' )[0 ] for l in libs \
98
- if not l .startswith ('-l' ) and not l .startswith ('-L' )]
97
+ libs = [os .path .basename (lib ).split ('.so' )[0 ] for lib in libs \
98
+ if not lib .startswith ('-l' ) and not lib .startswith ('-L' )]
99
99
100
100
# Check that the loaded libraries are white listed
101
101
bad_libs = []
102
102
good_libs = []
103
103
matched_re = []
104
- for l in libs :
104
+ for lib in libs :
105
105
matched = False
106
106
for r in self .known_libs :
107
- m = re .match (r , l )
107
+ m = re .match (r , lib )
108
108
if m :
109
- if m .group (0 ) == l :
109
+ if m .group (0 ) == lib :
110
110
matched = True
111
- good_libs .append (l )
111
+ good_libs .append (lib )
112
112
matched_re .append (r )
113
113
break
114
114
if not matched :
115
- bad_libs .append (l )
115
+ bad_libs .append (lib )
116
116
117
117
if self .verbose :
118
118
print ('Found whitelisted libraries after importing ROOT with the shown regex match:' )
119
- for l , r in zip (good_libs , matched_re ):
120
- print (' - {} ({})' .format (l , r ))
119
+ for lib , r in zip (good_libs , matched_re ):
120
+ print (' - {} ({})' .format (lib , r ))
121
121
import sys
122
122
sys .stdout .flush ()
123
123
0 commit comments