mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 16:37:18 -04:00
Add more checks in migration code (#21011)
When migrating add several more important sanity checks: * SHAs must be SHAs * Refs must be valid Refs * URLs must be reasonable Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net>
This commit is contained in:
parent
93a610a819
commit
e6b3be4608
24 changed files with 714 additions and 302 deletions
|
@ -110,6 +110,20 @@ func NewOneDevDownloader(ctx context.Context, baseURL *url.URL, username, passwo
|
|||
return downloader
|
||||
}
|
||||
|
||||
// String implements Stringer
|
||||
func (d *OneDevDownloader) String() string {
|
||||
return fmt.Sprintf("migration from oneDev server %s [%d]/%s", d.baseURL, d.repoID, d.repoName)
|
||||
}
|
||||
|
||||
// ColorFormat provides a basic color format for a OneDevDownloader
|
||||
func (d *OneDevDownloader) ColorFormat(s fmt.State) {
|
||||
if d == nil {
|
||||
log.ColorFprintf(s, "<nil: OneDevDownloader>")
|
||||
return
|
||||
}
|
||||
log.ColorFprintf(s, "migration from oneDev server %s [%d]/%s", d.baseURL, d.repoID, d.repoName)
|
||||
}
|
||||
|
||||
func (d *OneDevDownloader) callAPI(endpoint string, parameter map[string]string, result interface{}) error {
|
||||
u, err := d.baseURL.Parse(endpoint)
|
||||
if err != nil {
|
||||
|
@ -542,6 +556,9 @@ func (d *OneDevDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque
|
|||
ForeignIndex: pr.ID,
|
||||
Context: onedevIssueContext{IsPullRequest: true},
|
||||
})
|
||||
|
||||
// SECURITY: Ensure that the PR is safe
|
||||
_ = CheckAndEnsureSafePR(pullRequests[len(pullRequests)-1], d.baseURL.String(), d)
|
||||
}
|
||||
|
||||
return pullRequests, len(pullRequests) == 0, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue