blob: 50af88a6b6764eabc001499191028007c38fe4ec [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
37
Gilles Peskine184c0962020-03-24 18:25:17 +010038class FileIssueTracker:
Gilles Peskine6ee576e2019-02-25 20:59:05 +010039 """Base class for file-wide issue tracking.
40
41 To implement a checker that processes a file as a whole, inherit from
Gilles Peskine1e9698a2019-02-25 21:10:04 +010042 this class and implement `check_file_for_issue` and define ``heading``.
43
Gilles Peskine05a51a82020-05-10 16:52:44 +020044 ``suffix_exemptions``: files whose name ends with a string in this set
Gilles Peskine1e9698a2019-02-25 21:10:04 +010045 will not be checked.
46
Gilles Peskine0598db82020-05-10 16:57:16 +020047 ``path_exemptions``: files whose path (relative to the root of the source
48 tree) matches this regular expression will not be checked. This can be
49 ``None`` to match no path. Paths are normalized and converted to ``/``
50 separators before matching.
51
Gilles Peskine1e9698a2019-02-25 21:10:04 +010052 ``heading``: human-readable description of the issue
Gilles Peskine6ee576e2019-02-25 20:59:05 +010053 """
Darryl Green10d9ce32018-02-28 10:02:55 +000054
Gilles Peskineac9e7c02020-08-11 15:11:50 +020055 suffix_exemptions = frozenset() #type: FrozenSet[str]
56 path_exemptions = None #type: Optional[Pattern[str]]
Gilles Peskine1e9698a2019-02-25 21:10:04 +010057 # heading must be defined in derived classes.
58 # pylint: disable=no-member
59
Darryl Green10d9ce32018-02-28 10:02:55 +000060 def __init__(self):
Darryl Green10d9ce32018-02-28 10:02:55 +000061 self.files_with_issues = {}
62
Gilles Peskine0598db82020-05-10 16:57:16 +020063 @staticmethod
64 def normalize_path(filepath):
Gilles Peskineeca95db2020-05-28 18:19:20 +020065 """Normalize ``filepath`` with / as the directory separator."""
Gilles Peskine0598db82020-05-10 16:57:16 +020066 filepath = os.path.normpath(filepath)
Gilles Peskineeca95db2020-05-28 18:19:20 +020067 # On Windows, we may have backslashes to separate directories.
68 # We need slashes to match exemption lists.
Gilles Peskine0598db82020-05-10 16:57:16 +020069 seps = os.path.sep
70 if os.path.altsep is not None:
71 seps += os.path.altsep
72 return '/'.join(filepath.split(seps))
73
Darryl Green10d9ce32018-02-28 10:02:55 +000074 def should_check_file(self, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +010075 """Whether the given file name should be checked.
76
Gilles Peskine05a51a82020-05-10 16:52:44 +020077 Files whose name ends with a string listed in ``self.suffix_exemptions``
78 or whose path matches ``self.path_exemptions`` will not be checked.
Gilles Peskineaaee4442020-03-24 16:49:21 +010079 """
Gilles Peskine05a51a82020-05-10 16:52:44 +020080 for files_exemption in self.suffix_exemptions:
Darryl Green10d9ce32018-02-28 10:02:55 +000081 if filepath.endswith(files_exemption):
82 return False
Gilles Peskine0598db82020-05-10 16:57:16 +020083 if self.path_exemptions and \
84 re.match(self.path_exemptions, self.normalize_path(filepath)):
85 return False
Darryl Green10d9ce32018-02-28 10:02:55 +000086 return True
87
Darryl Green10d9ce32018-02-28 10:02:55 +000088 def check_file_for_issue(self, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +010089 """Check the specified file for the issue that this class is for.
90
91 Subclasses must implement this method.
92 """
Gilles Peskine6ee576e2019-02-25 20:59:05 +010093 raise NotImplementedError
Darryl Green10d9ce32018-02-28 10:02:55 +000094
Gilles Peskine04398052018-11-23 21:11:30 +010095 def record_issue(self, filepath, line_number):
Gilles Peskineaaee4442020-03-24 16:49:21 +010096 """Record that an issue was found at the specified location."""
Gilles Peskine04398052018-11-23 21:11:30 +010097 if filepath not in self.files_with_issues.keys():
98 self.files_with_issues[filepath] = []
99 self.files_with_issues[filepath].append(line_number)
100
Darryl Green10d9ce32018-02-28 10:02:55 +0000101 def output_file_issues(self, logger):
Gilles Peskineaaee4442020-03-24 16:49:21 +0100102 """Log all the locations where the issue was found."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000103 if self.files_with_issues.values():
104 logger.info(self.heading)
105 for filename, lines in sorted(self.files_with_issues.items()):
106 if lines:
107 logger.info("{}: {}".format(
108 filename, ", ".join(str(x) for x in lines)
109 ))
110 else:
111 logger.info(filename)
112 logger.info("")
113
Gilles Peskined4a853d2020-05-10 16:57:59 +0200114BINARY_FILE_PATH_RE_LIST = [
115 r'docs/.*\.pdf\Z',
116 r'programs/fuzz/corpuses/[^.]+\Z',
117 r'tests/data_files/[^.]+\Z',
118 r'tests/data_files/.*\.(crt|csr|db|der|key|pubkey)\Z',
119 r'tests/data_files/.*\.req\.[^/]+\Z',
120 r'tests/data_files/.*malformed[^/]+\Z',
121 r'tests/data_files/format_pkcs12\.fmt\Z',
Nick Childfc234b72022-11-02 15:23:39 -0500122 r'tests/data_files/pkcs7_data.*\.bin\Z',
Gilles Peskined4a853d2020-05-10 16:57:59 +0200123]
124BINARY_FILE_PATH_RE = re.compile('|'.join(BINARY_FILE_PATH_RE_LIST))
125
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100126class LineIssueTracker(FileIssueTracker):
127 """Base class for line-by-line issue tracking.
Darryl Green10d9ce32018-02-28 10:02:55 +0000128
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100129 To implement a checker that processes files line by line, inherit from
130 this class and implement `line_with_issue`.
131 """
132
Gilles Peskined4a853d2020-05-10 16:57:59 +0200133 # Exclude binary files.
134 path_exemptions = BINARY_FILE_PATH_RE
135
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100136 def issue_with_line(self, line, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +0100137 """Check the specified line for the issue that this class is for.
138
139 Subclasses must implement this method.
140 """
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100141 raise NotImplementedError
142
143 def check_file_line(self, filepath, line, line_number):
144 if self.issue_with_line(line, filepath):
145 self.record_issue(filepath, line_number)
146
147 def check_file_for_issue(self, filepath):
Gilles Peskineaaee4442020-03-24 16:49:21 +0100148 """Check the lines of the specified file.
149
150 Subclasses must implement the ``issue_with_line`` method.
151 """
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100152 with open(filepath, "rb") as f:
153 for i, line in enumerate(iter(f.readline, b"")):
154 self.check_file_line(filepath, line, i + 1)
155
Gilles Peskine2c618732020-03-24 22:26:01 +0100156
157def is_windows_file(filepath):
158 _root, ext = os.path.splitext(filepath)
Gilles Peskined2df86f2020-05-10 17:36:51 +0200159 return ext in ('.bat', '.dsp', '.dsw', '.sln', '.vcxproj')
Gilles Peskine2c618732020-03-24 22:26:01 +0100160
161
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100162class PermissionIssueTracker(FileIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100163 """Track files with bad permissions.
164
165 Files that are not executable scripts must not be executable."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000166
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100167 heading = "Incorrect permissions:"
Darryl Green10d9ce32018-02-28 10:02:55 +0000168
Gilles Peskine15898ee2020-08-08 23:14:27 +0200169 # .py files can be either full scripts or modules, so they may or may
170 # not be executable.
171 suffix_exemptions = frozenset({".py"})
172
Darryl Green10d9ce32018-02-28 10:02:55 +0000173 def check_file_for_issue(self, filepath):
Gilles Peskine23e64f22019-02-25 21:24:27 +0100174 is_executable = os.access(filepath, os.X_OK)
Gilles Peskine15898ee2020-08-08 23:14:27 +0200175 should_be_executable = filepath.endswith((".sh", ".pl"))
Gilles Peskine23e64f22019-02-25 21:24:27 +0100176 if is_executable != should_be_executable:
Darryl Green10d9ce32018-02-28 10:02:55 +0000177 self.files_with_issues[filepath] = None
178
179
Gilles Peskine4aebb8d2020-08-08 23:15:18 +0200180class ShebangIssueTracker(FileIssueTracker):
181 """Track files with a bad, missing or extraneous shebang line.
182
183 Executable scripts must start with a valid shebang (#!) line.
184 """
185
186 heading = "Invalid shebang line:"
187
188 # Allow either /bin/sh, /bin/bash, or /usr/bin/env.
189 # Allow at most one argument (this is a Linux limitation).
190 # For sh and bash, the argument if present must be options.
Shaun Case8b0ecbc2021-12-20 21:14:10 -0800191 # For env, the argument must be the base name of the interpreter.
Gilles Peskine4aebb8d2020-08-08 23:15:18 +0200192 _shebang_re = re.compile(rb'^#! ?(?:/bin/(bash|sh)(?: -[^\n ]*)?'
193 rb'|/usr/bin/env ([^\n /]+))$')
194 _extensions = {
195 b'bash': 'sh',
196 b'perl': 'pl',
197 b'python3': 'py',
198 b'sh': 'sh',
199 }
200
201 def is_valid_shebang(self, first_line, filepath):
202 m = re.match(self._shebang_re, first_line)
203 if not m:
204 return False
205 interpreter = m.group(1) or m.group(2)
206 if interpreter not in self._extensions:
207 return False
208 if not filepath.endswith('.' + self._extensions[interpreter]):
209 return False
210 return True
211
212 def check_file_for_issue(self, filepath):
213 is_executable = os.access(filepath, os.X_OK)
214 with open(filepath, "rb") as f:
215 first_line = f.readline()
216 if first_line.startswith(b'#!'):
217 if not is_executable:
218 # Shebang on a non-executable file
219 self.files_with_issues[filepath] = None
220 elif not self.is_valid_shebang(first_line, filepath):
221 self.files_with_issues[filepath] = [1]
222 elif is_executable:
223 # Executable without a shebang
224 self.files_with_issues[filepath] = None
225
226
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100227class EndOfFileNewlineIssueTracker(FileIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100228 """Track files that end with an incomplete line
229 (no newline character at the end of the last line)."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000230
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100231 heading = "Missing newline at end of file:"
Darryl Green10d9ce32018-02-28 10:02:55 +0000232
Gilles Peskined4a853d2020-05-10 16:57:59 +0200233 path_exemptions = BINARY_FILE_PATH_RE
234
Darryl Green10d9ce32018-02-28 10:02:55 +0000235 def check_file_for_issue(self, filepath):
236 with open(filepath, "rb") as f:
Gilles Peskine12b180a2020-05-10 17:36:42 +0200237 try:
238 f.seek(-1, 2)
239 except OSError:
240 # This script only works on regular files. If we can't seek
241 # 1 before the end, it means that this position is before
242 # the beginning of the file, i.e. that the file is empty.
243 return
244 if f.read(1) != b"\n":
Darryl Green10d9ce32018-02-28 10:02:55 +0000245 self.files_with_issues[filepath] = None
246
247
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100248class Utf8BomIssueTracker(FileIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100249 """Track files that start with a UTF-8 BOM.
250 Files should be ASCII or UTF-8. Valid UTF-8 does not start with a BOM."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000251
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100252 heading = "UTF-8 BOM present:"
Darryl Green10d9ce32018-02-28 10:02:55 +0000253
Gilles Peskine05a51a82020-05-10 16:52:44 +0200254 suffix_exemptions = frozenset([".vcxproj", ".sln"])
Gilles Peskined4a853d2020-05-10 16:57:59 +0200255 path_exemptions = BINARY_FILE_PATH_RE
Gilles Peskine2c618732020-03-24 22:26:01 +0100256
Darryl Green10d9ce32018-02-28 10:02:55 +0000257 def check_file_for_issue(self, filepath):
258 with open(filepath, "rb") as f:
259 if f.read().startswith(codecs.BOM_UTF8):
260 self.files_with_issues[filepath] = None
261
262
Gilles Peskine2c618732020-03-24 22:26:01 +0100263class UnixLineEndingIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100264 """Track files with non-Unix line endings (i.e. files with CR)."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000265
Gilles Peskine2c618732020-03-24 22:26:01 +0100266 heading = "Non-Unix line endings:"
267
268 def should_check_file(self, filepath):
Gilles Peskine0598db82020-05-10 16:57:16 +0200269 if not super().should_check_file(filepath):
270 return False
Gilles Peskine2c618732020-03-24 22:26:01 +0100271 return not is_windows_file(filepath)
Darryl Green10d9ce32018-02-28 10:02:55 +0000272
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100273 def issue_with_line(self, line, _filepath):
Darryl Green10d9ce32018-02-28 10:02:55 +0000274 return b"\r" in line
275
276
Gilles Peskine545e13f2020-03-24 22:29:11 +0100277class WindowsLineEndingIssueTracker(LineIssueTracker):
Gilles Peskined703a2e2020-04-01 13:35:46 +0200278 """Track files with non-Windows line endings (i.e. CR or LF not in CRLF)."""
Gilles Peskine545e13f2020-03-24 22:29:11 +0100279
280 heading = "Non-Windows line endings:"
281
282 def should_check_file(self, filepath):
Gilles Peskine0598db82020-05-10 16:57:16 +0200283 if not super().should_check_file(filepath):
284 return False
Gilles Peskine545e13f2020-03-24 22:29:11 +0100285 return is_windows_file(filepath)
286
287 def issue_with_line(self, line, _filepath):
Gilles Peskined703a2e2020-04-01 13:35:46 +0200288 return not line.endswith(b"\r\n") or b"\r" in line[:-2]
Gilles Peskine545e13f2020-03-24 22:29:11 +0100289
290
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100291class TrailingWhitespaceIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100292 """Track lines with trailing whitespace."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000293
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100294 heading = "Trailing whitespace:"
Gilles Peskine05a51a82020-05-10 16:52:44 +0200295 suffix_exemptions = frozenset([".dsp", ".md"])
Darryl Green10d9ce32018-02-28 10:02:55 +0000296
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100297 def issue_with_line(self, line, _filepath):
Darryl Green10d9ce32018-02-28 10:02:55 +0000298 return line.rstrip(b"\r\n") != line.rstrip()
299
300
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100301class TabIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100302 """Track lines with tabs."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000303
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100304 heading = "Tabs present:"
Gilles Peskine05a51a82020-05-10 16:52:44 +0200305 suffix_exemptions = frozenset([
Gilles Peskine344da1c2020-05-10 17:37:02 +0200306 ".pem", # some openssl dumps have tabs
Gilles Peskine2c618732020-03-24 22:26:01 +0100307 ".sln",
Gilles Peskine6e8d5a02020-03-24 22:01:28 +0100308 "/Makefile",
309 "/Makefile.inc",
310 "/generate_visualc_files.pl",
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100311 ])
Darryl Green10d9ce32018-02-28 10:02:55 +0000312
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100313 def issue_with_line(self, line, _filepath):
Darryl Green10d9ce32018-02-28 10:02:55 +0000314 return b"\t" in line
315
316
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100317class MergeArtifactIssueTracker(LineIssueTracker):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100318 """Track lines with merge artifacts.
319 These are leftovers from a ``git merge`` that wasn't fully edited."""
Gilles Peskinec117d592018-11-23 21:11:52 +0100320
Gilles Peskine1e9698a2019-02-25 21:10:04 +0100321 heading = "Merge artifact:"
Gilles Peskinec117d592018-11-23 21:11:52 +0100322
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100323 def issue_with_line(self, line, _filepath):
Gilles Peskinec117d592018-11-23 21:11:52 +0100324 # Detect leftover git conflict markers.
325 if line.startswith(b'<<<<<<< ') or line.startswith(b'>>>>>>> '):
326 return True
327 if line.startswith(b'||||||| '): # from merge.conflictStyle=diff3
328 return True
329 if line.rstrip(b'\r\n') == b'=======' and \
Gilles Peskine6ee576e2019-02-25 20:59:05 +0100330 not _filepath.endswith('.md'):
Gilles Peskinec117d592018-11-23 21:11:52 +0100331 return True
332 return False
333
Darryl Green10d9ce32018-02-28 10:02:55 +0000334
Gilles Peskine184c0962020-03-24 18:25:17 +0100335class IntegrityChecker:
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100336 """Sanity-check files under the current directory."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000337
338 def __init__(self, log_file):
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100339 """Instantiate the sanity checker.
340 Check files under the current directory.
341 Write a report of issues to log_file."""
Darryl Green10d9ce32018-02-28 10:02:55 +0000342 self.check_repo_path()
343 self.logger = None
344 self.setup_logger(log_file)
Darryl Green10d9ce32018-02-28 10:02:55 +0000345 self.issues_to_check = [
346 PermissionIssueTracker(),
Gilles Peskine4aebb8d2020-08-08 23:15:18 +0200347 ShebangIssueTracker(),
Darryl Green10d9ce32018-02-28 10:02:55 +0000348 EndOfFileNewlineIssueTracker(),
349 Utf8BomIssueTracker(),
Gilles Peskine2c618732020-03-24 22:26:01 +0100350 UnixLineEndingIssueTracker(),
Gilles Peskine545e13f2020-03-24 22:29:11 +0100351 WindowsLineEndingIssueTracker(),
Darryl Green10d9ce32018-02-28 10:02:55 +0000352 TrailingWhitespaceIssueTracker(),
353 TabIssueTracker(),
Gilles Peskinec117d592018-11-23 21:11:52 +0100354 MergeArtifactIssueTracker(),
Darryl Green10d9ce32018-02-28 10:02:55 +0000355 ]
356
Gilles Peskine0d060ef2019-02-25 20:35:31 +0100357 @staticmethod
358 def check_repo_path():
Darryl Green10d9ce32018-02-28 10:02:55 +0000359 if not all(os.path.isdir(d) for d in ["include", "library", "tests"]):
360 raise Exception("Must be run from Mbed TLS root")
361
362 def setup_logger(self, log_file, level=logging.INFO):
363 self.logger = logging.getLogger()
364 self.logger.setLevel(level)
365 if log_file:
366 handler = logging.FileHandler(log_file)
367 self.logger.addHandler(handler)
368 else:
369 console = logging.StreamHandler()
370 self.logger.addHandler(console)
371
Gilles Peskine3e2ee3c2020-05-10 17:18:06 +0200372 @staticmethod
373 def collect_files():
374 bytes_output = subprocess.check_output(['git', 'ls-files', '-z'])
375 bytes_filepaths = bytes_output.split(b'\0')[:-1]
376 ascii_filepaths = map(lambda fp: fp.decode('ascii'), bytes_filepaths)
377 # Prepend './' to files in the top-level directory so that
378 # something like `'/Makefile' in fp` matches in the top-level
379 # directory as well as in subdirectories.
380 return [fp if os.path.dirname(fp) else os.path.join(os.curdir, fp)
381 for fp in ascii_filepaths]
Gilles Peskine95c55752018-09-28 11:48:10 +0200382
Darryl Green10d9ce32018-02-28 10:02:55 +0000383 def check_files(self):
Gilles Peskine3e2ee3c2020-05-10 17:18:06 +0200384 for issue_to_check in self.issues_to_check:
385 for filepath in self.collect_files():
386 if issue_to_check.should_check_file(filepath):
387 issue_to_check.check_file_for_issue(filepath)
Darryl Green10d9ce32018-02-28 10:02:55 +0000388
389 def output_issues(self):
390 integrity_return_code = 0
391 for issue_to_check in self.issues_to_check:
392 if issue_to_check.files_with_issues:
393 integrity_return_code = 1
394 issue_to_check.output_file_issues(self.logger)
395 return integrity_return_code
396
397
398def run_main():
Gilles Peskine7dfcfce2019-07-04 19:31:02 +0200399 parser = argparse.ArgumentParser(description=__doc__)
Darryl Green10d9ce32018-02-28 10:02:55 +0000400 parser.add_argument(
401 "-l", "--log_file", type=str, help="path to optional output log",
402 )
403 check_args = parser.parse_args()
404 integrity_check = IntegrityChecker(check_args.log_file)
405 integrity_check.check_files()
406 return_code = integrity_check.output_issues()
407 sys.exit(return_code)
408
409
410if __name__ == "__main__":
411 run_main()