mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Merge remote-tracking branch 'tls/development' into development
Merge Mbed TLS at f790a6cbee
into Mbed Crypto.
Resolve conflicts by performing the following:
- Reject changes to README.md
- Don't add crypto as a submodule
- Remove test/ssl_cert_test from programs/Makefile
- Add cipher.nist_kw test to tests/CMakeLists.txt
- Reject removal of crypto-specific all.sh tests
- Reject update to SSL-specific portion of component_test_valgrind
in all.sh
- Reject addition of ssl-opt.sh testing to component_test_m32_o1 in
all.sh
* tls/development: (87 commits)
Call mbedtls_cipher_free() to reset a cipher context
Don't call mbedtls_cipher_setkey twice
Update crypto submodule
Minor fixes in get certificate policies oid test
Add certificate policy oid x509 extension
cpp_dummy_build: Add missing header psa_util.h
Clarify comment mangled by an earlier refactoring
Add an "out-of-box" component
Run ssl-opt.sh on 32-bit runtime
Don't use debug level 1 for informational messages
Skip uncritical unsupported extensions
Give credit to OSS-Fuzz for #2404
all.sh: remove component_test_new_ecdh_context
Remove crypto-only related components from all.sh
Remove ssl_cert_test sample app
Make CRT callback tests more robust
Rename constant in client2.c
Document and test flags in x509_verify
Fix style issues and a typo
Fix a rebase error
...
This commit is contained in:
@ -549,6 +549,17 @@ component_check_doxygen_warnings () {
|
||||
#### Build and test many configurations and targets
|
||||
################################################################
|
||||
|
||||
component_test_default_out_of_box () {
|
||||
msg "build: make, default config (out-of-box)" # ~1min
|
||||
make
|
||||
|
||||
msg "test: main suites make, default config (out-of-box)" # ~10s
|
||||
make test
|
||||
|
||||
msg "selftest: make, default config (out-of-box)" # ~10s
|
||||
programs/test/selftest
|
||||
}
|
||||
|
||||
component_test_default_cmake_gcc_asan () {
|
||||
msg "build: cmake, gcc, ASan" # ~ 1 min 50s
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
@ -797,6 +808,9 @@ component_test_m32_o1 () {
|
||||
# Build again with -O1, to compile in the i386 specific inline assembly
|
||||
msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
|
||||
scripts/config.pl full
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_DEBUG
|
||||
make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
|
||||
|
||||
msg "test: i386, make, gcc -O1 (ASan build)"
|
||||
@ -1061,6 +1075,9 @@ component_test_zeroize () {
|
||||
unset gdb_disable_aslr
|
||||
}
|
||||
|
||||
support_check_python_files () {
|
||||
type pylint3 >/dev/null 2>/dev/null
|
||||
}
|
||||
component_check_python_files () {
|
||||
msg "Lint: Python scripts"
|
||||
record_status tests/scripts/check-python-files.sh
|
||||
|
@ -19,14 +19,23 @@ import codecs
|
||||
import sys
|
||||
|
||||
|
||||
class IssueTracker(object):
|
||||
"""Base class for issue tracking. Issues should inherit from this and
|
||||
overwrite either issue_with_line if they check the file line by line, or
|
||||
overwrite check_file_for_issue if they check the file as a whole."""
|
||||
class FileIssueTracker(object):
|
||||
"""Base class for file-wide issue tracking.
|
||||
|
||||
To implement a checker that processes a file as a whole, inherit from
|
||||
this class and implement `check_file_for_issue` and define ``heading``.
|
||||
|
||||
``files_exemptions``: files whose name ends with a string in this set
|
||||
will not be checked.
|
||||
|
||||
``heading``: human-readable description of the issue
|
||||
"""
|
||||
|
||||
files_exemptions = frozenset()
|
||||
# heading must be defined in derived classes.
|
||||
# pylint: disable=no-member
|
||||
|
||||
def __init__(self):
|
||||
self.heading = ""
|
||||
self.files_exemptions = []
|
||||
self.files_with_issues = {}
|
||||
|
||||
def should_check_file(self, filepath):
|
||||
@ -35,23 +44,14 @@ class IssueTracker(object):
|
||||
return False
|
||||
return True
|
||||
|
||||
def issue_with_line(self, line):
|
||||
raise NotImplementedError
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
for i, line in enumerate(iter(f.readline, b"")):
|
||||
self.check_file_line(filepath, line, i + 1)
|
||||
raise NotImplementedError
|
||||
|
||||
def record_issue(self, filepath, line_number):
|
||||
if filepath not in self.files_with_issues.keys():
|
||||
self.files_with_issues[filepath] = []
|
||||
self.files_with_issues[filepath].append(line_number)
|
||||
|
||||
def check_file_line(self, filepath, line, line_number):
|
||||
if self.issue_with_line(line):
|
||||
self.record_issue(filepath, line_number)
|
||||
|
||||
def output_file_issues(self, logger):
|
||||
if self.files_with_issues.values():
|
||||
logger.info(self.heading)
|
||||
@ -64,24 +64,44 @@ class IssueTracker(object):
|
||||
logger.info(filename)
|
||||
logger.info("")
|
||||
|
||||
class LineIssueTracker(FileIssueTracker):
|
||||
"""Base class for line-by-line issue tracking.
|
||||
|
||||
class PermissionIssueTracker(IssueTracker):
|
||||
To implement a checker that processes files line by line, inherit from
|
||||
this class and implement `line_with_issue`.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Incorrect permissions:"
|
||||
def issue_with_line(self, line, filepath):
|
||||
raise NotImplementedError
|
||||
|
||||
def check_file_line(self, filepath, line, line_number):
|
||||
if self.issue_with_line(line, filepath):
|
||||
self.record_issue(filepath, line_number)
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
if not (os.access(filepath, os.X_OK) ==
|
||||
filepath.endswith((".sh", ".pl", ".py"))):
|
||||
with open(filepath, "rb") as f:
|
||||
for i, line in enumerate(iter(f.readline, b"")):
|
||||
self.check_file_line(filepath, line, i + 1)
|
||||
|
||||
class PermissionIssueTracker(FileIssueTracker):
|
||||
"""Track files with bad permissions.
|
||||
|
||||
Files that are not executable scripts must not be executable."""
|
||||
|
||||
heading = "Incorrect permissions:"
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
is_executable = os.access(filepath, os.X_OK)
|
||||
should_be_executable = filepath.endswith((".sh", ".pl", ".py"))
|
||||
if is_executable != should_be_executable:
|
||||
self.files_with_issues[filepath] = None
|
||||
|
||||
|
||||
class EndOfFileNewlineIssueTracker(IssueTracker):
|
||||
class EndOfFileNewlineIssueTracker(FileIssueTracker):
|
||||
"""Track files that end with an incomplete line
|
||||
(no newline character at the end of the last line)."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Missing newline at end of file:"
|
||||
heading = "Missing newline at end of file:"
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
@ -89,11 +109,11 @@ class EndOfFileNewlineIssueTracker(IssueTracker):
|
||||
self.files_with_issues[filepath] = None
|
||||
|
||||
|
||||
class Utf8BomIssueTracker(IssueTracker):
|
||||
class Utf8BomIssueTracker(FileIssueTracker):
|
||||
"""Track files that start with a UTF-8 BOM.
|
||||
Files should be ASCII or UTF-8. Valid UTF-8 does not start with a BOM."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "UTF-8 BOM present:"
|
||||
heading = "UTF-8 BOM present:"
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
@ -101,79 +121,76 @@ class Utf8BomIssueTracker(IssueTracker):
|
||||
self.files_with_issues[filepath] = None
|
||||
|
||||
|
||||
class LineEndingIssueTracker(IssueTracker):
|
||||
class LineEndingIssueTracker(LineIssueTracker):
|
||||
"""Track files with non-Unix line endings (i.e. files with CR)."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Non Unix line endings:"
|
||||
heading = "Non Unix line endings:"
|
||||
|
||||
def issue_with_line(self, line):
|
||||
def issue_with_line(self, line, _filepath):
|
||||
return b"\r" in line
|
||||
|
||||
|
||||
class TrailingWhitespaceIssueTracker(IssueTracker):
|
||||
class TrailingWhitespaceIssueTracker(LineIssueTracker):
|
||||
"""Track lines with trailing whitespace."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Trailing whitespace:"
|
||||
self.files_exemptions = [".md"]
|
||||
heading = "Trailing whitespace:"
|
||||
files_exemptions = frozenset(".md")
|
||||
|
||||
def issue_with_line(self, line):
|
||||
def issue_with_line(self, line, _filepath):
|
||||
return line.rstrip(b"\r\n") != line.rstrip()
|
||||
|
||||
|
||||
class TabIssueTracker(IssueTracker):
|
||||
class TabIssueTracker(LineIssueTracker):
|
||||
"""Track lines with tabs."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Tabs present:"
|
||||
self.files_exemptions = [
|
||||
"Makefile", "generate_visualc_files.pl"
|
||||
]
|
||||
heading = "Tabs present:"
|
||||
files_exemptions = frozenset([
|
||||
"Makefile",
|
||||
"generate_visualc_files.pl",
|
||||
])
|
||||
|
||||
def issue_with_line(self, line):
|
||||
def issue_with_line(self, line, _filepath):
|
||||
return b"\t" in line
|
||||
|
||||
|
||||
class MergeArtifactIssueTracker(IssueTracker):
|
||||
class MergeArtifactIssueTracker(LineIssueTracker):
|
||||
"""Track lines with merge artifacts.
|
||||
These are leftovers from a ``git merge`` that wasn't fully edited."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Merge artifact:"
|
||||
heading = "Merge artifact:"
|
||||
|
||||
def issue_with_line(self, filepath, line):
|
||||
def issue_with_line(self, line, _filepath):
|
||||
# Detect leftover git conflict markers.
|
||||
if line.startswith(b'<<<<<<< ') or line.startswith(b'>>>>>>> '):
|
||||
return True
|
||||
if line.startswith(b'||||||| '): # from merge.conflictStyle=diff3
|
||||
return True
|
||||
if line.rstrip(b'\r\n') == b'=======' and \
|
||||
not filepath.endswith('.md'):
|
||||
not _filepath.endswith('.md'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def check_file_line(self, filepath, line, line_number):
|
||||
if self.issue_with_line(filepath, line):
|
||||
self.record_issue(filepath, line_number)
|
||||
class TodoIssueTracker(LineIssueTracker):
|
||||
"""Track lines containing ``TODO``."""
|
||||
|
||||
class TodoIssueTracker(IssueTracker):
|
||||
heading = "TODO present:"
|
||||
files_exemptions = frozenset([
|
||||
os.path.basename(__file__),
|
||||
"benchmark.c",
|
||||
"pull_request_template.md",
|
||||
])
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "TODO present:"
|
||||
self.files_exemptions = [
|
||||
os.path.basename(__file__),
|
||||
"benchmark.c",
|
||||
"pull_request_template.md",
|
||||
]
|
||||
|
||||
def issue_with_line(self, line):
|
||||
def issue_with_line(self, line, _filepath):
|
||||
return b"todo" in line.lower()
|
||||
|
||||
|
||||
class IntegrityChecker(object):
|
||||
"""Sanity-check files under the current directory."""
|
||||
|
||||
def __init__(self, log_file):
|
||||
"""Instantiate the sanity checker.
|
||||
Check files under the current directory.
|
||||
Write a report of issues to log_file."""
|
||||
self.check_repo_path()
|
||||
self.logger = None
|
||||
self.setup_logger(log_file)
|
||||
@ -197,7 +214,8 @@ class IntegrityChecker(object):
|
||||
TodoIssueTracker(),
|
||||
]
|
||||
|
||||
def check_repo_path(self):
|
||||
@staticmethod
|
||||
def check_repo_path():
|
||||
if not all(os.path.isdir(d) for d in ["include", "library", "tests"]):
|
||||
raise Exception("Must be run from Mbed TLS root")
|
||||
|
||||
|
@ -9,10 +9,4 @@
|
||||
# Run 'pylint' on Python files for programming errors and helps enforcing
|
||||
# PEP8 coding standards.
|
||||
|
||||
if `hash pylint > /dev/null 2>&1`; then
|
||||
pylint -j 2 tests/scripts/generate_test_code.py --rcfile .pylint
|
||||
pylint -j 2 tests/scripts/test_generate_test_code.py --rcfile .pylint
|
||||
pylint -j 2 tests/scripts/mbedtls_test.py --rcfile .pylint
|
||||
else
|
||||
echo "$0: WARNING: 'pylint' not found! Skipping checks on Python files."
|
||||
fi
|
||||
pylint3 -j 2 scripts/*.py tests/scripts/*.py
|
||||
|
@ -238,7 +238,7 @@ class FileWrapper(io.FileIO, object):
|
||||
if hasattr(parent, '__next__'):
|
||||
line = parent.__next__() # Python 3
|
||||
else:
|
||||
line = parent.next() # Python 2
|
||||
line = parent.next() # Python 2 # pylint: disable=no-member
|
||||
if line is not None:
|
||||
self._line_no += 1
|
||||
# Convert byte array to string with correct encoding and
|
||||
|
@ -37,7 +37,8 @@ https://github.com/ARMmbed/greentea
|
||||
import re
|
||||
import os
|
||||
import binascii
|
||||
from mbed_host_tests import BaseHostTest, event_callback
|
||||
|
||||
from mbed_host_tests import BaseHostTest, event_callback # pylint: disable=import-error
|
||||
|
||||
|
||||
class TestDataParserError(Exception):
|
||||
|
@ -22,7 +22,7 @@
|
||||
Unit tests for generate_test_code.py
|
||||
"""
|
||||
|
||||
|
||||
# pylint: disable=wrong-import-order
|
||||
try:
|
||||
# Python 2
|
||||
from StringIO import StringIO
|
||||
@ -36,6 +36,7 @@ try:
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from unittest.mock import patch
|
||||
# pylint: enable=wrong-import-order
|
||||
from generate_test_code import gen_dependencies, gen_dependencies_one_line
|
||||
from generate_test_code import gen_function_wrapper, gen_dispatch
|
||||
from generate_test_code import parse_until_pattern, GeneratorInputError
|
||||
@ -336,6 +337,7 @@ class StringIOWrapper(StringIO, object):
|
||||
:param length:
|
||||
:return:
|
||||
"""
|
||||
# pylint: disable=unused-argument
|
||||
line = super(StringIOWrapper, self).readline()
|
||||
if line is not None:
|
||||
self.line_no += 1
|
||||
|
Reference in New Issue
Block a user