]>
Commit | Line | Data |
---|---|---|
a65627a8 TL |
1 | #!/usr/bin/env python3 |
2 | ||
3 | # Use heuristics to identify new files that maybe binaries. | |
4 | # Flagged files need to be manually inspected and either added to the | |
5 | # whitelist (because they are safe to redistribute), or to the blacklist | |
6 | # (so that they'll be removed prior to orig.tar.xz generation). | |
7 | ||
8 | import os | |
9 | import re | |
10 | import sys | |
11 | ||
12 | def nameOK(name): | |
13 | OKPatterns = ['\.gitignore', 'AUTHORS', 'FILE.LST', 'Change[lL]og', | |
14 | 'COPYING', 'configure', 'FAQ', '(GNU)?[Mm]akefile', | |
15 | 'INDEX', 'LICENSE', 'README', 'TODO' ] | |
16 | OKRegexs = map(re.compile, OKPatterns) | |
17 | ||
18 | for r in OKRegexs: | |
19 | if r.match(name): | |
20 | return True | |
21 | return False | |
22 | ||
23 | def extensionOK(name): | |
24 | OKExtensions = [ '1', '3', 'ASL', 'asi', 'asl', 'aslc', 'Asm', 'asm', | |
25 | 'asm16', 'bat', 'bmp', 'c', 'CMM', 'cmm', 'cnf', 'cpp', | |
26 | 'css', 'dec', 'decTest', 'dlg', 'dsc', 'docx', 'dsp', | |
27 | 'dsw', 'el', 'env', 'fdf', 'g', 'gif', 'H', 'h', 'hpp', | |
28 | 'html', 'i', 'idf', 'in', 'inc', 'inf', 'info', 'ini', | |
29 | 'lds', 'log', 'lua', 'mak', 'makefile', 'md', 'nasm', | |
30 | 'nasmb', 'nsh', 'patch', 'pbxuser', 'pbxproj', 'pdf', | |
31 | 'pem', 'pl', 'png', 'pod', 'ps', 'py', 'r', 'rtf', 'S', | |
32 | 's', 'sct', 'sh', 'sln', 't', 'template', 'txt', 'uni', | |
33 | 'Vfr', 'vcproj', 'vfi', 'vfr', 'xml' ] | |
34 | ext = name.split('.')[-1] | |
35 | ||
36 | if ext in OKExtensions: | |
37 | return True | |
38 | return False | |
39 | ||
40 | if __name__ == '__main__': | |
41 | top = './' | |
42 | for root, dirs, files in os.walk(top): | |
43 | with open('./debian/binary-check.whitelist', 'r') as f: | |
44 | whitelist = list(map(lambda s: s.strip(), f.readlines())) | |
45 | ||
46 | ret = 0 | |
47 | for name in files: | |
48 | relpath = os.path.join(root, name)[len(top):] | |
49 | if relpath in whitelist: | |
50 | continue | |
51 | if nameOK(name): | |
52 | continue | |
53 | if extensionOK(name): | |
54 | continue | |
55 | else: | |
56 | sys.stdout.write("WARNING: Possible binary %s\n" % (os.path.join(root, name))) | |
57 | ret = -1 | |
58 | sys.exit(ret) | |
59 |