-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/github_actions/dot-github/workflo…
…ws/aws-actions/configure-aws-credentials-4.0.2
- Loading branch information
Showing
19 changed files
with
165 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: dependencies | ||
|
||
on: | ||
# Because of permissions issues with forked PRs, | ||
# Only run on a schedule or pushes to main. | ||
push: | ||
branches: | ||
- main | ||
# Only run if these files were touched. | ||
paths: | ||
- "**/Cargo.toml" | ||
- "**/Cargo.lock" | ||
- ".github/workflows/dependencies.yml" | ||
|
||
schedule: | ||
# Run every day at 1800 UTC. | ||
- cron: "0 18 * * *" | ||
|
||
jobs: | ||
audit: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write # Open/update issues. | ||
checks: write # Create/update a check run. | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: rustsec/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# This script parses the LastDynamicAnalysis file generated by Valgrind running through CTest memcheck. | ||
# It identifies any leaking file descriptors and triggers an error when detected. | ||
# This enhances the capabilities of existing Valgrind checks. | ||
# Output snippet for open file descriptors: | ||
# ==6652== FILE DESCRIPTORS: 6 open (3 std) at exit. | ||
# ==6652== Open AF_INET socket 6: 127.0.0.1:36915 <-> unbound | ||
# ==6652== at 0x498B2EB: socket (syscall-template.S:120) | ||
# ==6652== by 0x16CD16: s2n_new_inet_socket_pair (s2n_self_talk_ktls_test.c:69) | ||
# ==6652== by 0x15DBB2: main (s2n_self_talk_ktls_test.c:168) | ||
# ==6652== | ||
import os | ||
import sys | ||
|
||
EXIT_SUCCESS = 0 | ||
# Exit with error code 1 if leaking fds are detected. | ||
ERROR_EXIT_CODE = 1 | ||
# This test is designed to be informational only, so we only print fifteen lines of error messages when a leak is detected. | ||
NUM_OF_LINES_TO_PRINT = 15 | ||
|
||
|
||
def find_log_file(path): | ||
for f in os.listdir(path): | ||
if "LastDynamicAnalysis" in f: | ||
return os.path.join(path, f) | ||
|
||
raise FileNotFoundError("LastDynamicAnalysis log file is not found!") | ||
|
||
|
||
def detect_leak(file): | ||
fd_leak_detected = False | ||
lines = file.readlines() | ||
for i in range(len(lines)): | ||
if "FILE DESCRIPTORS:" in lines[i]: | ||
# Example line: `==6096== FILE DESCRIPTORS: 4 open (3 std) at exit.` | ||
line_elements = lines[i].split() | ||
open_fd_count = line_elements[line_elements.index("DESCRIPTORS:") + 1] | ||
std_fd_count = line_elements[line_elements.index("std)") - 1][1:] | ||
# CTest memcheck writes to a LastDynamicAnslysis log file. | ||
# We allow that fd to remain opened. | ||
if int(open_fd_count) > int(std_fd_count) + 1: | ||
for j in range(NUM_OF_LINES_TO_PRINT): | ||
print(lines[i + j], end="") | ||
print() | ||
fd_leak_detected = True | ||
return fd_leak_detected | ||
|
||
|
||
def main(): | ||
# Print banner of the test | ||
print("############################################################################") | ||
print("################# Test for Leaking File Descriptors ########################") | ||
print("############################################################################") | ||
|
||
with open(find_log_file(sys.argv[1]), 'r') as file: | ||
if detect_leak(file): | ||
sys.exit(ERROR_EXIT_CODE) | ||
|
||
return EXIT_SUCCESS | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
# Initialization and Teardown | ||
The s2n-tls library must be initialized with `s2n_init()` before calling most library functions. `s2n_init()` MUST NOT be called more than once, even when an application uses multiple threads or processes. s2n attempts to clean up its thread-local memory at thread-exit and all other memory at process-exit. However, this may not work if you are using a thread library other than pthreads or other threads using s2n outlive the thread that called `s2n_init()`. In that case you should call `s2n_cleanup_thread()` from every thread or process created after `s2n_init()`. | ||
|
||
> Note: `s2n_cleanup_thread()` is currently considered unstable, meaning the API is subject to change in a future release. To access this API, include `api/unstable/cleanup.h`. | ||
## Initialization | ||
The s2n-tls library must be initialized with `s2n_init()` before calling most library functions. `s2n_init()` will error if it is called more than once, even when an application uses multiple threads. | ||
|
||
Initialization can be modified by calling `s2n_crypto_disable_init()` or `s2n_disable_atexit()` before `s2n_init()`. | ||
|
||
An application can override s2n-tls’s internal memory management by calling `s2n_mem_set_callbacks` before calling s2n_init. | ||
An application can override s2n-tls’s internal memory management by calling `s2n_mem_set_callbacks()` before calling `s2n_init()`. | ||
|
||
If you are trying to use FIPS mode, you must enable FIPS in your libcrypto library (probably by calling `FIPS_mode_set(1)`) before calling `s2n_init()`. | ||
|
||
## Teardown | ||
### Thread-local Memory | ||
We recommend calling `s2n_cleanup()` from every thread created after `s2n_init()` to ensure there are no memory leaks. s2n-tls has thread-local memory that it attempts to clean up automatically at thread-exit. However, this is done using pthread destructors and may not work if you are using a threads library other than pthreads. | ||
|
||
### Library Cleanup | ||
A full cleanup and de-initialization of the library can be done by calling `s2n_cleanup_final()`. s2n-tls allocates some memory at initialization that is intended to live for the duration of the process, but can be cleaned up earlier with `s2n_cleanup_final()`. Not calling this method may cause tools like ASAN or valgrind to detect memory leaks, as the memory will still be allocated when the process exits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.