-
Notifications
You must be signed in to change notification settings - Fork 30
ci: Bun cooldown for installs, no gateway in publish, OIDC #597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
42cb58b
ci: Bun cooldown for installs, no gateway in publish, OIDC
guyofeck 9f69e84
ci: address review — trim comments, drop the reverse proxy check
claude 47a949f
ci: raise the bun cooldown from 7 to 14 days
claude 08d1bbc
chore: drop the accidentally committed __pycache__ artifact
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| #!/usr/bin/env python3 | ||
| """Fail if any GitHub Actions job skips the mandatory Wix gateway proxy action. | ||
|
|
||
| There is no opt-out marker by design. A job that genuinely cannot run the proxy | ||
| (a non-ubuntu runner, say) changes this script in the same PR, so the exception | ||
| gets reviewed in the open. | ||
| There is still no per-job opt-out marker by design. A job that genuinely cannot | ||
| run the proxy changes this script in the same PR, so the exception gets reviewed | ||
| in the open — which is exactly how PUBLISH_WORKFLOWS below came to exist. | ||
|
|
||
| The rule is bidirectional: non-publish jobs must run the proxy, and publish jobs | ||
| must not. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
@@ -19,6 +22,28 @@ | |
| # so a sparse checkout has to materialize both directories. | ||
| REQUIRED_PATHS = (".github/actions/wix-gateway-proxy", ".github/certs") | ||
|
|
||
| # Workflows that must NOT route npm through the embargo gateway. | ||
| # | ||
| # secplatform's interim policy for OSS repos (Dima Ryskin): use embargo for | ||
| # non-publish tasks, and protect publish tasks with an enforced lockfile | ||
| # (`bun install --frozen-lockfile`) plus a package manager that honors a | ||
| # minimal-age directive (`minimumReleaseAge` in bunfig.toml) instead. Those jobs | ||
| # resolve nothing, so dropping the gateway does not widen what they can pull. | ||
| # The gateway cannot carry a publish today — `npm publish` sends | ||
| # `PUT /<package>`, which misses its `^~ /-/` passthrough block, and it sets no | ||
| # client_max_body_size so nginx's 1 MB default rejects a packument carrying the | ||
| # base64 tarball. | ||
| # | ||
| # Keyed on exact filename, and every exemption is printed on success, so this | ||
| # cannot quietly grow. Revisit once the embargo publish bug is fixed: these | ||
| # workflows should go back to being gatewayed like everything else. | ||
| PUBLISH_WORKFLOWS = frozenset( | ||
| { | ||
| ".github/workflows/manual-publish.yml", | ||
| ".github/workflows/preview-publish.yml", | ||
| } | ||
| ) | ||
|
|
||
| FIX_HINT = """Every job must run the Wix gateway proxy immediately after a checkout that | ||
| puts it on disk, or that job's npm installs bypass the Wix embargo gateway. | ||
|
|
||
|
|
@@ -118,6 +143,20 @@ def job_problem(job: dict, workflows: frozenset[str]) -> str | None: | |
| return _checkout_problem(steps[0]) | ||
|
|
||
|
|
||
| def publish_job_problem(job: dict) -> str | None: | ||
| """Describe why this publish job wrongly runs the proxy, or None if it abstains.""" | ||
| if "uses" in job: | ||
| return None | ||
| steps = job.get("steps") or [] | ||
| if any(_uses(step) == PROXY_ACTION for step in steps): | ||
| return ( | ||
| "runs the Wix gateway proxy, but publish workflows must not: the gateway " | ||
| "cannot carry `npm publish`, so these workflows rely on the committed " | ||
| "lockfile plus min-release-age in .npmrc instead" | ||
| ) | ||
| return None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure this is really needed, maybe its enough to simply not check the publishing actions set explicitly in the list? |
||
|
|
||
|
|
||
| def _job_lines(text: str) -> dict[str, int]: | ||
| document = yaml.compose(text) | ||
| if document is None: | ||
|
|
@@ -133,16 +172,23 @@ def main(repo_root: pathlib.Path = REPO_ROOT) -> int: | |
| paths = sorted(p for p in workflows_dir.iterdir() if p.suffix in (".yml", ".yaml")) | ||
| workflows = frozenset(p.relative_to(repo_root).as_posix() for p in paths) | ||
| problems = [] | ||
| jobs = calls = 0 | ||
| jobs = calls = exempt = 0 | ||
| exempt_paths = set() | ||
|
|
||
| for path in paths: | ||
| rel = path.relative_to(repo_root).as_posix() | ||
| text = path.read_text(encoding="utf-8") | ||
| lines = _job_lines(text) | ||
| for job_id, job in ((yaml.safe_load(text) or {}).get("jobs") or {}).items(): | ||
| job = job or {} | ||
| jobs += 1 | ||
| calls += "uses" in job | ||
| problem = job_problem(job, workflows) | ||
| if rel in PUBLISH_WORKFLOWS: | ||
| exempt += 1 | ||
| exempt_paths.add(rel) | ||
| problem = publish_job_problem(job) | ||
| else: | ||
| jobs += 1 | ||
| calls += "uses" in job | ||
| problem = job_problem(job, workflows) | ||
| if problem: | ||
| problems.append((path.relative_to(repo_root), lines[job_id], job_id, problem)) | ||
|
|
||
|
|
@@ -156,9 +202,14 @@ def main(repo_root: pathlib.Path = REPO_ROOT) -> int: | |
|
|
||
| print( | ||
| f"Wix gateway proxy: verified {jobs - calls} of {jobs} jobs across " | ||
| f"{len(paths)} workflows ({calls} reusable-workflow calls delegate to " | ||
| f"the workflow they call)." | ||
| f"{len(paths) - len(exempt_paths)} workflows ({calls} reusable-workflow calls " | ||
| f"delegate to the workflow they call)." | ||
| ) | ||
| if exempt: | ||
| print( | ||
| f"Publish workflows exempt by policy, and verified to abstain " | ||
| f"({exempt} job(s)): " + ", ".join(sorted(exempt_paths)) | ||
| ) | ||
| return 0 | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets remove slop, enough to write that adding files here should not be taken easily and can pose a security concern