Skip to content

Commit b9ffd9e

Browse files
authored
Merge branch 'main' into nix_junit
2 parents 610248d + 80db009 commit b9ffd9e

File tree

436 files changed

+32615
-2025
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

436 files changed

+32615
-2025
lines changed

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
### Resolved issues:
22

3-
resolves #ISSUE-NUMBER1, resolves #ISSUE-NUMBER2, etc.
3+
Resolves #ISSUE-NUMBER1, resolves #ISSUE-NUMBER2, etc.
44

55
### Description of changes:
66

7-
Describe s2n’s current behavior and how your code changes that behavior. If there are no issues this pr is resolving, explain why this change is necessary.
7+
Describe s2n’s current behavior and how your code changes that behavior. If there are no issues this PR is resolving, explain why this change is necessary.
8+
89
### Call-outs:
910

1011
Address any potentially confusing code. Is there code added that needs to be cleaned up later? Is there code that is missing because it’s still in development?
12+
1113
### Testing:
1214

13-
How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?
15+
How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?
1416

15-
Is this a refactor change? If so, how have you proved that the intended behavior hasn't changed?
17+
Is this a refactor change? If so, how have you proved that the intended behavior hasn't changed?
1618

1719
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Diff for: .github/workflows/ci_compliance.yml

+46-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
name: Compliance
3-
43
on:
4+
push:
5+
branches: [main]
56
pull_request:
67
branches: [main]
78
merge_group:
@@ -12,13 +13,18 @@ jobs:
1213
duvet:
1314
runs-on: ubuntu-latest
1415
steps:
15-
- uses: actions/checkout@v3
16-
- uses: actions/checkout@v3
16+
- name: Clone s2n-tls
17+
uses: actions/checkout@v3
18+
19+
- name: Clone s2n-quic
20+
uses: actions/checkout@v3
1721
with:
1822
repository: aws/s2n-quic
1923
path: ./s2n-quic
2024
submodules: true
21-
- uses: ./s2n-quic/.github/actions/duvet
25+
26+
- name: Run duvet action
27+
uses: ./s2n-quic/.github/actions/duvet
2228
with:
2329
s2n-quic-dir: ./s2n-quic
2430
report-script: compliance/generate_report.sh
@@ -27,3 +33,39 @@ jobs:
2733
aws-s3-bucket-name: s2n-tls-ci-artifacts
2834
aws-s3-region: us-west-2
2935
cdn: https://d3fqnyekunr9xg.cloudfront.net
36+
37+
# The `duvet report` command generates some artifacts (specs folder) that
38+
# interfere with detecting uncommitted files. This step cleans up those
39+
# artifacts. Since the cleanup runs prior to the “Extract RFC spec data”
40+
# phase, this is a safe operation.
41+
- name: Cleanup intermediate artifacts
42+
run: rm -r specs
43+
shell: bash
44+
45+
- name: Extract RFC spec data
46+
working-directory: ./compliance
47+
run: ./initialize_duvet.sh
48+
shell: bash
49+
50+
- name: Check if there are uncommitted changes
51+
run: |
52+
# If this fails you need to run `cd compliance && ./compliance/initialize_duvet.sh`
53+
#
54+
# FIXME: https://github.com/aws/s2n-tls/issues/4219
55+
# We generate and commit the spec files to avoid re-downloading them each time in
56+
# the CI (avoid flaky network calls). However, this currently doesn't work in
57+
# s2n-tls since duvet assumes that the specs folder live in the project's base
58+
# folder.
59+
#
60+
# Use 'git status --porcelain' instead of 'git diff --exit-code' since git diff
61+
# only detects diffs but fails to detect new files. Ignore the s2n-quic dir
62+
# `(:!s2n-quic)` since we explicitly clone the repo as part of this job.
63+
git_status=$(git status --porcelain -- ':!s2n-quic')
64+
if [ -n "$git_status" ]; then
65+
echo "Found uncommitted changes:"
66+
echo "$git_status"
67+
exit 1
68+
else
69+
echo "Workspace is clean"
70+
fi
71+
shell: bash

Diff for: .github/workflows/ci_rust.yml

+48-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: Tests
3939
working-directory: ${{env.ROOT_PATH}}
40-
run: cargo test
40+
run: cargo test --all-features
4141

