-
Notifications
You must be signed in to change notification settings - Fork 110
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
Semver checks #909
Semver checks #909
Conversation
d00b919
to
d3ede9f
Compare
d3ede9f
to
f86bb91
Compare
f86bb91
to
63647aa
Compare
v2: Documented semver-checks in CONTRIBUTING.md. |
63647aa
to
70fc2d5
Compare
v3: Noticed that I didn't install semver-checks in push action... Well, I did say I have no idea how to test it. |
TODO / Considerations:
|
70fc2d5
to
fa1ad25
Compare
fa1ad25
to
7e69c96
Compare
b560b84
to
ee643d8
Compare
9eefa4e
to
0502fa1
Compare
v5:
|
.github/workflows/semver_checks.yml
Outdated
- uses: actions/checkout@v3 | ||
- name: Install semver-checks | ||
run: cargo install cargo-semver-checks --no-default-features | ||
- name: Verify that's it's safe to publish the version. |
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 think this label implies too much, that the tool does really exhaustive checks and its assessment about semver compatibility can be trusted.
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.
Changed. Is the current version better?
If the workflow removes the |
This allows to run the tool manually. Right now the script doesn't do much, but when we want to run it with various feature sets or other flags it will be more useful.
This workflow looks for breaking API changes using popular cargo-semver-checks tool. This comit introduces it only for PRs. If PR breaks API, appropriate label is added, otherwise it is removed.
Add a job that checks compatibility when a tag is pushed. It gets current version from Cargo.toml, calculates previous version (unless current version is on crates.io - which should not be the case) and checks that the release type (major / minor / patch) is correct.
b180328
to
d190123
Compare
This is to avoid a race condition where a job scheduled for a first push finished after the job scheduled for a second push, resulting in incorrectly assigning / removing a label to PR.
d190123
to
8fb2355
Compare
v6: Addressed review comments, added concurrency control |
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.
Looks good. Please drop the "TMP" commit and I'll merge.
8fb2355
to
f6d68d3
Compare
Done |
This PR introduces cargo-semver-checks to our CI.
The behavior is very similar to what I described in the issue: #906
semver-checks-breaking
label if the PR breaks API (compared to PR base). Report from the tool, containing info about incompatibilities, is posted as a comment.Apart from CI integration this PR also modifies
Makefile
andCONTRIBUTING.MD
to make it easier for contributors to run checks locally.cargo-semver-checks has some false-negatives and false-positives, so it is NOT a replacement for a reviewer.
Reviewer still needs to check the code to see if it's API-breaking. semver-checks should still be a big help with that, catching many cases that
are very hard to identify manually or that people forget about.
Security:
PR CI uses
pull_request_target
trigger which can receive read-write GITHUB_TOKEN (whilepull_request
can't if a PR is from a fork - which is a vast majority of PRs).This is required in order to be able to add/remove label to a PR. It makes such jobs a valuable target for attackers.
Workflows using
pull_request_target
are run in the context of base of a PR instead of head of a PR (likepull_request
workflows do). This prevents the attacker from modifying the workflow file.PR CI is split into two parts. First, unprivileged, job (called
semver-pull-request-check
) performs actual check, which is an insecure process (for example: attacker could add maliciousbuild.rs
file).For this reason, this first job has no permissions (
permissions: {}
attribute), so taking over it should not give anything interesting to the attacker.The second, privileged, job (called
semver-pull-request-label
) has write permissions for pull requests and its only task is adding or removing a label to/from a PR.It checks the output from the first job and labels a PR based on that. The only thing done with outputs from unprivileged job is a simple comparison with "0",
so modifying those outputs will not result in takeover of privileged job.
As far as I can tell, from GitHub docs each job is run on a clean VM, so taking over unprivileged job should not allow attacker to take over privileged job.
Fixes: #906
Pre-review checklist
I added relevant tests for new features and bug fixes.I have provided docstrings for the public items that I want to introduce.I have adjusted the documentation in./docs/source/
.Fixes:
annotations to PR description.