-
Notifications
You must be signed in to change notification settings - Fork 20
feat: fail-closed guard against proprietary source in this public repo #160
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # pre-commit: block proprietary source from entering this public repo. | ||
| # Enable with: git config core.hooksPath .githooks | ||
| # | ||
| # Checks only the staged (added/copied/modified) files for speed. | ||
| # POSIX bash 3.2 compatible (stock macOS). | ||
| set -euo pipefail | ||
|
|
||
| repo_root="$(git rev-parse --show-toplevel)" | ||
| checker="$repo_root/scripts/check-proprietary-source.sh" | ||
|
|
||
| if [ ! -f "$checker" ]; then | ||
| echo "pre-commit: $checker is missing — refusing to commit without the guard." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| staged=() | ||
| while IFS= read -r f; do | ||
| [ -n "$f" ] && staged+=("$f") | ||
| done < <(git diff --cached --name-only --diff-filter=ACM) | ||
|
|
||
| if [ "${#staged[@]}" -eq 0 ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| bash "$checker" "${staged[@]}" |
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # pre-merge-commit: git does NOT run pre-commit for merge commits, so a | ||
| # `git merge` that brings in proprietary source would otherwise slip past the | ||
| # local guard entirely. This repo vendors third-party sources (unity-webview), | ||
| # which makes merging an upstream branch a routine operation — exactly the case | ||
| # that needs covering. Delegates to the same check as pre-commit. | ||
| # | ||
| # Enable with: git config core.hooksPath .githooks | ||
| set -euo pipefail | ||
|
|
||
| exec bash "$(git rev-parse --show-toplevel)/.githooks/pre-commit" |
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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: No proprietary source | ||
|
|
||
| # Fail-closed gate: keeps native (Java/Kotlin) source, the private Gradle | ||
| # build system, and the private build pipeline out of this public repo. | ||
| # Native code ships only as compiled .aar / .unitypackage / .bundle artifacts. | ||
| # See scripts/check-proprietary-source.sh for the denylist and rationale. | ||
| # | ||
| # Runs on every push to ANY branch (the repo is public, so a pushed branch is | ||
| # world-visible even without a PR) and on every PR. | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| push: | ||
| branches: ['**'] | ||
|
|
||
| jobs: | ||
| no-proprietary-source: | ||
| runs-on: ubuntu-latest | ||
|
marc-n-dream marked this conversation as resolved.
|
||
| # Read-only gate: it only ever scans the tree, so it must not be able to | ||
| # write to it. Do not widen without a concrete reason. | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Scan tracked files for proprietary source | ||
| run: bash scripts/check-proprietary-source.sh | ||
| shell: bash | ||
|
|
||
| - name: Reject submodule gitlinks | ||
| run: | | ||
| gitlinks=$(git ls-files -s | awk '$1 == "160000" { print $4 }') | ||
| if [ -n "$gitlinks" ]; then | ||
| echo "ERROR: submodule gitlink(s) found — the private repos must not be" >&2 | ||
| echo "referenced as submodules in this public repo:" >&2 | ||
| echo "$gitlinks" | sed 's/^/ - /' >&2 | ||
| exit 1 | ||
| fi | ||
| shell: bash | ||
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
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.
Uh oh!
There was an error while loading. Please reload this page.