-
Notifications
You must be signed in to change notification settings - Fork 594
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
ci: ensure wasm integrity #3173
Open
Uzlopak
wants to merge
11
commits into
nodejs:main
Choose a base branch
from
Uzlopak:llhttp-integrity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c8d3201
ci: ensure wasm integrity
Uzlopak 24c01bf
fix malicious code
Uzlopak 08caa80
Update nodejs.yml
mcollina 673bd1b
modify
Uzlopak e9a12ab
malicious
Uzlopak 1f60fd5
use my repo
Uzlopak e9ca1c2
fetch depth 0
Uzlopak 787c7d9
revert malicious change
Uzlopak 8360f6e
output
Uzlopak 7e71031
fix typo
Uzlopak a2371db
finalize
Uzlopak 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 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,61 @@ | ||
name: Ensure integrity of llhttp wasm files | ||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check: | ||
name: Check files | ||
if: ${{ github.event_name == 'pull_request' }} | ||
outputs: | ||
run_job: ${{ steps.check_files.outputs.run_job }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check modified files | ||
id: check_files | ||
run: | | ||
echo "=============== list modified files ===============" | ||
git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD | ||
|
||
echo "========== check paths of modified files ==========" | ||
git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD > files.txt | ||
|
||
echo "run_job=false" > "$GITHUB_OUTPUT" | ||
|
||
while IFS= read -r file | ||
do | ||
if [[ $file == deps/llhttp/* || $file == lib/llhttp/llhttp* ]]; then | ||
echo "run_job=true" > "$GITHUB_OUTPUT" | ||
fi | ||
done < files.txt | ||
|
||
echo "GITHUB_OUTPUT: $(cat $GITHUB_OUTPUT)" | ||
|
||
llhttp-wasm: | ||
if: ${{ github.event_name == 'pull_request' && needs.check.outputs.run_job == 'true' }} | ||
name: Check integrity of generated wasm-files for llhttp | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Build wasm of llhttp | ||
run: | | ||
npm run prebuild:wasm && | ||
npm run build:wasm | ||
- name: Integrity Check | ||
run: | | ||
git diff --quiet lib/llhttp* | ||
if [ $? -eq 0 ]; then | ||
echo "No changes in the generated wasm files." | ||
else | ||
echo "Changes detected in the generated wasm files." | ||
echo "Please run 'npm run prebuild:wasm' and 'npm run build:wasm' locally and commit the changes." | ||
exit 1 | ||
fi |
This file contains 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 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.
I'm not sure I would run this for every PR. Maybe only if those files were changed?
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.
It is a reusable workflow. It has two steps. First check if wasm related files were changed, if so run the integrity check. Maybe the first step can be further optimized by using https://github.com/tj-actions/changed-files so that we can also take care of cases where we directly push into main. Also makes sense to obligatory run the integrity check in the automated release workflow.
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.
Maybe we can just run it in the release workflow then.
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.
@mcollina
Imho we should ensure that the repo has the correct content at any time. So if somebody tries to upstream malicious code into the repo, then it should be imho detected early and not as the last step of the release workflow.
The only issue i see, is that people could force push into main and bypass the ci.
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.
we can limit that now that we have automated releases, open a separate issue.