|
28 | 28 | CONFIG_DIR = REPO_ROOT / ".github" / "config" / "image" |
29 | 29 | ALLOWLIST_DIR = REPO_ROOT / "test" / "security" / "data" / "ecr_scan_allowlist" |
30 | 30 | ECR_ACCOUNT = os.environ.get("ECR_ACCOUNT_ID", "") |
| 31 | +# SageMaker built-in algorithm images (xgboost) live in a separate ECR account |
| 32 | +# from the standard DLC framework account. Empty string falls back to ECR_ACCOUNT. |
| 33 | +ECR_ACCOUNT_SAGEMAKER = os.environ.get("ECR_ACCOUNT_ID_SAGEMAKER", "") or ECR_ACCOUNT |
31 | 34 | ECR_REGION = os.environ.get("AWS_REGION", "us-west-2") |
32 | 35 | S3_BUCKET = os.environ.get("SCANNER_ALLOWLIST_S3_BUCKET", "") |
33 | 36 |
|
| 37 | +# Frameworks whose ECR repositories live in the SageMaker built-in algorithm account. |
| 38 | +SAGEMAKER_BUILTIN_FRAMEWORKS = {"xgboost"} |
| 39 | + |
| 40 | + |
| 41 | +def ecr_account_for_framework(framework): |
| 42 | + """Return the ECR account ID that hosts images for the given framework.""" |
| 43 | + if framework in SAGEMAKER_BUILTIN_FRAMEWORKS: |
| 44 | + return ECR_ACCOUNT_SAGEMAKER |
| 45 | + return ECR_ACCOUNT |
| 46 | + |
34 | 47 |
|
35 | 48 | def load_image_configs(): |
36 | 49 | """Read all .github/config/image/**/*.yml and return list of (framework, framework_version, repo, tag) tuples.""" |
@@ -60,11 +73,11 @@ def load_image_configs(): |
60 | 73 | return configs |
61 | 74 |
|
62 | 75 |
|
63 | | -def get_image_sha(ecr_client, repo, tag): |
| 76 | +def get_image_sha(ecr_client, ecr_account, repo, tag): |
64 | 77 | """Look up image digest from ECR. Returns sha string or None.""" |
65 | 78 | try: |
66 | 79 | resp = ecr_client.describe_images( |
67 | | - registryId=ECR_ACCOUNT, |
| 80 | + registryId=ecr_account, |
68 | 81 | repositoryName=repo, |
69 | 82 | imageIds=[{"imageTag": tag}], |
70 | 83 | ) |
@@ -198,9 +211,12 @@ def main(): |
198 | 211 | continue |
199 | 212 | seen.add(image_key) |
200 | 213 |
|
201 | | - LOG.info(f"{image_key} (framework={framework}, config={source_file})") |
| 214 | + ecr_account = ecr_account_for_framework(framework) |
| 215 | + LOG.info( |
| 216 | + f"{image_key} (framework={framework}, ecr_account={ecr_account}, config={source_file})" |
| 217 | + ) |
202 | 218 |
|
203 | | - sha = get_image_sha(ecr_client, repo, tag) |
| 219 | + sha = get_image_sha(ecr_client, ecr_account, repo, tag) |
204 | 220 | if not sha: |
205 | 221 | LOG.warning(" skip: image not found in ECR") |
206 | 222 | skipped += 1 |
|
0 commit comments