Skip to content
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

Atlassian Error: "An issue type with this name already exists" #23

Closed
patelp132 opened this issue Mar 25, 2020 · 26 comments
Closed

Atlassian Error: "An issue type with this name already exists" #23

patelp132 opened this issue Mar 25, 2020 · 26 comments

Comments

@patelp132
Copy link

Getting an error when running the script. Not sure what on the JIRA end is causing this issue
Screen Shot 2020-03-24 at 5 06 26 PM

@SteveMcGrath
Copy link
Collaborator

Can you provide the full traceback and some debug logs?

@SteveMcGrath
Copy link
Collaborator

whats your config file look like?

@patelp132
Copy link
Author

patelp132 commented Mar 25, 2020

Just like the example:
Stored in a 'config.yaml'

tenable:
  access_key: 000001773236158ce8943c7369c12f98c092be2e1582b95ef86da5a6c3700000
  secret_key: 111111773236158ce8943c7369c12f98c092be2e1582b95ef86da5a6c3711111

jira:
  api_token: 11111scPw10lX2WvDoj00000
  api_username: username@company.com
  address: company.atlassian.net

project:
  leadAccountId: 554433:00112233-ffee-aabb-aabb-998877665544

@SteveMcGrath
Copy link
Collaborator

SteveMcGrath commented Mar 26, 2020

May I ask that you add in the following to your config and try to re-run:

log:
  level: debug

Then paste in the output. If you want to make is more readable, simply wrap the output in with 3 ticks (the unshifted tilde) above and below.

@SteveMcGrath
Copy link
Collaborator

SteveMcGrath commented Mar 26, 2020

Thats odd. It appears to be trying to create a Sub-Task issuetype, which it shouldn't ever to as the default one should exist. Can you create this python script next to your config file, run it, and then paste the output?

Basically what it's doing is retrieving the list of issuetypes and printing them to the screen.

from tenable_jira.jira import Jira
from tenable_jira.config import base_config
from restfly.utils import dict_merge
import yaml, json

config_file = 'config.yaml'

config = dict_merge(
    base_config(),
    yaml.load(open(config_file), Loader=yaml.Loader)
)
jira = Jira(
    'https://{}/rest/api/3'.format(config['jira']['address']),
    config['jira']['api_username'],
    config['jira']['api_token']
)
print('Available Issue Types are:')
for a in jira.issue_types.list():
    print('{:>10}: {}'.format(a.get('id'), a.get('name')))

@patelp132
Copy link
Author

