blob: 5c18702defb5cc990221d78f8f2e78ea2c6ae6a6 [file] [log] [blame]
Darryl Green10d9ce32018-02-28 10:02:55 +00001#!/usr/bin/env python3
Gilles Peskine7dfcfce2019-07-04 19:31:02 +02002
Bence Szépkúti1e148272020-08-07 13:07:28 +02003# Copyright The Mbed TLS Contributors
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02004# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
Gilles Peskine7dfcfce2019-07-04 19:31:02 +020017
Darryl Green10d9ce32018-02-28 10:02:55 +000018"""
Darryl Green10d9ce32018-02-28 10:02:55 +000019This script checks the current state of the source code for minor issues,
20including incorrect file permissions, presence of tabs, non-Unix line endings,
Gilles Peskine55b49ee2019-07-04 19:31:33 +020021trailing whitespace, and presence of UTF-8 BOM.
Darryl Green10d9ce32018-02-28 10:02:55 +000022Note: requires python 3, must be run from Mbed TLS root.
23"""
24
25import os
26import argparse
27import logging
28import codecs
Gilles Peskine0598db82020-05-10 16:57:16 +020029import re
Gilles Peskine3e2ee3c2020-05-10 17:18:06 +020030import subprocess
Darryl Green10d9ce32018-02-28 10:02:55 +000031import sys
Gilles Peskineac9e7c02020-08-11 15:11:50 +020032try:
33 from typing import FrozenSet, Optional, Pattern # pylint: disable=unused-import
34except ImportError:
35 pass
Darryl Green10d9ce32018-02-28 10:02:55 +000036
Gilles Peskine7ff47662022-09-18 21:17:09 +020037import scripts_path # pylint: disable=unused-import
38from mbedtls_dev import build_tree
39
Darryl Green10d9ce32018-02-28 10:02:55 +000040
Gilles Peskine184c0962020-03-24 18:25:17 +010041class FileIssueTracker:
Gilles Peskine6ee576e2019-02-25 20:59:05 +010042 """Base class for file-wide issue tracking.
43
44 To implement a checker that processes a file as a whole, inherit from
Gilles Peskine1e9698a2019-02-25 21:10:04 +010045 this class and implement `check_file_for_issue` and define ``heading``.
46
Gilles Peskine05a51a82020-05-10 16:52:44 +020047 ``suffix_exemptions``: files whose name ends with a string in this set
Gilles Peskine1e9698a2019-02-25 21:10:04 +010048 will not be checked.
49
Gilles Peskine0598db82020-05-10 16:57:16 +020050 ``path_exemptions``: files whose path (relative to the root of the source
51 tree) matches this regular expression will not be checked. This can be
52 ``None`` to match no path. Paths are normalized and converted to ``/``
53 separators before matching.
54
Gilles Peskine1e9698a2019-02-25 21:10:04 +010055 ``heading``: human-readable description of the issue
Gilles Peskine6ee576e2019-02-25 20:59:05 +010056 """
Darryl Green10d9ce32018-02-28 10:02:55 +000057
Gilles Peskineac9e7c02020-08-11 15:11:50 +020058 suffix_exemptions = frozenset() #type: FrozenSet[str]
59 path_exemptions = None #type: Optional[Pattern[str]]
Gilles Peskine1e9698a2019-02-25 21:10:04 +010060 # heading must be defined in derived classes.
61 # pylint: disable=no-member
62
Darryl Green10d9ce32018-02-28 10:02:55 +000063 def __init__(self):
Darryl Green10d9ce32018-02-28 10:02:55 +000064 self.files_with_issues = {}
65
Gilles Peskine0598db82020-05-10 16:57:16 +020066 @staticmethod
67 def normalize_path(filepath):
Gilles Peskineeca95db2020-05-28 18:19:20 +020068 """Normalize ``filepath`` with / as the directory separator."""
Gilles Peskine0598db82020-05-10 16:57:16 +020069 filepath = os.path.normpath(filepath)
Gilles Peskineeca95db2020-05-28 18:19:20 +020070 # On Windows, we may have backslashes to separate directories.
71 # We need slashes to match exemption lists.
Gilles Peskine0598db82020-05-10 16:57:16 +020072 seps = os.path.sep
73 if os.path.altsep is not None:
74 seps += os.path.altsep
75 return '/'.join(filepath.split(seps))
76
Darryl Green10d9ce32018-02-28 10:02:55 +000077 def should_check_file(self, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +010078 """Whether the given file name should be checked.
79
Gilles Peskine05a51a82020-05-10 16:52:44 +020080 Files whose name ends with a string listed in ``self.suffix_exemptions``
81 or whose path matches ``self.path_exemptions`` will not be checked.
Gilles Peskineaaee4442020-03-24 16:49:21 +010082 """
Gilles Peskine05a51a82020-05-10 16:52:44 +020083 for files_exemption in self.suffix_exemptions:
Darryl Green10d9ce32018-02-28 10:02:55 +000084 if filepath.endswith(files_exemption):
85 return False
Gilles Peskine0598db82020-05-10 16:57:16 +020086 if self.path_exemptions and \
87 re.match(self.path_exemptions, self.normalize_path(filepath)):
88 return False
Darryl Green10d9ce32018-02-28 10:02:55 +000089 return True
90
Darryl Green10d9ce32018-02-28 10:02:55 +000091 def check_file_for_issue(self, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +010092 """Check the specified file for the issue that this class is for.
93
94 Subclasses must implement this method.
95 """
Gilles Peskine6ee576e2019-02-25 20:59:05 +010096 raise NotImplementedError
Darryl Green10d9ce32018-02-28 10:02:55 +000097
Gilles Peskine04398052018-11-23 21:11:30 +010098 def record_issue(self, filepath, line_number):
Gilles Peskineaaee4442020-03-24 16:49:21 +010099 """Record that an issue was found at the specified location."""
Gilles Peskine04398052018-11-23 21:11:30 +0100100 if filepath not in self.files_with_issues.keys():
101 self.files_with_issues[filepath] = []
102 self.files_with_issues[filepath].append(line_number)
103
Darryl Green10d9ce32018-02-28 10:02:55 +0000104 def output_file_issues(self, logger):
Gilles Peskineaaee4442020-03-24 16:49:21 +0100105 """Log all the locations where the issue was found."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000106 if self.files_with_issues.values():
107 logger.info(self.heading)
108 for filename, lines in sorted(self.files_with_issues.items()):
109 if lines:
110 logger.info("{}: {}".format(
111 filename, ", ".join(str(x) for x in lines)
112 ))
113 else:
114 logger.info(filename)
115 logger.info("")
116
Gilles Peskined4a853d2020-05-10 16:57:59 +0200117BINARY_FILE_PATH_RE_LIST = [
118 r'docs/.*\.pdf\Z',
119 r'programs/fuzz/corpuses/[^.]+\Z',
120 r'tests/data_files/[^.]+\Z',
121 r'tests/data_files/.*\.(crt|csr|db|der|key|pubkey)\Z',
122 r'tests/data_files/.*\.req\.[^/]+\Z',
123 r'tests/data_files/.*malformed[^/]+\Z',
124 r'tests/data_files/format_pkcs12\.fmt\Z',
125]
126BINARY_FILE_PATH_RE = re.compile('|'.join(BINARY_FILE_PATH_RE_LIST))
127
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100128class LineIssueTracker(FileIssueTracker):
129 """Base class for line-by-line issue tracking.
Darryl Green10d9ce32018-02-28 10:02:55 +0000130
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100131 To implement a checker that processes files line by line, inherit from
132 this class and implement `line_with_issue`.
133 """
134
Gilles Peskined4a853d2020-05-10 16:57:59 +0200135 # Exclude binary files.
136 path_exemptions = BINARY_FILE_PATH_RE
137
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100138 def issue_with_line(self, line, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +0100139 """Check the specified line for the issue that this class is for.
140
141 Subclasses must implement this method.
142 """
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100143 raise NotImplementedError
144
145 def check_file_line(self, filepath, line, line_number):
146 if self.issue_with_line(line, filepath):
147 self.record_issue(filepath, line_number)
148
149 def check_file_for_issue(self, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +0100150 """Check the lines of the specified file.
151
152 Subclasses must implement the ``issue_with_line`` method.
153 """
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100154 with open(filepath, "rb") as f:
155 for i, line in enumerate(iter(f.readline, b"")):
156 self.check_file_line(filepath, line, i + 1)
157
Gilles Peskine2c618732020-03-24 22:26:01 +0100158
159def is_windows_file(filepath):
160 _root, ext = os.path.splitext(filepath)
Gilles Peskined2df86f2020-05-10 17:36:51 +0200161 return ext in ('.bat', '.dsp', '.dsw', '.sln', '.vcxproj')
Gilles Peskine2c618732020-03-24 22:26:01 +0100162
163
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100164class PermissionIssueTracker(FileIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100165 """Track files with bad permissions.
166
167 Files that are not executable scripts must not be executable."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000168
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100169 heading = "Incorrect permissions:"
Darryl Green10d9ce32018-02-28 10:02:55 +0000170
Gilles Peskine15898ee2020-08-08 23:14:27 +0200171 # .py files can be either full scripts or modules, so they may or may
172 # not be executable.
173 suffix_exemptions = frozenset({".py"})
174
Darryl Green10d9ce32018-02-28 10:02:55 +0000175 def check_file_for_issue(self, filepath):
Gilles Peskine23e64f22019-02-25 21:24:27 +0100176 is_executable = os.access(filepath, os.X_OK)
Gilles Peskine15898ee2020-08-08 23:14:27 +0200177 should_be_executable = filepath.endswith((".sh", ".pl"))
Gilles Peskine23e64f22019-02-25 21:24:27 +0100178 if is_executable != should_be_executable:
Darryl Green10d9ce32018-02-28 10:02:55 +0000179 self.files_with_issues[filepath] = None
180
181
Gilles Peskine4aebb8d2020-08-08 23:15:18 +0200182class ShebangIssueTracker(FileIssueTracker):
183 """Track files with a bad, missing or extraneous shebang line.
184
185 Executable scripts must start with a valid shebang (#!) line.
186 """
187
188 heading = "Invalid shebang line:"
189
190 # Allow either /bin/sh, /bin/bash, or /usr/bin/env.
191 # Allow at most one argument (this is a Linux limitation).
192 # For sh and bash, the argument if present must be options.
Shaun Case0e7791f2021-12-20 21:14:10 -0800193 # For env, the argument must be the base name of the interpreter.
Gilles Peskine4aebb8d2020-08-08 23:15:18 +0200194 _shebang_re = re.compile(rb'^#! ?(?:/bin/(bash|sh)(?: -[^\n ]*)?'
195 rb'|/usr/bin/env ([^\n /]+))$')
196 _extensions = {
197 b'bash': 'sh',
198 b'perl': 'pl',
199 b'python3': 'py',
200 b'sh': 'sh',
201 }
202
203 def is_valid_shebang(self, first_line, filepath):
204 m = re.match(self._shebang_re, first_line)
205 if not m:
206 return False
207 interpreter = m.group(1) or m.group(2)
208 if interpreter not in self._extensions:
209 return False
210 if not filepath.endswith('.' + self._extensions[interpreter]):
211 return False
212 return True
213
214 def check_file_for_issue(self, filepath):
215 is_executable = os.access(filepath, os.X_OK)
216 with open(filepath, "rb") as f:
217 first_line = f.readline()
218 if first_line.startswith(b'#!'):
219 if not is_executable:
220 # Shebang on a non-executable file
221 self.files_with_issues[filepath] = None
222 elif not self.is_valid_shebang(first_line, filepath):
223 self.files_with_issues[filepath] = [1]
224 elif is_executable:
225 # Executable without a shebang
226 self.files_with_issues[filepath] = None
227
228
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100229class EndOfFileNewlineIssueTracker(FileIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100230 """Track files that end with an incomplete line
231 (no newline character at the end of the last line)."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000232
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100233 heading = "Missing newline at end of file:"
Darryl Green10d9ce32018-02-28 10:02:55 +0000234
Gilles Peskined4a853d2020-05-10 16:57:59 +0200235 path_exemptions = BINARY_FILE_PATH_RE
236
Darryl Green10d9ce32018-02-28 10:02:55 +0000237 def check_file_for_issue(self, filepath):
238 with open(filepath, "rb") as f:
Gilles Peskine12b180a2020-05-10 17:36:42 +0200239 try:
240 f.seek(-1, 2)
241 except OSError:
242 # This script only works on regular files. If we can't seek
243 # 1 before the end, it means that this position is before
244 # the beginning of the file, i.e. that the file is empty.
245 return
246 if f.read(1) != b"\n":
Darryl Green10d9ce32018-02-28 10:02:55 +0000247 self.files_with_issues[filepath] = None
248
249
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100250class Utf8BomIssueTracker(FileIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100251 """Track files that start with a UTF-8 BOM.
252 Files should be ASCII or UTF-8. Valid UTF-8 does not start with a BOM."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000253
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100254 heading = "UTF-8 BOM present:"
Darryl Green10d9ce32018-02-28 10:02:55 +0000255
Gilles Peskine05a51a82020-05-10 16:52:44 +0200256 suffix_exemptions = frozenset([".vcxproj", ".sln"])
Gilles Peskined4a853d2020-05-10 16:57:59 +0200257 path_exemptions = BINARY_FILE_PATH_RE
Gilles Peskine2c618732020-03-24 22:26:01 +0100258
Darryl Green10d9ce32018-02-28 10:02:55 +0000259 def check_file_for_issue(self, filepath):
260 with open(filepath, "rb") as f:
261 if f.read().startswith(codecs.BOM_UTF8):
262 self.files_with_issues[filepath] = None
263
264
Gilles Peskine2c618732020-03-24 22:26:01 +0100265class UnixLineEndingIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100266 """Track files with non-Unix line endings (i.e. files with CR)."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000267
Gilles Peskine2c618732020-03-24 22:26:01 +0100268 heading = "Non-Unix line endings:"
269
270 def should_check_file(self, filepath):
Gilles Peskine0598db82020-05-10 16:57:16 +0200271 if not super().should_check_file(filepath):
272 return False
Gilles Peskine2c618732020-03-24 22:26:01 +0100273 return not is_windows_file(filepath)
Darryl Green10d9ce32018-02-28 10:02:55 +0000274
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100275 def issue_with_line(self, line, _filepath):
Darryl Green10d9ce32018-02-28 10:02:55 +0000276 return b"\r" in line
277
278
Gilles Peskine545e13f2020-03-24 22:29:11 +0100279class WindowsLineEndingIssueTracker(LineIssueTracker):
Gilles Peskined703a2e2020-04-01 13:35:46 +0200280 """Track files with non-Windows line endings (i.e. CR or LF not in CRLF)."""
Gilles Peskine545e13f2020-03-24 22:29:11 +0100281
282 heading = "Non-Windows line endings:"
283
284 def should_check_file(self, filepath):
Gilles Peskine0598db82020-05-10 16:57:16 +0200285 if not super().should_check_file(filepath):
286 return False
Gilles Peskine545e13f2020-03-24 22:29:11 +0100287 return is_windows_file(filepath)
288
289 def issue_with_line(self, line, _filepath):
Gilles Peskined703a2e2020-04-01 13:35:46 +0200290 return not line.endswith(b"\r\n") or b"\r" in line[:-2]
Gilles Peskine545e13f2020-03-24 22:29:11 +0100291
292
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100293class TrailingWhitespaceIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100294 """Track lines with trailing whitespace."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000295
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100296 heading = "Trailing whitespace:"
Gilles Peskine05a51a82020-05-10 16:52:44 +0200297 suffix_exemptions = frozenset([".dsp", ".md"])
Darryl Green10d9ce32018-02-28 10:02:55 +0000298
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100299 def issue_with_line(self, line, _filepath):
Darryl Green10d9ce32018-02-28 10:02:55 +0000300 return line.rstrip(b"\r\n") != line.rstrip()
301
302
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100303class TabIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100304 """Track lines with tabs."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000305
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100306 heading = "Tabs present:"
Gilles Peskine05a51a82020-05-10 16:52:44 +0200307 suffix_exemptions = frozenset([
Gilles Peskine344da1c2020-05-10 17:37:02 +0200308 ".pem", # some openssl dumps have tabs
Gilles Peskine2c618732020-03-24 22:26:01 +0100309 ".sln",
Gilles Peskine6e8d5a02020-03-24 22:01:28 +0100310 "/Makefile",
311 "/Makefile.inc",
312 "/generate_visualc_files.pl",
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100313 ])
Darryl Green10d9ce32018-02-28 10:02:55 +0000314
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100315 def issue_with_line(self, line, _filepath):
Darryl Green10d9ce32018-02-28 10:02:55 +0000316 return b"\t" in line
317
318
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100319class MergeArtifactIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100320 """Track lines with merge artifacts.
321 These are leftovers from a ``git merge`` that wasn't fully edited."""
Gilles Peskinec117d592018-11-23 21:11:52 +0100322
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100323 heading = "Merge artifact:"
Gilles Peskinec117d592018-11-23 21:11:52 +0100324
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100325 def issue_with_line(self, line, _filepath):
Gilles Peskinec117d592018-11-23 21:11:52 +0100326 # Detect leftover git conflict markers.
327 if line.startswith(b'<<<<<<< ') or line.startswith(b'>>>>>>> '):
328 return True
329 if line.startswith(b'||||||| '): # from merge.conflictStyle=diff3
330 return True
331 if line.rstrip(b'\r\n') == b'=======' and \
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100332 not _filepath.endswith('.md'):
Gilles Peskinec117d592018-11-23 21:11:52 +0100333 return True
334 return False
335
Darryl Green10d9ce32018-02-28 10:02:55 +0000336
Gilles Peskine184c0962020-03-24 18:25:17 +0100337class IntegrityChecker:
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100338 """Sanity-check files under the current directory."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000339
340 def __init__(self, log_file):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100341 """Instantiate the sanity checker.
342 Check files under the current directory.
343 Write a report of issues to log_file."""
Gilles Peskine7ff47662022-09-18 21:17:09 +0200344 build_tree.check_repo_path()
Darryl Green10d9ce32018-02-28 10:02:55 +0000345 self.logger = None
346 self.setup_logger(log_file)
Darryl Green10d9ce32018-02-28 10:02:55 +0000347 self.issues_to_check = [
348 PermissionIssueTracker(),
Gilles Peskine4aebb8d2020-08-08 23:15:18 +0200349 ShebangIssueTracker(),
Darryl Green10d9ce32018-02-28 10:02:55 +0000350 EndOfFileNewlineIssueTracker(),
351 Utf8BomIssueTracker(),
Gilles Peskine2c618732020-03-24 22:26:01 +0100352 UnixLineEndingIssueTracker(),
Gilles Peskine545e13f2020-03-24 22:29:11 +0100353 WindowsLineEndingIssueTracker(),
Darryl Green10d9ce32018-02-28 10:02:55 +0000354 TrailingWhitespaceIssueTracker(),
355 TabIssueTracker(),
Gilles Peskinec117d592018-11-23 21:11:52 +0100356 MergeArtifactIssueTracker(),
Darryl Green10d9ce32018-02-28 10:02:55 +0000357 ]
358
Darryl Green10d9ce32018-02-28 10:02:55 +0000359 def setup_logger(self, log_file, level=logging.INFO):
360 self.logger = logging.getLogger()
361 self.logger.setLevel(level)
362 if log_file:
363 handler = logging.FileHandler(log_file)
364 self.logger.addHandler(handler)
365 else:
366 console = logging.StreamHandler()
367 self.logger.addHandler(console)
368
Gilles Peskine3e2ee3c2020-05-10 17:18:06 +0200369 @staticmethod
370 def collect_files():
371 bytes_output = subprocess.check_output(['git', 'ls-files', '-z'])
372 bytes_filepaths = bytes_output.split(b'\0')[:-1]
373 ascii_filepaths = map(lambda fp: fp.decode('ascii'), bytes_filepaths)
374 # Prepend './' to files in the top-level directory so that
375 # something like `'/Makefile' in fp` matches in the top-level
376 # directory as well as in subdirectories.
377 return [fp if os.path.dirname(fp) else os.path.join(os.curdir, fp)
378 for fp in ascii_filepaths]
Gilles Peskine95c55752018-09-28 11:48:10 +0200379
Darryl Green10d9ce32018-02-28 10:02:55 +0000380 def check_files(self):
Gilles Peskine3e2ee3c2020-05-10 17:18:06 +0200381 for issue_to_check in self.issues_to_check:
382 for filepath in self.collect_files():
383 if issue_to_check.should_check_file(filepath):
384 issue_to_check.check_file_for_issue(filepath)
Darryl Green10d9ce32018-02-28 10:02:55 +0000385
386 def output_issues(self):
387 integrity_return_code = 0
388 for issue_to_check in self.issues_to_check:
389 if issue_to_check.files_with_issues:
390 integrity_return_code = 1
391 issue_to_check.output_file_issues(self.logger)
392 return integrity_return_code
393
394
395def run_main():
Gilles Peskine7dfcfce2019-07-04 19:31:02 +0200396 parser = argparse.ArgumentParser(description=__doc__)
Darryl Green10d9ce32018-02-28 10:02:55 +0000397 parser.add_argument(
398 "-l", "--log_file", type=str, help="path to optional output log",
399 )
400 check_args = parser.parse_args()
401 integrity_check = IntegrityChecker(check_args.log_file)
402 integrity_check.check_files()
403 return_code = integrity_check.output_issues()
404 sys.exit(return_code)
405
406
407if __name__ == "__main__":
408 run_main()