forked from aws/s2n-tls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Disable broken rust dry-runs (aws#4384)
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 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,45 @@ | ||
import os | ||
import re | ||
|
||
def find_s2n_config_new_calls(directory): | ||
# Define the regex pattern for s2n_config_new() function call | ||
config_new = re.compile(r'\bstruct s2n_config *(.*) = s2n_config_new\s*\(') | ||
|
||
NULL_CHECKS = [ | ||
"RESULT_ENSURE_REF(<>)", | ||
"POSIX_ENSURE_REF(<>)", | ||
"EXPECT_NOT_NULL(<>)", | ||
] | ||
# List to store file paths with matching lines | ||
matching_files = [] | ||
|
||
# Iterate through each file in the directory and its subdirectories | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
if file.endswith(".c"): | ||
file_path = os.path.join(root, file) | ||
|
||
# Open the file and read its content | ||
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: | ||
lines = f.readlines() | ||
|
||
results = [] | ||
for line_number, line in enumerate(lines, start=1): | ||
match = config_new.search(line) | ||
if match == None: | ||
continue | ||
variable = match.group(1) | ||
print(variable) | ||
print(line.strip()) | ||
matching_files.append((file_path, line_number, line.strip())) | ||
return matching_files | ||
|
||
# Replace 'your_codebase_directory' with the actual path to your C codebase | ||
codebase_directory = '.' | ||
|
||
# Find s2n_config_new() calls in the codebase | ||
result = find_s2n_config_new_calls(codebase_directory) | ||
|
||
# Display the results | ||
# for file_path, line_number, line_content in result: | ||
# print(f"File: {file_path}:{line_number}: {line_content}") |