Commit graph

12 commits

Author SHA1 Message Date
Gilles Peskine
d11bb47fe0 Reject invalid UTF-8 and weird characters in text files
Reject "weird" characters in text files, especially control characters that
might be escape sequences or that might cause other text to appear garbled
(as in https://trojansource.codes/).

Also reject byte sequences that aren't valid UTF-8.

Accept only ASCII (except most control characters), letters, some non-ASCII
punctuation and some mathematical and technical symbols. This covers
everything that's currently present in Mbed TLS ( §áèéëñóöüłŽ–—’“”…≥).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-05 20:31:14 +01:00
Gilles Peskine
b389743ace Pass line number to issue_with_line
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-05 20:28:30 +01:00
Gilles Peskine
0ed9e78bf7 Treat more *.bin files as binary
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-05 20:27:35 +01:00
Dave Rodgman
f58172fe43 Merge remote-tracking branch 'origin/development' into pr3431 2022-11-10 09:54:49 +00:00
Nick Child
fc234b7b52 test/pkcs7: Add Windows CRLF EOF to data files
Windows tests are failing pkcs7 verification due to differnt line
endings. Therefore, add make instuctions for building the data
files with Windows EOF instead. As a result, regenerate other data
files so that verification works.

Add these CRLF EOF files to the exception in check_files to ignore
the line endings.

Signed-off-by: Nick Child <nick.child@ibm.com>
2022-11-03 09:24:20 -05:00
Gilles Peskine
d9071e7d96 Unify check_repo_path
We had 4 identical copies of the check_repo_path function. Replace them by a
single copy in the build_tree module where it naturally belongs.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-18 21:17:09 +02:00
Shaun Case
8b0ecbccf4 Redo of PR#5345. Fixed spelling and typographical errors found by CodeSpell.
Signed-off-by: Shaun Case <warmsocks@gmail.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-05-11 21:25:51 +01:00
Gilles Peskine
ac9e7c0b6e check_files.py: pass mypy
Add enough type annotations to pass mypy 0.782 with Python 3.5. The
source code will still run normally under older Python versions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-12-10 21:30:01 +01:00
Gilles Peskine
4aebb8d936 Test shebang lines
Executable scripts must have shebang (#!) line to be effectively
executable on most Unix-like systems. Enforce this, and conversely
enforce that files with a shebang line are executable.

Check that the specified interperter is consistent with the file
extension.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-12-10 21:29:55 +01:00
Gilles Peskine
15898eec23 Allow Python files not to be executable
.py files may be modules which are not standalone program, so allow
them not to be executable.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-12-10 21:29:49 +01:00
Bence Szépkúti
1e14827beb Update copyright notices to use Linux Foundation guidance
As a result, the copyright of contributors other than Arm is now
acknowledged, and the years of publishing are no longer tracked in the
source files.

Also remove the now-redundant lines declaring that the files are part of
MbedTLS.

This commit was generated using the following script:

# ========================
#!/bin/sh

# Find files
find '(' -path './.git' -o -path './3rdparty' ')' -prune -o -type f -print | xargs sed -bi '

# Replace copyright attribution line
s/Copyright.*Arm.*/Copyright The Mbed TLS Contributors/I

# Remove redundant declaration and the preceding line
$!N
/This file is part of Mbed TLS/Id
P
D
'
# ========================

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2020-08-19 10:35:41 +02:00
Gilles Peskine
fb4f933f8e Rename Python scripts to use '_' and not '-'
You can't import a Python script whose name includes '-'.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-06-25 14:22:06 +02:00
Renamed from tests/scripts/check-files.py (Browse further)