diff options
author | zeripath <art27@cantab.net> | 2022-09-04 11:47:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-04 13:47:56 +0300 |
commit | e6b3be460840f1f982d5358198466e7d6f509d21 (patch) | |
tree | d3e4cb52c6a7df321e9b4ffdfe6f99f79d392b63 /services/migrations/onedev.go | |
parent | 93a610a819688b54d4565b8cbbae7cc04c552073 (diff) | |
download | gitea-e6b3be460840f1f982d5358198466e7d6f509d21.tar.gz gitea-e6b3be460840f1f982d5358198466e7d6f509d21.zip |
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>
Diffstat (limited to 'services/migrations/onedev.go')
-rw-r--r-- | services/migrations/onedev.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/services/migrations/onedev.go b/services/migrations/onedev.go index a46ba35f72..8cc826c3b4 100644 --- a/services/migrations/onedev.go +++ b/services/migrations/onedev.go @@ -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 |