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

apiv2: set mitigated date if applicable #3285

Merged
merged 3 commits into from
Nov 24, 2020
Merged

Conversation

keenan-v1
Copy link
Contributor

  • Sets or clears mitigated date based on the value of is_Mitigated
  • Sets or clears mitigated_by based on the value of is_Mitigated and current user context

- Sets or clears mitigated date based on the value of is_Mitigated
- Sets or clears mitigated_by based on the value of is_Mitigated
Copy link
Member

@valentijnscholten valentijnscholten left a comment

Choose a reason for hiding this comment

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

thanks. i was confused a bit, but the logic looks ok. could you make it so we have 2 booleans and call save if one of them is True. so 'push_to_jira' and 'set_mitigated'? now if you quickyl read it could make readers think in some cases we will not save the instance at all due to the naming of the boolean.

@valentijnscholten valentijnscholten changed the title Implement Issue #3189 set mitigated date via API apiv2: set mitigated date if applicable Nov 18, 2020
@valentijnscholten
Copy link
Member

should the same logic be in perform_create? if somebody creates a finding that is already marked as mitigated?

instance.mitigated_by = self.context['request'].user
if settings.USE_TZ:
instance.mitigated = timezone.make_aware(instance.mitigated, timezone.get_default_timezone())
elif not instance.is_Mitigated and instance.mitigation is not None:
Copy link
Member

Choose a reason for hiding this comment

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

should this check for instance.mitigated instead of instance.mitigation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. My testing didn't catch this. Will fix.

@keenan-v1
Copy link
Contributor Author

I've added the requested changes and fixed the bug in variable naming. Tested the functionality and it is working as intended.

@valentijnscholten
Copy link
Member

thanks for the PR

@madchap
Copy link
Collaborator

madchap commented Nov 20, 2020

As a push to jira will actually overwrite the jira description field, this update may come as a surprise to some users. On the UI, there is the ? that warns about it, but in this case it will just do it.

@keenan-v1
Copy link
Contributor Author

As a push to jira will actually overwrite the jira description field, this update may come as a surprise to some users. On the UI, there is the ? that warns about it, but in this case it will just do it.

Isn't that more a problem with the push-to-jira patch and less of a problem with this one? I'm not entirely sure how the Jira stuff works as I don't use it yet. I simply worked around the Jira code here as it was overriding the same areas as my original fix for the mitigated date did.

@valentijnscholten valentijnscholten added this to the 1.10.0 milestone Nov 24, 2020
@madchap madchap merged commit 8e1327e into DefectDojo:dev Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants