mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 17:25:28 +00:00
Merge pull request #6145 from projectdiscovery/jira-improvements
feat: added bearer support to jira reporting for self hosted + misc
This commit is contained in:
commit
566b1f9860
@ -3,6 +3,7 @@ package jira
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -68,9 +69,12 @@ type Options struct {
|
|||||||
// AccountID is the accountID of the jira user.
|
// AccountID is the accountID of the jira user.
|
||||||
AccountID string `yaml:"account-id" json:"account_id" validate:"required"`
|
AccountID string `yaml:"account-id" json:"account_id" validate:"required"`
|
||||||
// Email is the email of the user for jira instance
|
// Email is the email of the user for jira instance
|
||||||
Email string `yaml:"email" json:"email" validate:"required,email"`
|
Email string `yaml:"email" json:"email"`
|
||||||
|
// PersonalAccessToken is the personal access token for jira instance.
|
||||||
|
// If this is set, Bearer Auth is used instead of Basic Auth.
|
||||||
|
PersonalAccessToken string `yaml:"personal-access-token" json:"personal_access_token"`
|
||||||
// Token is the token for jira instance.
|
// Token is the token for jira instance.
|
||||||
Token string `yaml:"token" json:"token" validate:"required"`
|
Token string `yaml:"token" json:"token"`
|
||||||
// ProjectName is the name of the project.
|
// ProjectName is the name of the project.
|
||||||
ProjectName string `yaml:"project-name" json:"project_name"`
|
ProjectName string `yaml:"project-name" json:"project_name"`
|
||||||
// ProjectID is the ID of the project (optional)
|
// ProjectID is the ID of the project (optional)
|
||||||
@ -103,14 +107,28 @@ func New(options *Options) (*Integration, error) {
|
|||||||
if !options.Cloud {
|
if !options.Cloud {
|
||||||
username = options.AccountID
|
username = options.AccountID
|
||||||
}
|
}
|
||||||
tp := jira.BasicAuthTransport{
|
|
||||||
Username: username,
|
var httpclient *http.Client
|
||||||
Password: options.Token,
|
if options.PersonalAccessToken != "" {
|
||||||
|
bearerTp := jira.BearerAuthTransport{
|
||||||
|
Token: options.PersonalAccessToken,
|
||||||
|
}
|
||||||
|
if options.HttpClient != nil {
|
||||||
|
bearerTp.Transport = options.HttpClient.HTTPClient.Transport
|
||||||
|
}
|
||||||
|
httpclient = bearerTp.Client()
|
||||||
|
} else {
|
||||||
|
basicTp := jira.BasicAuthTransport{
|
||||||
|
Username: username,
|
||||||
|
Password: options.Token,
|
||||||
|
}
|
||||||
|
if options.HttpClient != nil {
|
||||||
|
basicTp.Transport = options.HttpClient.HTTPClient.Transport
|
||||||
|
}
|
||||||
|
httpclient = basicTp.Client()
|
||||||
}
|
}
|
||||||
if options.HttpClient != nil {
|
|
||||||
tp.Transport = options.HttpClient.HTTPClient.Transport
|
jiraClient, err := jira.NewClient(httpclient, options.URL)
|
||||||
}
|
|
||||||
jiraClient, err := jira.NewClient(tp.Client(), options.URL)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user