Skip to content

Commit 0c95ad6

Browse files
authored
Merge branch 'main' into dependabot/github_actions/aws-actions/stale-issue-cleanup-6
2 parents 153b4fd + ac26551 commit 0c95ad6

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

.github/workflows/create-channel.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
105105

106106
- name: Build ${{ matrix.variant }} image
107-
uses: whoan/docker-build-with-cache-action@v5
107+
uses: whoan/docker-build-with-cache-action@v8
108108
with:
109109
registry: ${{ secrets.AWS_ECR_REPO }}
110110
username: ${{ secrets.AWS_ACCESS_KEY_ID }}

.github/workflows/create-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
9595

9696
- name: Build aws-crt-${{ matrix.variant }} image
97-
uses: whoan/docker-build-with-cache-action@v5
97+
uses: whoan/docker-build-with-cache-action@v8
9898
with:
9999
registry: ${{ secrets.AWS_ECR_REPO }}
100100
username: ${{ secrets.AWS_ACCESS_KEY_ID }}

builder/actions/setup_cross_ci_crt_environment.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,11 @@ def _common_setup(self, env):
423423
pass
424424

425425
def run(self, env):
426+
# A special environment variable indicating that we want to dump test environment variables to a specified file.
427+
env_dump_file = env.shell.getenv("AWS_SETUP_CRT_TEST_ENVIRONMENT_DUMP_FILE")
428+
426429
# Bail if not running tests
427-
if not env.project.needs_tests(env):
430+
if not env.project.needs_tests(env) and not env_dump_file:
428431
print('Tests not needed for project. Skipping setting test environment variables')
429432
return
430433

@@ -475,3 +478,10 @@ def run(self, env):
475478
print(f"Detected whether on Codebuild: {self.is_codebuild}")
476479

477480
self._common_setup(env)
481+
482+
# Create a temporary file with all environment variables.
483+
# Useful for running tests locally.
484+
if env_dump_file:
485+
with open(file=env_dump_file, mode='w+') as file:
486+
for env_name, env_value in env.project.config['test_env'].items():
487+
file.write(f"export {env_name}={env_value}\n")

builder/core/fetch.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,25 @@ def fetch_and_extract(url, archive_path, extract_path):
236236
print('Extracting {} to {}'.format(archive_path, extract_path))
237237
if tarfile.is_tarfile(archive_path):
238238
with tarfile.open(archive_path) as tar:
239-
tar.extractall(extract_path)
239+
def is_within_directory(directory, target):
240+
241+
abs_directory = os.path.abspath(directory)
242+
abs_target = os.path.abspath(target)
243+
244+
prefix = os.path.commonprefix([abs_directory, abs_target])
245+
246+
return prefix == abs_directory
247+
248+
def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
249+
250+
for member in tar.getmembers():
251+
member_path = os.path.join(path, member.name)
252+
if not is_within_directory(path, member_path):
253+
raise Exception("Attempted Path Traversal in Tar File")
254+
255+
tar.extractall(path, members, numeric_owner=numeric_owner)
256+
257+
safe_extract(tar, extract_path)
240258

241259
elif zipfile.is_zipfile(archive_path):
242260
with zipfile.ZipFile(archive_path) as zip:

0 commit comments

Comments
 (0)