4242
- name: Test external build
4343
# if this test is failing, make sure that api headers are appropriately
@@ -59,6 +59,53 @@ jobs:
5959
./generate.sh
6060
ldd target/debug/integration | grep libs2n.so
6161
62+
generate-openssl-102:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v3
66+
67+
- uses: actions-rs/toolchain@v1
68+
id: toolchain
69+
with:
70+
toolchain: stable
71+
override: true
72+
73+
- uses: camshaft/rust-cache@v1
74+
75+
- name: Cache OpenSSL 1.0.2
76+
id: cache-openssl
77+
uses: actions/cache@v3
78+
with:
79+
path: ~/openssl-102/install
80+
key: ${{ runner.os }}-openssl-102
81+
82+
- if: ${{ steps.cache-openssl.outputs.cache-hit != 'true' }}
83+
name: Install OpenSSL 1.0.2
84+
run: |
85+
mkdir ~/openssl-102
86+
pushd ~/openssl-102
87+
88+
mkdir install
89+
install_dir="$(pwd)"/install
90+
91+
wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
92+
tar -xzvf openssl-1.0.2u.tar.gz
93+
94+
pushd openssl-1.0.2u
95+
./config --prefix="${install_dir}" --openssldir="${install_dir}"/openssl
96+
make
97+
make install
98+
popd
99+
100+
popd
101+
102+
- name: Generate
103+
run: OPENSSL_DIR=~/openssl-102/install ${{env.ROOT_PATH}}/generate.sh
104+
105+
- name: Tests
106+
working-directory: ${{env.ROOT_PATH}}
107+
run: cargo test --all-features
108+
62109
rustfmt:
63110
runs-on: ubuntu-latest
64111
steps:

