aboutsummaryrefslogtreecommitdiffstats
path: root/services/migrations/onedev.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-09-04 11:47:56 +0100
committerGitHub <noreply@github.com>2022-09-04 13:47:56 +0300
commite6b3be460840f1f982d5358198466e7d6f509d21 (patch)
treed3e4cb52c6a7df321e9b4ffdfe6f99f79d392b63 /services/migrations/onedev.go
parent93a610a819688b54d4565b8cbbae7cc04c552073 (diff)
downloadgitea-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.go17
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