fix: ensure relative avatars keep small scope

This commit is contained in:
Michael Smith 2025-04-09 16:07:58 +00:00
parent e035f1fca3
commit 3b9c01ea6c

View File

@ -414,7 +414,7 @@ func parseContributorFiles(readmeEntries []readme) (
contributorProfileFrontmatter: yml,
}
if prev, conflict := frontmatterByUsername[processed.GithubUsername]; conflict {
if prev, isConflict := frontmatterByUsername[processed.GithubUsername]; isConflict {
yamlParsingErrors.Errors = append(
yamlParsingErrors.Errors,
fmt.Errorf(
@ -534,6 +534,17 @@ func validateRelativeUrls(
continue
}
if strings.HasPrefix(*con.AvatarUrl, "..") {
problems = append(
problems,
fmt.Errorf(
"%q: relative avatar URLs cannot be placed outside a user's namespaced directory",
con.FilePath,
),
)
continue
}
absolutePath := strings.TrimSuffix(con.FilePath, "README.md") +
*con.AvatarUrl
_, err := os.ReadFile(absolutePath)