Diff for: .github/workflows/proof_ci.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
run: |
6363
# Search within 5 most recent releases for latest available package
6464
CBMC_REL="https://api.github.com/repos/diffblue/cbmc/releases?page=1&per_page=5"
65-
CBMC_DEB=$(curl -s $CBMC_REL | jq -r '.[].assets[].browser_download_url' | grep -e 'ubuntu-20.04' | head -n 1)
65+
CBMC_DEB=$(curl -s $CBMC_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.[].assets[].browser_download_url' | grep -e 'ubuntu-20.04' | head -n 1)
6666
CBMC_ARTIFACT_NAME=$(basename $CBMC_DEB)
6767
curl -o $CBMC_ARTIFACT_NAME -L $CBMC_DEB
6868
sudo dpkg -i $CBMC_ARTIFACT_NAME
@@ -80,7 +80,7 @@ jobs:
8080
shell: bash
8181
run: |
8282
CBMC_VIEWER_REL="https://api.github.com/repos/model-checking/cbmc-viewer/releases/latest"
83-
CBMC_VIEWER_VERSION=$(curl -s $CBMC_VIEWER_REL | jq -r .name | sed 's/viewer-//')
83+
CBMC_VIEWER_VERSION=$(curl -s $CBMC_VIEWER_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r .name | sed 's/viewer-//')
8484
pip3 install cbmc-viewer==$CBMC_VIEWER_VERSION
8585
- name: Install CBMC viewer ${{ env.CBMC_VIEWER_VERSION }}
8686
if: ${{ env.CBMC_VIEWER_VERSION != 'latest' }}
@@ -96,7 +96,7 @@ jobs:
9696
run: |
9797
# Search within 5 most recent releases for latest available package
9898
LITANI_REL="https://api.github.com/repos/awslabs/aws-build-accumulator/releases?page=1&per_page=5"
99-
LITANI_DEB=$(curl -s $LITANI_REL | jq -r '.[].assets[0].browser_download_url' | head -n 1)
99+
LITANI_DEB=$(curl -s $LITANI_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.[].assets[0].browser_download_url' | head -n 1)
100100
DBN_PKG_FILENAME=$(basename $LITANI_DEB)
101101
curl -L $LITANI_DEB -o $DBN_PKG_FILENAME
102102
sudo apt-get update
@@ -118,7 +118,7 @@ jobs:
118118
if ${{ env.KISSAT_TAG == 'latest' }}
119119
then
120120
KISSAT_REL="https://api.github.com/repos/arminbiere/kissat/releases/latest"
121-
KISSAT_TAG_NAME=$(curl -s $KISSAT_REL | jq -r '.tag_name')
121+
KISSAT_TAG_NAME=$(curl -s $KISSAT_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.tag_name')
122122
else
123123
KISSAT_TAG_NAME=${{ env.KISSAT_TAG }}
124124
fi
@@ -137,7 +137,7 @@ jobs:
137137
if ${{ env.CADICAL_TAG == 'latest' }}
138138
then
139139
CADICAL_REL="https://api.github.com/repos/arminbiere/cadical/releases/latest"
140-
CADICAL_TAG_NAME=$(curl -s $CADICAL_REL | jq -r '.tag_name')
140+
CADICAL_TAG_NAME=$(curl -s $CADICAL_REL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.tag_name')
141141
else
142142
CADICAL_TAG_NAME=${{ env.CADICAL_TAG }}
143143
fi

Diff for: CMakeLists.txt

+46-13
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@ option(COVERAGE "Enable profiling collection for code coverage calculation" OFF)
3838
option(S2N_INTEG_TESTS "Enable the integrationv2 tests" OFF)
3939
option(S2N_FAST_INTEG_TESTS "Enable the integrationv2 with more parallelism, only has effect if S2N_INTEG_TESTS=ON" OFF)
4040
option(S2N_INSTALL_S2NC_S2ND "Install the binaries s2nc and s2nd" OFF)
41-
option(EXPERIMENTAL_TREAT_WARNINGS_AS_ERRORS "Additional compiler warnings are treated as errors. Warnings may
42-
indicate danger points where you should verify with the S2N-TLS developers that the security of
43-
the library is not compromised. These warnings are currently failing for some builds; once the problems are fixed,
44-
they will be moved to UNSAFE_TREAT_WARNINGS_AS_ERRORS." OFF)
4541
option(TSAN "Enable ThreadSanitizer to test thread safety" OFF)
42+
option(ASAN "Enable AddressSanitizer to test memory safety" OFF)
4643

4744
# Turn BUILD_TESTING=ON by default
4845
include(CTest)
@@ -164,13 +161,9 @@ set(CMAKE_C_FLAGS_DEBUGOPT "")
164161

165162
target_compile_options(${PROJECT_NAME} PRIVATE -pedantic -std=gnu99 -Wall -Wimplicit -Wunused -Wcomment -Wchar-subscripts
166163
-Wuninitialized -Wshadow -Wcast-align -Wwrite-strings -Wno-deprecated-declarations -Wno-unknown-pragmas -Wformat-security
167-
-Wno-missing-braces -Wno-strict-prototypes -Wa,--noexecstack
164+
-Wno-missing-braces -Wsign-compare -Wno-strict-prototypes -Wa,--noexecstack
168165
)
169166

170-
if (EXPERIMENTAL_TREAT_WARNINGS_AS_ERRORS)
171-
target_compile_options(${PROJECT_NAME} PRIVATE -Wsign-compare )
172-
endif()
173-
174167
if (UNSAFE_TREAT_WARNINGS_AS_ERRORS)
175168
target_compile_options(${PROJECT_NAME} PRIVATE -Werror )
176169
endif ()
@@ -222,10 +215,20 @@ if(S2N_UNSAFE_FUZZING_MODE)
222215
endif()
223216

224217
if(TSAN)
225-
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=thread)
218+
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=thread -DS2N_THREAD_SANITIZER=1)
226219
target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=thread)
227220
endif()
228221

222+
if(ASAN)
223+
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=address -DS2N_ADDRESS_SANITIZER=1)
224+
target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=address)
225+
endif()
226+
227+
if(TSAN OR ASAN)
228+
# no-omit-frame-pointer and no-optimize-sibling-calls provide better stack traces
229+
target_compile_options(${PROJECT_NAME} PUBLIC -fno-omit-frame-pointer -fno-optimize-sibling-calls)
230+
endif()
231+
229232
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
230233

231234
if (NOT $ENV{S2N_LIBCRYPTO} MATCHES "awslc")
@@ -313,6 +316,10 @@ endfunction()
313316

