mirror of https://github.com/daffainfo/nuclei.git
Gitlab tracker: Duplicate issues (#4152)
* Added initial API docs * dark mode fixes! * gitlab tracker duplicate check * integration test * added In to search to restrict to title match * added example GitLab yaml --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>dev
parent
5ffe890c00
commit
0137a40a35
|
@ -690,6 +690,21 @@ github:
|
|||
issue-label: 'Nuclei'
|
||||
```
|
||||
|
||||
Alternatively if you use GitLab, create a config file following content and replace the appropriate values:
|
||||
|
||||
```yaml
|
||||
# GitLab contains configuration options for GitLab issue tracker
|
||||
|
||||
gitlab:
|
||||
username: '$user'
|
||||
base-url: 'gitlab.com'
|
||||
token: '$token'
|
||||
project-name: 'testing-project'
|
||||
issue-label: 'nuclei-label'
|
||||
severity-as-label: true
|
||||
duplicate-issue-check: true
|
||||
```
|
||||
|
||||
To store results in Elasticsearch, create a config file with the following content and replace the appropriate values:
|
||||
|
||||
```yaml
|
||||
|
|
|
@ -32,6 +32,8 @@ gitLab:
|
|||
project-name: "1234"
|
||||
# issue-label is the label of the created issue type
|
||||
issue-label: bug
|
||||
# duplicate-issue-check flag to enable duplicate tracking issue check.
|
||||
duplicate-issue-check: true
|
||||
|
||||
# Jira contains configuration options for Jira issue tracker
|
||||
jira:
|
||||
|
|
|
@ -33,6 +33,8 @@ type Options struct {
|
|||
// SeverityAsLabel (optional) sends the severity as the label of the created
|
||||
// issue.
|
||||
SeverityAsLabel bool `yaml:"severity-as-label"`
|
||||
// DuplicateIssueCheck is a bool to enable duplicate tracking issue check and update the newest
|
||||
DuplicateIssueCheck bool `yaml:"duplicate-issue-check" default:"false"`
|
||||
|
||||
HttpClient *retryablehttp.Client `yaml:"-"`
|
||||
}
|
||||
|
@ -71,6 +73,35 @@ func (i *Integration) CreateIssue(event *output.ResultEvent) error {
|
|||
}
|
||||
customLabels := gitlab.Labels(labels)
|
||||
assigneeIDs := []int{i.userID}
|
||||
if i.options.DuplicateIssueCheck {
|
||||
searchIn := "title"
|
||||
searchState := "all"
|
||||
issues, _, err := i.client.Issues.ListProjectIssues(i.options.ProjectName, &gitlab.ListProjectIssuesOptions{
|
||||
In: &searchIn,
|
||||
State: &searchState,
|
||||
Search: &summary,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(issues) > 0 {
|
||||
issue := issues[0]
|
||||
_, _, err := i.client.Notes.CreateIssueNote(i.options.ProjectName, issue.IID, &gitlab.CreateIssueNoteOptions{
|
||||
Body: &description,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if issue.State == "closed" {
|
||||
reopen := "reopen"
|
||||
_, resp, err := i.client.Issues.UpdateIssue(i.options.ProjectName, issue.IID, &gitlab.UpdateIssueOptions{
|
||||
StateEvent: &reopen,
|
||||
})
|
||||
fmt.Sprintln(resp, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, _, err := i.client.Issues.CreateIssue(i.options.ProjectName, &gitlab.CreateIssueOptions{
|
||||
Title: &summary,
|
||||
Description: &description,
|
||||
|
|
Loading…
Reference in New Issue