mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-29 18:38:28 +00: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:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user