314317
# Tries to compile a feature probe and initializes the corresponding flags
315318
function(feature_probe PROBE_NAME)
319+
# Load the global probe flags
320+
file(READ "${CMAKE_CURRENT_LIST_DIR}/tests/features/GLOBAL.flags" GLOBAL_FILE)
321+
string(REPLACE "\n" "" GLOBAL_FLAGS "${GLOBAL_FILE}")
322+
316323
# Load the probe's flags
317324
file(READ "${CMAKE_CURRENT_LIST_DIR}/tests/features/${PROBE_NAME}.flags" PROBE_FILE)
318325
string(REPLACE "\n" "" PROBE_FLAGS "${PROBE_FILE}")
@@ -324,9 +331,12 @@ function(feature_probe PROBE_NAME)
324331
SOURCES "${CMAKE_CURRENT_LIST_DIR}/tests/features/${PROBE_NAME}.c"
325332
LINK_LIBRARIES ${LINK_LIB} ${OS_LIBS}
326333
CMAKE_FLAGS ${ADDITIONAL_FLAGS}
327-
COMPILE_DEFINITIONS -c ${PROBE_FLAGS}
334+
COMPILE_DEFINITIONS -c ${GLOBAL_FLAGS} ${PROBE_FLAGS}
328335
${ARGN}
336+
OUTPUT_VARIABLE TRY_COMPILE_OUTPUT
329337
)
338+
# Uncomment the line below to get the output of the try_compile command
339+
#message(STATUS "Output of try_compile: ${TRY_COMPILE_OUTPUT}")
330340

331341
# Set the result of the probe
332342
feature_probe_result(${PROBE_NAME} ${IS_AVAILABLE})
@@ -504,13 +514,30 @@ if (BUILD_TESTING)
504514
add_library(allocator_overrides SHARED ${TEST_LD_PRELOAD})
505515

506516
set(UNIT_TEST_ENVS S2N_DONT_MLOCK=1)
517+
if (TSAN OR ASAN)
518+
set(UNIT_TEST_ENVS ${UNIT_TEST_ENVS} S2N_ADDRESS_SANITIZER=1)
519+
endif()
507520
if(TSAN)
508521
set(TSAN_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/tests/.tsan_suppressions)
509522
if(NOT EXISTS ${TSAN_SUPPRESSIONS_FILE})
510523
message(FATAL_ERROR "TSAN suppression file ${TSAN_SUPPRESSIONS_FILE} missing")
511524
endif()
512-
set(UNIT_TEST_ENVS ${UNIT_TEST_ENVS} S2N_ADDRESS_SANITIZER=1)
513-
set(UNIT_TEST_ENVS ${UNIT_TEST_ENVS} TSAN_OPTIONS=suppressions=${TSAN_SUPPRESSIONS_FILE})
525+
set(TSAN_OPTIONS suppressions=${TSAN_SUPPRESSIONS_FILE})
526+
if(DEFINED ENV{TSAN_OPTIONS})
527+
set(TSAN_OPTIONS "${TSAN_OPTIONS} $ENV{TSAN_OPTIONS}")
528+
endif()
529+
set(UNIT_TEST_ENVS ${UNIT_TEST_ENVS} TSAN_OPTIONS=${TSAN_OPTIONS})
530+
endif()
531+
if(ASAN)
532+
# "detect_odr_violation" detects violations of the "one definition rule",
533+
# ensuring that symbols are only defined once.
534+
# But some of our unit tests intentionally include *.c files for testing,
535+
# resulting in duplicate global values.
536+
set(ASAN_OPTIONS detect_odr_violation=0)
537+
if(DEFINED ENV{ASAN_OPTIONS})
538+
set(ASAN_OPTIONS "${ASAN_OPTIONS} $ENV{ASAN_OPTIONS}")
539+
endif()
540+
set(UNIT_TEST_ENVS ${UNIT_TEST_ENVS} ASAN_OPTIONS=${ASAN_OPTIONS})
514541
endif()
515542
message(STATUS "Running tests with environment: ${UNIT_TEST_ENVS}")
516543

