Commit Graph

31991 Commits

Author SHA1 Message Date
Gilles Peskine 6759e8012d Make open calls more uniform
Text mode ('t') is the default for the open builtin, but not for gzip.open
and its imitators. Always specify it explicitly to avoid making maintiners
wonder if there's an intended difference in behavior.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine d63709d3db collect_test_cases.py is now a separate module
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 9c9d9fa5b0 Default to requiring full test coverage
Command-line options allow choosing whether a never-executed test results in
a warning or an error. Also, a consuming script can make the default
permissive by setting FULL_COVERAGE_BY_DEFAULT to False.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine b111d9fe54 Support compressed outcome files transparently
Transparently read outcome files compressed with xz (which we currently use
on the CI) or with gzip.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 67e415fc6a Also write to a log file by default
Write the log of outcome analysis to a log file by default. This is a cheap
way of getting the outcome analysis log in an easy-to-access form on the CI:
with our current CI scripts, they are now automatically available as an
artifact called `analyze_outcomes.log`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 48c005f569 Adjust import path after script moves
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 4103f92134 Merge branch 'tmp-branch-move-files-to-framework' into move-files-into-framework 2024-10-09 13:49:41 +02:00
Gilles Peskine ce00cfe798 Move some files to framework repository
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:49:38 +02:00
Gilles Peskine 2c17ec74be Default to allowing partial test coverage
Currently, many test cases are not executed. A follow-up pull request will
take care of that. In the meantime, continue allowing partial test coverage.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-08 19:54:43 +02:00
Gilles Peskine fecb9b916d Downgrade mypy to a version that works with our code base
mypy >=0.960 rejects macro_collector.py.
https://github.com/Mbed-TLS/mbedtls-framework/issues/50

We currently need mypy >=0.940, <0.960. Pick 0.942, which works, and is the
system version on Ubuntu 22.04.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-08 19:54:43 +02:00
Gilles Peskine 199c9195f5 Upgrade mypy to the last version supporting Python 3.6
Upgrade mypy to 0.971, which is the last version that supports Python 3.6
(the oldest Python version that we currently run on the CI).

This fixes the error
```
framework/scripts/mbedtls_framework/outcome_analysis.py:119: error: Incompatible return value type (got "IO[Any]", expected "TextIO")
framework/scripts/mbedtls_framework/outcome_analysis.py:121: error: Incompatible return value type (got "IO[Any]", expected "TextIO")
```
As far as I can tell the fix is https://github.com/python/mypy/pull/9275
which was released in mypy 0.940.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-08 19:54:43 +02:00
Gilles Peskine 3146772575 Adjust paths for impending moves to the framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-08 19:37:23 +02:00
Gilles Peskine 082eadef4e Separate code and data of outcome analysis
Place the code of outcome analysis (auxiliary functions, tasks, command line
entry point) into a separate module, which will be moved to the
version-independent framework repository so that it can be shared between
maintained branches. Keep the branch-specific list of driver components and
ignore lists in the per-repository script.

We keep the executable script at `tests/scripts/analyze_outcomes.py`. It's
simpler that way, because that path is hard-coded in CI scripts.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:42:37 +02:00
Gilles Peskine e41cde57c3 Pass KNOWN_TASKS as an argument to main
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:36:09 +02:00
Gilles Peskine 005dca6ad8 Typecheck main
Always have tasks_list be a list, not potentially some fancier iterable.

Bypass mypy's somewhat legitimate complaint about REFERENCE and DRIVER in
task_class: they could potentially be instance attributes, but we rely on
them being class attributes. Python does normally guarantee their existence
as class attributes (unless a derived class explicitly deletes them), but
they could be overridden by an instance attribute; that's just something
we don't do, so the class attribute's value is legitimate. We can't
expect mypy to know that, so work around its complaint.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:31:38 +02:00
Gilles Peskine ad02d44e01 Don't reuse a variable name inside a function
Use different names for task name, a task class and a task instance. The
interpreter doesn't care, but it's less confusing for both humans and type
checkers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:28:28 +02:00
Gilles Peskine 9d78e87b49 Missing NotImplementedError in abstract method
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:18:33 +02:00
Gilles Peskine 49c77dd0e4 Remove sample ignore list elements for coverage
The ignore list for coverage only has two test cases out of ~10000 that are
currently reported as not executed. This is a drop in the sea and not
useful. Remove them so that the class can be used generically. A follow-up
will construct a comprehensive ignore list.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:40:55 +02:00
Gilles Peskine 9f930e0f9e Create a module to split branch-independent code out of analyze_outcomes.py
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:38:32 +02:00
Gilles Peskine c8c83d0303 Split test case collection from checks
Move the test case collection code out of check_test_cases.py and into its
own module. This allows outcome analysis to depend only on the new module
and not on check_test_cases.py.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:35:52 +02:00
Gilles Peskine 1e5dbd3c7c Create a module to split test case collection from checks
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:23:53 +02:00
Gilles Peskine 38d4c91b06 Merge pull request #9594 from gilles-peskine-arm/analyze_outcomes-classes-development
analyze_outcomes.py refactoring: change stringly typed data to classes
2024-10-03 10:38:04 +00:00
Manuel Pégourié-Gonnard cb42f29c4e Merge pull request #9662 from gilles-peskine-arm/dtls_server-allow_unexpected_message_on_second_handshake-dev
dtls_server: allow unexpected message on second handshake
2024-10-02 10:39:53 +00:00
Gilles Peskine 13b4954597 Remove "error" allowance in dtls_server
Now that dtls_server doesn't print "error" when it receives stray messages
while it's waiting for a second handshake, have the tests fail if "error" is
printed for some other reason.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-02 11:09:20 +02:00
Gilles Peskine 713127de4c dtls_server: allow unexpected messages during handshake
If MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE happens during the handshake, don't
show it as an "error". It might be an error, but it might also be a fact of
life if it happens during the second or more handshake: it can be a
duplicated packet or a close_notify alert from the previous connection,
which is hard to avoid and harmless.

