Skip to content

Commit 615c625

Browse files
committed
fix(security): constrain GitHub URL matches
1 parent d7c1a57 commit 615c625

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

internal/clustering/clustering_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ func TestExtractRefs(t *testing.T) {
112112
{"see #42 for context", 1},
113113
{"fix owner/repo#7", 1},
114114
{"https://github.com/owner/repo/issues/3", 1},
115+
{"see github.com/owner/repo/pull/4", 1},
116+
{"https://notgithub.com/owner/repo/issues/3", 0},
115117
{"nothing here", 0},
116118
}
117119

internal/clustering/fingerprint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var (
7878
// Matches owner/repo#123 or owner/repo #123 (issue or pull-request number).
7979
repoIssueRefPattern = regexp.MustCompile(`(?i)([a-z0-9](?:[a-z0-9-]*[a-z0-9])?)/([a-z0-9_.-]+)\s*#\s*(\d+)`)
8080
// Matches github.com/owner/repo/issues/123 or pull/123.
81-
urlRefPattern = regexp.MustCompile(`(?i)github\.com/([a-z0-9](?:[a-z0-9-]*[a-z0-9])?)/([a-z0-9_.-]+)/(?:issues|pull)/(\d+)`)
81+
urlRefPattern = regexp.MustCompile(`(?i)(?:^|[^a-z0-9.-])(?:https?://)?(?:www\.)?github\.com/([a-z0-9](?:[a-z0-9-]*[a-z0-9])?)/([a-z0-9_.-]+)/(?:issues|pull)/(\d+)`)
8282
// Matches bare #123 in body or title, constrained to word boundaries.
8383
bareRefPattern = regexp.MustCompile(`(?:^|\s|\W)#\s*(\d+)(?:\b|$)`)
8484
)

0 commit comments

Comments
 (0)