[stable-2.19] Fix direct S3 link in integration tests (#86464) (#86466)

Also add a sanity test to prevent similar issues in the future.

(cherry picked from commit b1bc1e2513)
This commit is contained in:
Matt Clay 2026-01-26 15:47:52 -08:00 committed by GitHub
parent 500a3326bf
commit 35a8b6aff6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 1 deletions

View file

@ -82,7 +82,7 @@
- name: install OpenAuthenticode
shell: |
if (-not (Get-Module -Name OpenAuthenticode -ListAvailable | Where-Object Version -ge '0.5.0')) {
$url = 'https://ansible-ci-files.s3.us-east-1.amazonaws.com/test/integration/targets/win_app_control/openauthenticode.0.6.1.nupkg'
$url = 'https://ci-files.testing.ansible.com/test/integration/targets/win_app_control/openauthenticode.0.6.1.nupkg'
Invoke-WebRequest -Uri $url -OutFile '{{ local_tmp_dir }}/openauthenticode.0.6.1.nupkg'
Register-PSResourceRepository -Name AnsibleTemp -Trusted -Uri '{{ local_tmp_dir }}'

View file

@ -0,0 +1,4 @@
{
"text": true,
"output": "path-line-column-message"
}

View file

@ -0,0 +1,27 @@
"""
Disallow direct linking to S3 buckets.
S3 buckets should be accessed through a CloudFront distribution.
"""
from __future__ import annotations
import re
import sys
def main():
"""Main entry point."""
for path in sys.argv[1:] or sys.stdin.read().splitlines():
with open(path, 'rb') as path_fd:
for line, b_text in enumerate(path_fd.readlines()):
try:
text = b_text.decode()
except UnicodeDecodeError:
continue
if match := re.search(r'(http.*?s3\..*?amazonaws\.com)', text):
print(f'{path}:{line + 1}:{match.start(1) + 1}: use a CloudFront distribution instead of an S3 bucket: {match.group(1)}')
if __name__ == '__main__':
main()