Skip to content

Commit d48c2c3

Browse files
feat(trackers): add site-url to optionally provide jira server URL for oauth (#6716)
* feat: add site-url to optionally provide jira server URL for oauth * chore(cmd): add `site-url` config option Adds optional `site-url` field to JIRA issue tracker configuration for specifying browsable URL when it differs from the API endpoint. This is particularly useful for OAuth-based JIRA Cloud integrations where `issue.Self` contains "api.atlassian.com" instead of the user-facing domain. Signed-off-by: Dwi Siswanto <[email protected]> --------- Signed-off-by: Dwi Siswanto <[email protected]> Co-authored-by: Dwi Siswanto <[email protected]>
1 parent c80ac99 commit d48c2c3

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

cmd/nuclei/issue-tracker-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
# update-existing: false
101101
# # URL is the jira application url
102102
# url: https://localhost/jira
103+
# # site-url is the browsable URL for the Jira instance (optional)
104+
# # If not provided, issue.Self will be used. Useful for OAuth where issue.Self contains api.atlassian.com
105+
# site-url: https://your-company.atlassian.net
103106
# # account-id is the account-id of the Jira user or username in case of on-prem Jira
104107
# account-id: test-account-id
105108
# # email is the email of the user for Jira instance

pkg/reporting/trackers/jira/jira.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ type Options struct {
184184
UpdateExisting bool `yaml:"update-existing" json:"update_existing"`
185185
// URL is the URL of the jira server
186186
URL string `yaml:"url" json:"url" validate:"required"`
187+
// SiteURL is the browsable URL for the Jira instance (optional)
188+
// If not provided, issue.Self will be used. Useful for OAuth where issue.Self contains api.atlassian.com
189+
SiteURL string `yaml:"site-url" json:"site_url"`
187190
// AccountID is the accountID of the jira user.
188191
AccountID string `yaml:"account-id" json:"account_id" validate:"required"`
189192
// Email is the email of the user for jira instance
@@ -346,16 +349,26 @@ func (i *Integration) CreateNewIssue(event *output.ResultEvent) (*filters.Create
346349
}
347350
return nil, fmt.Errorf("%w => %s", err, data)
348351
}
349-
return getIssueResponseFromJira(createdIssue)
352+
return i.getIssueResponseFromJira(createdIssue)
350353
}
351354

352-
func getIssueResponseFromJira(issue *jira.Issue) (*filters.CreateIssueResponse, error) {
353-
parsed, err := url.Parse(issue.Self)
354-
if err != nil {
355-
return nil, err
355+
func (i *Integration) getIssueResponseFromJira(issue *jira.Issue) (*filters.CreateIssueResponse, error) {
356+
var issueURL string
357+
358+
// Use SiteURL if provided, otherwise fall back to original issue.Self logic
359+
if i.options.SiteURL != "" {
360+
// Use the configured site URL for browsable links (useful for OAuth)
361+
baseURL := strings.TrimRight(i.options.SiteURL, "/")
362+
issueURL = fmt.Sprintf("%s/browse/%s", baseURL, issue.Key)
363+
} else {
364+
// Fall back to original logic using issue.Self
365+
parsed, err := url.Parse(issue.Self)
366+
if err != nil {
367+
return nil, err
368+
}
369+
parsed.Path = fmt.Sprintf("/browse/%s", issue.Key)
370+
issueURL = parsed.String()
356371
}
357-
parsed.Path = fmt.Sprintf("/browse/%s", issue.Key)
358-
issueURL := parsed.String()
359372

360373
return &filters.CreateIssueResponse{
361374
IssueID: issue.ID,
@@ -376,7 +389,7 @@ func (i *Integration) CreateIssue(event *output.ResultEvent) (*filters.CreateIss
376389
if err != nil {
377390
return nil, errors.Wrap(err, "could not add comment to existing issue")
378391
}
379-
return getIssueResponseFromJira(&issue)
392+
return i.getIssueResponseFromJira(&issue)
380393
}
381394
}
382395
resp, err := i.CreateNewIssue(event)

0 commit comments

Comments
 (0)