-
Notifications
You must be signed in to change notification settings - Fork 87
Fix Jira integration for Atlassian Cloud migration #916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ package jira | |||||||||||||||||
|
|
||||||||||||||||||
| import ( | ||||||||||||||||||
| "fmt" | ||||||||||||||||||
| "strings" | ||||||||||||||||||
| "net/url" | ||||||||||||||||||
|
|
||||||||||||||||||
| "github.com/andygrunwald/go-jira" | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
@@ -72,8 +72,9 @@ func (j *OHSSService) formatIssue(issue jira.Issue) (formatIssue OHSSIssue, err | |||||||||||||||||
| formatIssue.Title = issue.Fields.Summary | ||||||||||||||||||
| } | ||||||||||||||||||
| if issue.Self != "" { | ||||||||||||||||||
| selfSlice := strings.SplitAfter(issue.Self, ".com") | ||||||||||||||||||
| formatIssue.WebURL = fmt.Sprintf("%s/browse/%s", selfSlice[0], issue.Key) | ||||||||||||||||||
| if u, err := url.Parse(issue.Self); err == nil { | ||||||||||||||||||
| formatIssue.WebURL = fmt.Sprintf("%s://%s/browse/%s", u.Scheme, u.Host, issue.Key) | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+75
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Current WebURL parsing logic =="
rg -n -C3 'url\.Parse\(issue\.Self\)|WebURL' pkg/jira/ohssService.go
echo
echo "== Existing Self URL test cases =="
rg -n -C2 'Self\s*=' pkg/jira/ohssService_test.go
echo
echo "== Check for malformed/relative Self coverage =="
rg -n -C2 'malformed|invalid|relative|scheme|host' pkg/jira/ohssService_test.go || trueRepository: openshift/backplane-cli Length of output: 1321 Harden At lines 75-77, Current code has no test coverage for relative or malformed Proposed fix- if u, err := url.Parse(issue.Self); err == nil {
+ if u, err := url.Parse(issue.Self); err == nil &&
+ (u.Scheme == "http" || u.Scheme == "https") &&
+ u.Host != "" {
formatIssue.WebURL = fmt.Sprintf("%s://%s/browse/%s", u.Scheme, u.Host, issue.Key)
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| return formatIssue, nil | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default domain switch exposes domain-coupled issue ID parsing in access requests.
After Line 65 changes the default to
.net,pkg/accessrequest/accessRequest.go(Line 82) still strips URLs usingstrings.TrimPrefix(issueID, getJiraBaseURL()+"/browse/"). Full legacy.combrowse URLs won’t be normalized and can fail later issue-key handling. Consider making issue-ID extraction domain-agnostic (parse/browse/<KEY>from any Jira host).🤖 Prompt for AI Agents