fix: filter multi-segment identifiers from Jira issue key matching#902
Conversation
…VE-2026-41284 Adds FindJiraIssueKeys to the jira package which encapsulates pattern matching and filtering in one function. Matches that are always followed by -<digit> in the source text are discarded, preventing false positives from CVE/CWE-style identifiers. (#900)
…itives Replaces MatchPatternInCommitMessageORBranchName with direct GetCommitInfoFromCommitSHA + FindJiraIssueKeys, which encapsulates both regex matching and multi-segment identifier filtering. (#900)
|
Claude finished @dangrondahl's task in 3m 52s —— View job PR Review: fix: filter multi-segment identifiers from Jira issue key matching
Static AnalysisAll checks pass:
Review SummaryThis is a clean, well-structured PR. The TDD workflow is evident in the commit history (red → green → refactor → cleanup), and the previous review feedback (precondition comment, edge case tests) was addressed. What works well
Minor observations
Overall: LGTM. No bugs, no security concerns, no performance issues. The filtering logic is sound and well-tested. |
Address review feedback: document the precondition on isPartialMultiSegment, add tests for key appearing both standalone and in a multi-segment identifier, and for dedup behavior.
| searchTexts = append(searchTexts, o.secondarySource) | ||
| } | ||
| combinedText := strings.Join(searchTexts, "\n") | ||
| issueIDs := jira.FindJiraIssueKeys(combinedText, o.projectKeys) |
There was a problem hiding this comment.
Nit: the old MatchPatternInCommitMessageORBranchName returned []string{} for no matches, while FindJiraIssueKeys returns nil. This is fine here since range nil is a no-op in Go — just calling it out for awareness.
|
It's a minor nit, but I suggest we address |
Considered this. Moving the regexes to package-level compiled vars is possible, but the readability cost outweighs the benefit here. As you said, the CLI command runs once per invocation, so the per-call compilation is diminishing here. Keeping the regexes local to the function makes the code easier to follow. Leaving as-is. |
Summary
FindJiraIssueKeys()to thejirapackage, encapsulating regex matching and post-filtering in one function. Matches that are always followed by-<digit>in the source text (e.g.CVE-2026-41284) are discarded as false positives.attestJira.goto useFindJiraIssueKeysinstead of raw pattern matching viaMatchPatternInCommitMessageORBranchName.Closes #900
Test plan
go test ./internal/jira/passes (10 new tests + 2 existing)make lintpasses with 0 issuesmake test_integrationpasses (requires local server)