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

JIRA: allow different templates for jira description rendering #3938

Merged
merged 3 commits into from
Mar 4, 2021

Conversation

valentijnscholten
Copy link
Member

@valentijnscholten valentijnscholten commented Feb 26, 2021

Depending on your JIRA instance or JIRA project, you may want to use different templates for rendering the issue description. Sometimes you want to provide all the details and want them to be visible in JIRA.
Sometimes you want to provide only a link back into defect dojo and not too much details.
This PR allows you to chose between these two templates, or add even more of your own templates.
Any templates added to (or modified in) dojo/templates/issue-trackers automatically become options in the jira config dropdowns.

The PR is always falling back to the default full description template already in use. So when people to do nothing after upgrading, it just keeps work as it was. It's all optional.

The PR also adds the component_name, component_version and all the SAST_xxxx fields to the "full/default" jira template, fixing #3931

image
image

BTW The first attempt at this PR was using a new model JIRAIssueTemplate that could be edited via the Django Admin portal at /admin. But this opened up risks that people could use the template language to retrieve all kinds of sensitive details. In the current world I think a lot of setups still have "everyone" as staff/superuser, so there was too much risk.
With a better permission model we could still switch to using a model instead of having to use templates on the filesystem and having to rebuild the images (or use complex mounting nobody understands ;-))

BTW2 In v2 of this PR I used the FilePathField on the model to let django populate the dropdown for us. But this resulted in the full path being stored in the issue_template field, where the template loader expects a relative path. So this required adding/removing of the prefix in some places, which broke the model validation, etc.

BTW3 So then I moved to just a CharField with choices. This worked, but if a user adds a template on disk, the choices change and django expects you to make a migration. Our initializer automatically makes those resulting in instances getting our of sync and in conflict with upstream releases.

So I fell back to just using a CharField and populating the dropdown on the forms.

@valentijnscholten valentijnscholten changed the title jira: allow different templates for jira description rendering WIP: jira: allow different templates for jira description rendering Feb 26, 2021
@valentijnscholten valentijnscholten changed the title WIP: jira: allow different templates for jira description rendering JIRA: allow different templates for jira description rendering Feb 26, 2021
@valentijnscholten valentijnscholten marked this pull request as ready for review February 26, 2021 17:08
@madchap madchap self-requested a review February 27, 2021 10:02
@madchap madchap added New Migration Adding a new migration file. Take care when merging. settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR labels Feb 27, 2021
@madchap
Copy link
Collaborator

madchap commented Feb 28, 2021

fyi @yilmi

Copy link
Collaborator

@madchap madchap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally tested in staging environment, works peachy :-)

This will allow us to address some teams wanting to restrict data access for confidentiality purposes, while others want all details in JIRA directly without having to navigate to Dojo.

@madchap madchap requested a review from a team March 2, 2021 06:21
Copy link
Contributor

@damiencarol damiencarol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave a try. it's a good feature. Maybe some users will want to add there own template in the future

@damiencarol damiencarol merged commit 1cebe36 into DefectDojo:dev Mar 4, 2021
@valentijnscholten valentijnscholten deleted the jira-fs-templates branch March 4, 2021 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New Migration Adding a new migration file. Take care when merging. settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants