@@ -2265,12 +2265,15 @@ def _private_key_inputs(text: str) -> bool:
22652265 return False
22662266
22672267
2268- def _holds_credentials (workflow : str , body : str , * , effective_permissions : bool = False ) -> bool :
2268+ def _holds_credentials (workflow : str , body : str , * , effective_permissions : bool = False ,
2269+ strict : bool = False ) -> bool :
22692270 """L6: non-GITHUB_TOKEN secrets, OIDC writes or a deployment environment.
22702271
22712272 Existing VM checks conservatively include workflow permissions. GKE checks
22722273 use the job's effective scopes. Bracket/dynamic secret access and inherited
2273- reusable-workflow secrets must not bypass either rule.
2274+ reusable-workflow secrets must not bypass either rule. ``strict`` is
2275+ reserved for the token-only prebuilt artifact job; other callers retain
2276+ the main workflow's comment-stripped credential scan.
22742277 """
22752278 if (_job_values (body , 'environment' )
22762279 or _job_values (body , 'secrets' ) == ['inherit' ]):
@@ -2282,38 +2285,42 @@ def _holds_credentials(workflow: str, body: str, *, effective_permissions: bool
22822285 for value in permissions ):
22832286 return True
22842287
2285- # Expressions expand even in script comments; retain every raw byte.
2286- # Other jobs' App credentials are not inherited by the artifact job.
2287- header = _JOBS_KEY .split (workflow , maxsplit = 1 )[0 ]
2288- inherited_env = []
2289- in_env = False
2290- for line in workflow .split ('\n ' ):
2291- if line .strip () and _indent (line ) == 0 and not line .startswith ('#' ):
2292- in_env = _key_value (line , 'env' ) is not None
2293- if in_env :
2294- inherited_env .append (line )
2295- text = header + '\n ' + body + '\n ' + '\n ' .join (inherited_env )
2296- if (_uses_app_token (workflow , body )
2297- or _private_key_inputs (body + '\n ' + '\n ' .join (inherited_env ))):
2298- return True
2299- # A whole/dynamic secrets context cannot prove GITHUB_TOKEN-only use.
2300- # Prose may mention secrets; inspect expressions without cutting hashes
2301- # or treating a quoted }} (including doubled quotes) as their end.
2302- for expression in re .finditer (r'\$\{\{' , text ):
2303- end , in_string = expression .end (), False
2304- while end < len (text ):
2305- if text [end ] == "'" :
2306- if in_string and text .startswith ("''" , end ):
2307- end += 2
2308- continue
2309- in_string = not in_string
2310- elif not in_string and text .startswith ('}}' , end ):
2311- break
2312- end += 1
2313- value = text [expression .end ():end ]
2314- if any (_SECRET_REFERENCE .match (value , context .start ()) is None
2315- for context in re .finditer (r'\bsecrets\b' , value , re .IGNORECASE )):
2288+ if strict :
2289+ # Expressions expand even in script comments; retain every raw byte.
2290+ # Other jobs' App credentials are not inherited by the artifact job.
2291+ header = _JOBS_KEY .split (workflow , maxsplit = 1 )[0 ]
2292+ inherited_env = []
2293+ in_env = False
2294+ for line in workflow .split ('\n ' ):
2295+ if line .strip () and _indent (line ) == 0 and not line .startswith ('#' ):
2296+ in_env = _key_value (line , 'env' ) is not None
2297+ if in_env :
2298+ inherited_env .append (line )
2299+ text = header + '\n ' + body + '\n ' + '\n ' .join (inherited_env )
2300+ if (_uses_app_token (workflow , body )
2301+ or _private_key_inputs (body + '\n ' + '\n ' .join (inherited_env ))):
23162302 return True
2303+ # A whole/dynamic secrets context cannot prove GITHUB_TOKEN-only use.
2304+ # Prose may mention secrets; inspect expressions without cutting hashes
2305+ # or treating a quoted }} (including doubled quotes) as their end.
2306+ for expression in re .finditer (r'\$\{\{' , text ):
2307+ end , in_string = expression .end (), False
2308+ while end < len (text ):
2309+ if text [end ] == "'" :
2310+ if in_string and text .startswith ("''" , end ):
2311+ end += 2
2312+ continue
2313+ in_string = not in_string
2314+ elif not in_string and text .startswith ('}}' , end ):
2315+ break
2316+ end += 1
2317+ value = text [expression .end ():end ]
2318+ if any (_SECRET_REFERENCE .match (value , context .start ()) is None
2319+ for context in re .finditer (r'\bsecrets\b' , value , re .IGNORECASE )):
2320+ return True
2321+ else :
2322+ text = '\n ' .join (re .sub (r'\s+#.*$' , '' , line ) for line in _code (body ))
2323+ text += '\n ' + '\n ' .join (_job_values (workflow , 'env' ))
23172324 for match in _SECRET_REFERENCE .finditer (text ):
23182325 if match .group (1 ) is not None :
23192326 if match .group (1 ).upper () != 'GITHUB_TOKEN' :
@@ -2836,6 +2843,7 @@ def runner_findings(workflows: dict[str, str]) -> list[str]:
28362843 if job not in jobs ]
28372844 for job , body in jobs .items ():
28382845 runs_on , uses = _job_values (body , 'runs-on' ), _job_values (body , 'uses' )
2846+ strict_prebuilt = (name , job ) == ('release.yml' , 'prebuilt' )
28392847 gke_pin = gke_pins .get (job )
28402848 resolved_runners , _ = _resolved_runner_values (workflow , body )
28412849 has_gke = bool (_GKE_ROUTE .search (' ' .join (runs_on + resolved_runners )))
@@ -2876,7 +2884,8 @@ def runner_findings(workflows: dict[str, str]) -> list[str]:
28762884 findings .append (f'{ name } job { job } must not declare job services on GKE' )
28772885 if has_gke :
28782886 permissions = _effective_permissions (workflow , body )
2879- if (_holds_credentials (workflow , body , effective_permissions = True )
2887+ if (_holds_credentials (workflow , body , effective_permissions = True ,
2888+ strict = strict_prebuilt )
28802889 or any (re .search (r'\bid-token\b' , value ) for value in permissions )):
28812890 findings .append (f'{ name } job { job } must not expose credentials on GKE' )
28822891 runner_text = ' ' .join (runs_on + _job_block (body , 'strategy' ))
@@ -2892,7 +2901,8 @@ def runner_findings(workflows: dict[str, str]) -> list[str]:
28922901 # Other jobs retain the conservative workflow-plus-job credential check.
28932902 exact_gke_runner = bool (gke_pin and job in fixed_hosted and raw_runners == [gke_pin ])
28942903 credentials = _holds_credentials (
2895- workflow , body , effective_permissions = exact_gke_runner )
2904+ workflow , body , effective_permissions = exact_gke_runner ,
2905+ strict = strict_prebuilt )
28962906 if job not in pinned :
28972907 if pinned and runs_on :
28982908 findings .append (f'{ name } job { job } needs a pinned runner and time limit' )
@@ -3365,6 +3375,9 @@ def _compiler_cache_restore_with(step: str) -> list[str]:
33653375# A changed helper requires reviewing its source and controls before repinning.
33663376# This is a source contract, never an engine/build/glibc verdict.
33673377RELEASE_BOOKWORM_HELPER_BLOB = 'daaf2fe0541b5d0f8aab0746b35dcf069862afa3'
3378+ # The helper delegates the shipped-archive execution to this exact consumer.
3379+ # This is a source contract, never a native-runtime verdict.
3380+ RELEASE_BOOKWORM_CONSUMER_BLOB = 'd066968913c0d4ff7358e6fd4dde2a794e1be600'
33683381
33693382
33703383def release_prebuilt_helper_findings (source : str ) -> list [str ]:
@@ -3376,6 +3389,15 @@ def release_prebuilt_helper_findings(source: str) -> list[str]:
33763389 return []
33773390
33783391
3392+ def release_prebuilt_consumer_findings (source : str ) -> list [str ]:
3393+ payload = source .encode ('utf-8' )
3394+ actual = hashlib .sha1 (b'blob ' + str (len (payload )).encode ('ascii' ) + b'\0 ' + payload ).hexdigest ()
3395+ if actual != RELEASE_BOOKWORM_CONSUMER_BLOB :
3396+ return ['release prebuilt archive consumer differs from the reviewed full-library '
3397+ 'native consumer source contract' ]
3398+ return []
3399+
3400+
33793401def release_prebuilt_workflow_findings (workflow : str ) -> list [str ]:
33803402 """Pin artifact structure and its token-only admission surface."""
33813403 prebuilt = _jobs (workflow ).get ('prebuilt' , '' )
@@ -4890,6 +4912,17 @@ def main() -> int:
48904912 findings .append ('release prebuilt Bookworm helper must be a regular source file' )
48914913 else :
48924914 checked += release_prebuilt_helper_findings (read_ci_text (helper_path , findings ))
4915+ consumer_path = ROOT / 'scripts/check_shipped_archive_runtime.sh'
4916+ if (consumer_path .parent .is_symlink () or consumer_path .is_symlink ()
4917+ or not consumer_path .is_file ()):
4918+ findings .append ('release prebuilt archive consumer must be a regular source file' )
4919+ else :
4920+ try :
4921+ consumer = read_ci_text (consumer_path , findings , ROOT )
4922+ except OSError as error :
4923+ findings .append (f'release prebuilt archive consumer cannot be read: { error } ' )
4924+ else :
4925+ checked += release_prebuilt_consumer_findings (consumer )
48934926 findings = list (dict .fromkeys (findings + checked ))
48944927 for finding in findings :
48954928 print (finding )
0 commit comments