-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add endpoint deleting workflow run #34337
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
base: main
Are you sure you want to change the base?
Conversation
Just pushed new commits. Please check. |
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.
Overall looks good, but I defer my approval after more testing from my side.
Co-authored-by: Lunny Xiao <[email protected]>
|
||
runID := ctx.PathParamInt64("run") | ||
|
||
run, err := actions_model.GetRunByID(ctx, runID) |
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.
Permission check bypass? A doer could delete repoB's action runs by accessing repoA?
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.
Permission check bypass? A doer could delete repoB's action runs by accessing repoA?
I believe the middlewares before repo.DeleteActionRun
already do permission check.
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.
How? The middleware allows to access repoA, but what if your "runID" is for repoB?
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 agree with wxiaoguang, the middleware does not check the path parameter "run" to belong to the checked repository.
Please check if the RepoID of the ActionRun with runid matches the ctx.Repo.Repository.ID
Feel free to look at the artifacts rest api Get and Delete by id.
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.
@ChristopherHX In that case I think your artifact implementation has the same defection too
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.
My GetArtifactsOfRun has a repoid filter => database checks it
My getArtifactsByPathParam has an explicit repo_id check after reading it by id from database
If you found something, please point me to it. I would be happy to fix it.
@@ -36,6 +36,15 @@ | |||
<div class="run-list-meta">{{svg "octicon-calendar" 16}}{{DateUtils.TimeSince .Updated}}</div> | |||
<div class="run-list-meta">{{svg "octicon-stopwatch" 16}}{{.Duration}}</div> | |||
</div> | |||
{{if and ($.AllowDeleteWorkflowRuns) (.Link) (.Status.IsDone)}} |
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.
Why check (.Link)
?
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.
At line 14 {{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}
I don't quite understand this but I found .Link
is the one wanted.
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.
Hmm, I do not think the old code is right (since Implement actions (#21937))
the run.Link
should be used directly without check.
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.
iirc what I found is, take gitea as example, {{$.Link}}
would be https://gitea.com/gitea/act/actions
that misses out /runs
.
So At line 14 can just remove the if check and at line 39 can remove the check?
In current Gitea probably {{$.Link}}/{{.Index}}
would never be reached.
Anyone else?
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.
IMO the old $.Link
is an abuse (over-defensive programming)
.... I think we should always use run.Link
in this case (just forget the $.Link
and removing the if
check should be good enough).
Add endpoint deleting workflow run
Resolves #26219
/claim #26219