Fixes #9652.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-02 11:09:20 +02:00
Ronald Cron 96c6f5eb36 Merge pull request #9492 from eleuzi01/remove-legacy-symbol-definitions
Remove definitions of legacy symbols
2024-10-01 10:33:06 +00:00
Elena Uziunaite 780e8562ef Update submodule
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-30 14:58:07 +01:00
Ronald Cron 33ac133217 Merge pull request #34 from eleuzi01/replace-ecc-keys
Replace MBEDTLS_PK_HAVE_ECC_KEYS with PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY

Validated for dev by the CI of https://github.com/Mbed-TLS/mbedtls/pull/9492, for 3.6 by the CI of https://github.com/Mbed-TLS/mbedtls/pull/9640.
2024-09-30 15:13:46 +02:00
Gilles Peskine 46771295f2 Merge pull request #9558 from gilles-peskine-arm/run-test-suites-on-subproject
Run test suites on subproject
2024-09-28 08:31:30 +00:00
Gilles Peskine 0930b331c0 Don't use the "allow list" terminology any longer
What was formerly called an allow list is now an ignore table.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-27 18:28:29 +02:00
David Horstmann 1a09caa8a8 Merge pull request #9638 from gilles-peskine-arm/ssl-opt-sample-programs-dev
Test sample programs in ssl-opt.sh
2024-09-26 14:33:11 +00:00
Elena Uziunaite bf90fa97c9 Update submodule to the head of framework PR
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:22:39 +01:00
Elena Uziunaite f7b24653d7 Remove extra spaces
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Elena Uziunaite 21a6a20c84 Replace MBEDTLS_MD_CAN_SHA256 with PSA_WANT_ALG_SHA_256
And add temporary solution so it works with 3.6 and 4.0

Temporary solution to be resolved in #51.

Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Elena Uziunaite 010c1f1ae0 Adapt changes to work with both 3.6 and 4.0
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Elena Uziunaite 4f80439a5f Replace MBEDTLS_PK_HAVE_ECC_KEYS with PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Elena Uziunaite 9b0bdd0590 Remove MBEDTLS_ECP_HAVE_xxx and MBEDTLS_MD_CAN_xxx
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
Elena Uziunaite 7f85f1f958 Cosmetic changes
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
Elena Uziunaite feb105c042 Address review comment
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
Elena Uziunaite 05fe6e472e Remove MBEDTLS_MD_CAN_SHA512 from header files
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
Elena Uziunaite 3b84b2e28c Remove legacy symbol definitions pt 2
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
Elena Uziunaite c0d6943b7f Replace legacy symbols in config files
Replace symbols that were left over in config_adjust_*.h and
check_config.h

Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
Elena Uziunaite 404311a702 Remove MBEDTLS_ECP_HAVE_SECP256R1 leftovers
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
Elena Uziunaite e4669a5753 Remove legacy symbol definitions pt 1
Remove straightforward definitions that only appear in
config_adjust_legacy_crypto.h

Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
David Horstmann b268d270ed Merge pull request #9413 from sezrab/split_numeric_string_conversions_oid-development
Split numeric string conversions out of the OID module
2024-09-26 12:50:37 +00:00
Harry Ramsey 3b71262750 Remove MBEDTLS_OID_C guard from static functions
This commit removes the MBEDTLS_OID_C guard from the static functions in
the library/x509_create.c as this function is no longer included in the
oid.c file.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-09-26 11:38:25 +01:00
Manuel Pégourié-Gonnard 560265154c Merge pull request #9604 from gilles-peskine-arm/config-full-booleans-only
config.py: don't rely on section names
2024-09-26 10:03:19 +00:00
Gilles Peskine f88f6d6b83 Stop testing without PSA
Stop testing configurations without PSA (MBEDTLS_PSA_CRYPTO_C or at least
MBEDTLS_PSA_CRYPTO_CLIENT). No future release from this branch will support
such configurations, and we can no longer build the SSL sample programs
without psa_crypto_init.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-26 10:21:39 +02:00
Gilles Peskine 3c16e998e5 Update framework to the main branch
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-26 10:19:04 +02:00
Manuel Pégourié-Gonnard 4e9e8391cd Merge pull request #49 from gilles-peskine-arm/config-full-booleans-only-framework
config.py: don't rely on section names
2024-09-26 09:22:13 +02:00