@@ -589,6 +616,12 @@ if (BUILD_TESTING)
589616
# For Nix and environments where LD_LIBRARY_PATH is already correct.
590617
# We're also dropping tox and calling pytest directly, because
591618
# Nix is already handling all of the python setup.
619+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND ${test_target} STREQUAL "integrationv2_sslyze" )
620+
# sslyze/nassl is not available on aarch64.
621+
message(WARNING "Skipping ${test_target} due to missing tools on ${CMAKE_SYSTEM_PROCESSOR}")
622+
continue()
623+
endif()
624+
message(STATUS "Adding integ test ${test_target}")
592625
add_test(NAME ${test_target}
593626
COMMAND
594627
pytest

Diff for: README.md

+17-42
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,30 @@ s2n-tls is a C99 implementation of the TLS/SSL protocols that is designed to be
1414
[![Join the chat at https://gitter.im/awslabs/s2n](https://badges.gitter.im/awslabs/s2n.svg)](https://gitter.im/awslabs/s2n?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1515

1616
## Quickstart for Ubuntu
17-
1. Fork s2n-tls on GitHub
18-
2. Run the following commands on Ubuntu.
19-
```
20-
git clone https://github.com/${YOUR_GITHUB_ACCOUNT_NAME}/s2n-tls.git
21-
cd s2n-tls
22-
23-
# Pick an "env" line from the codebuild/codebuild.config file and run it, in this case choose the openssl-1.1.1 with GCC 9 build
24-
S2N_LIBCRYPTO=openssl-1.1.1 BUILD_S2N=true TESTS=integrationv2 GCC_VERSION=9
25-
26-
sudo codebuild/bin/s2n_install_test_dependencies.sh
27-
codebuild/bin/s2n_codebuild.sh
28-
```
29-
30-
## Quickstart for OSX (or other platforms)
31-
32-
If you are building on OSX, or simply don't want to execute the entire build script above, you can use build tools like Ninja.
3317

34-
### OSX
35-
36-
An example of building on OSX:
37-
38-
```sh
39-
# Install required dependencies using homebrew
40-
brew install ninja cmake coreutils [email protected]
41-
42-
# Clone the s2n-tls source repository into the `s2n-tls` directory
43-
git clone https://github.com/${YOUR_GITHUB_ACCOUNT_NAME}/s2n-tls.git
18+
```bash
19+
# clone s2n-tls
20+
git clone https://github.com/aws/s2n-tls.git
4421
cd s2n-tls
4522

46-
# Create a build directory, and build s2n-tls with debug symbols and a specific OpenSSL version.
47-
cmake . -Bbuild -GNinja \
48-
-DCMAKE_BUILD_TYPE=Debug \
49-
-DCMAKE_PREFIX_PATH=$(dirname $(dirname $(brew list [email protected]|grep libcrypto.dylib)))
50-
cmake --build ./build -j $(nproc)
51-
CTEST_PARALLEL_LEVEL=$(nproc) ninja -C build test
52-
```
23+
# install build dependencies
24+
sudo apt update
25+
sudo apt install cmake
5326

54-
### Amazonlinux2
27+
# install a libcrypto
28+
sudo apt install libssl-dev
5529

56-
Install dependencies with `./codebuild/bin/install_al2_dependencies.sh` after cloning.
57-
58-
```sh
59-
git clone https://github.com/${YOUR_GITHUB_ACCOUNT_NAME}/s2n-tls.git
60-
cd s2n-tls
61-
cmake . -Bbuild -DCMAKE_EXE_LINKER_FLAGS="-lcrypto -lz" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
62-
cmake --build ./build -j $(nproc)
63-
CTEST_PARALLEL_LEVEL=$(nproc) make -C build test
30+
# build s2n-tls
31+
cmake . -Bbuild \
32+
-DCMAKE_BUILD_TYPE=Release \
33+
-DCMAKE_INSTALL_PREFIX=./s2n-tls-install
34+
cmake --build build -j $(nproc)
35+
CTEST_PARALLEL_LEVEL=$(nproc) ctest --test-dir build
36+
cmake --install build
6437
```
6538

39+
See the [s2n-tls build documentation](docs/BUILD.md) for further guidance on building s2n-tls for your platform.
40+
6641
## Have a Question?
6742
If you have any questions about Submitting PR's, Opening Issues, s2n-tls API usage, or something similar, we have a public chatroom available here to answer your questions: https://gitter.im/awslabs/s2n
6843

0 commit comments

Comments
 (0)