Yeah i was having trouble tracking where this issue was coming from.

     11243: Service Request
     11244: Service Request with Approvals
     11279: Emailed request
     11278: Ask a question
     11238: Subtask
     11277: Submit a request or incident
         7: Technical task
     10000: Sub-Task
     10107: Discovered Bug
         1: Bug
         5: Epic
         2: New Feature
         6: Story
         3: Task
         4: Improvement
     10100: Test
     10701: User Story
     10902: Employee Term
     10802: SRE Incident
     10401: Problem-Do Not Use
     10501: Incident
     10801: Employee Change
     10502: RCA Action
     10903: Employee Transfer
     10601: Defect
     11001: SAR Request
     11272: Bug
     11239: Task
     11203: Epic
     11204: Subtask
     11213: Subtask
     11242: Feature
     11101: Data Request
     11209: Epic
     11208: Task
     11210: Subtask
     11211: Task
     11258: Spike
     11214: Story
     11212: Epic
     11218: Task
     11219: Epic
     11220: Subtask
     11240: Epic
     11224: RCA
     11225: Task
     11226: Epic
     11227: Subtask
     11241: Subtask
     11231: Story
     11229: Epic
     11230: Subtask
     11276: Incident
     11273: Story
     11262: Normal Change
     11200: Story
     11248: Task
     11249: Epic
     11250: Subtask
     11263: Task
     11264: Epic
     11265: Subtask
     11275: New ask
     11269: Task
     11270: Epic
     11271: Subtask
     11285: Feature Request
     11266: Task
     11267: Epic
     11274: Problem
     11284: Support
     10002: Project
     10005: Creative Request
     10101: IT Help
     10102: Purchase
     10103: Change
     10104: Fault
     10105: Access Request
     10901: Employee Hire
     10301: Access
     10106: Break\Fix
     10004: Bug Report
         8: Test Case
     10006: Package Request
     10007: Engineering Request```

@SteveMcGrath
Copy link
Collaborator

alrighty, well thats a lot of task and subtask issuetypes...

You're likely going to need to manually force the task and subtask settings in the config. Add this in and see if it works:

issue_types:
  - jira_id: 3
    name: Task
    type: standard
    search:
    - Tenable Plugin ID
  - jira_id: 10000
    name: Sub-task
    type: subtask
    search:
    - Tenable Plugin ID
    - Tenable Asset UUID
    - Device IPv4
    - Device IPv6
    - Vulnerability Port
    - Vulnerability Protocol

@patelp132
Copy link
Author

patelp132 commented Mar 26, 2020

where am i adding that? in the config file?

@SteveMcGrath
Copy link
Collaborator

yup.

@SteveMcGrath
Copy link
Collaborator

I'm gonna need the full debug log.

@SteveMcGrath
Copy link
Collaborator

Looks like the rood cause is the issuetype for the task. Using the output from your issuetype selection, you have the following issuetypes with the same name (below). I had selected the lowest number for each in my config I had sent you, but you should try some of the other IDs and see if you have better success.

I dont have a better answer for you sadly, as Jira's APIs are quite limited in this regard.

Task IDs:
    3
    11208
    11211
    11218
    11225
    11239
    11248
    11263
    11266
    11269

Sub-task IDs:
    10000
    11204
    11210
    11213
    11220
    11227
    11230
    11238
    11241
    11250
    11265
    11271

@patelp132
Copy link
Author

Changing the ID's that aren't in that list, triggers a new error with "errors":{"issuetype":"valid issue type is required"}}'

@SteveMcGrath
Copy link
Collaborator

can you update to the latest version of the integration? The later versions will actually report their version in the logs.

@patelp132
Copy link
Author

yeah we haven't done this integration and its the first time getting it going. Looks like it is the lastest version and the version is being show in the logs as 2020-03-26 13:00:46,075 root INFO Tenable2JiraCloud Version 1.1.3 is this what you are referring to?

@SteveMcGrath
Copy link
Collaborator

yes. i didnt see it in the debug you had sent before.

@SteveMcGrath
Copy link
Collaborator

Hmm, looking more closely at the logs, it appears that it's not able to select the appropriate screens...

2020-03-26 12:26:04,084 tenable_jira.transform.Tio2Jira INFO Using JIRA Screens []

As a result of that, it's not associating the fields to the screens. I think we're going to have to explicitly declare to the integration the screen IDs. If you goto the configuration within Jira and look for the following screens:

  • VULN: Task Management Create Issue Screen
  • VULN: Task Management Edit/View Issue Screen

If you click either the configure or the edit link for each one and then look at the URL on the next page, you'll get the id for the screen. Copy that id for each screen and then we will make the following addition to the configuration file:

screen:
  jira_ids:
    - 10016
    - 10017

This should sidestep the screen searcher and just tell the integration to populate the tabs for those screens. This happens as Jira doesn't have a way to find the direct linkage between a project and a screen via the API, so the integration is trying to figure it out by the name. It's not perfect, and seems to have run afoul here.

If all works well, you should see a lot more IDs being logged in the beginning of the run, basically detailing the screen id, tab id, and field id.

@patelp132
Copy link
Author

accidentally closed. Working on trying this out

@patelp132 patelp132 reopened this Mar 26, 2020
@patelp132
Copy link
Author

Should those screen already exist? or do we need to create those screens and screen schemes and then add that to the config file with the ID's for the new screens (replacing the IDs you sent)

@SteveMcGrath
Copy link
Collaborator

those screens should have been created with the VULN Project

@patelp132
Copy link
Author

Yeah the screens were not there. Need to create those and im assuming the screen schemes will also need to be created or those fields get created by the script?

@SteveMcGrath
Copy link
Collaborator

SteveMcGrath commented Mar 27, 2020

Once the screens are created, the script will create & populate the fields and tabs within those screens.

@patelp132
Copy link
Author

Thanks for the help Steve!

@SteveMcGrath
Copy link
Collaborator

Everything working now?

@patelp132
Copy link
Author

yup, got it working. When we run this will it close vuln tickets that have been addressed and then reopen the same ticket if that same vuln comes back?

@SteveMcGrath
Copy link
Collaborator

It will not re-open an old ticket, but create a new one instead. it will auto-close tickets when the vulnerability state changes to fixed/closed. These are all detailed out further in the readme ;)

@javijor80
Copy link

javijor80 commented May 13, 2021

Hi SteveMcGrath,

Could you please confirm if this python script is complete and from which url we can get all the modules used in the import such as jira, base_config, etc.?

from tenable_jira.jira import Jira
from tenable_jira.config import base_config
from restfly.utils import dict_merge
import yaml, json

config_file = 'config.yaml'

config = dict_merge(
base_config(),
yaml.load(open(config_file), Loader=yaml.Loader)
)
jira = Jira(
'https://{}/rest/api/3'.format(config['jira']['address']),
config['jira']['api_username'],
config['jira']['api_token']
)
print('Available Issue Types are:')
for a in jira.issue_types.list():
print('{:>10}: {}'.format(a.get('id'), a.get('name')))

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants