Skip to content

Add the close_old_findings parameter also to reimport API - #3572

Merged
madchap merged 13 commits into
DefectDojo:devfrom
ccojocar:add-param-reimport
Jan 6, 2021
Merged

madchap merged 13 commits into
DefectDojo:devfrom
ccojocar:add-param-reimport

Conversation

@ccojocar

Copy link
Copy Markdown
Contributor

Add the close_old_findings parameter to reimport API similarly like for import API. This param will control if the old findings are going to be mitigated or not. The change maintains the current behaviour by mitigating the old findings if no parameter is set in the reimport API request.

The reason for this change, it is triggered by one of our use cases where some git repositories are continuously scanned for secrets. After the initial scan, when the entire commits history is checked, the scanner goes over the commits only from the last 2 days. This generates just a diff of findings which when they get reimported leads to the mitigation of all other findings. Obviously those findings are not yet mitigated. That being said, we want to control when the old findings are mitigated by the reimport command.

cc @madchap @yilmi

@madchap

madchap commented Dec 31, 2020

Copy link
Copy Markdown
Contributor

lgtm, especially as this does not change the current behavior and allows for more flexibility.

@valentijnscholten

Copy link
Copy Markdown
Member

Please keep UI and API logic in sync.

@ccojocar

ccojocar commented Jan 4, 2021 •

Copy link
Copy Markdown
Contributor Author

Please keep UI and API logic in sync.

@valentijnscholten what exactly do you mean by this? Can you provide some pointer to the UI part which is out of sync?

@madchap

madchap commented Jan 4, 2021

Copy link
Copy Markdown
Contributor

Please keep UI and API logic in sync.

@valentijnscholten what exactly do you mean by this? Can you provide some pointer to the UI part which is out of sync?

Please have a look at https://github.com/DefectDojo/django-DefectDojo/blob/dev/dojo/test/views.py#L618

@ccojocar

ccojocar commented Jan 4, 2021

Copy link
Copy Markdown
Contributor Author

@valentijnscholten @madchap I added it the close_old_findings as a form param in the ReImport viewer in order to keep the functionality in sync with the API.

@valentijnscholten

Copy link
Copy Markdown
Member

Thanks. Sorry if my remarks was not clear, but unfortunately currently the reimport logic is duplicated in two places (and slighly different). We want to refactor this at some point, which makes it even more important to make sure the behaviour is covered by the unit tests or integration tests. Could you update the existing tests around import/reimport in test_import_reimport to reflect the new parameter?

Also, to have the new boolean appear on the form, it would need to be added to ReImportScanForm in forms.py, where a help_text can also be supplied to explain the behaviour.

@valentijnscholten valentijnscholten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see previous comment

@madchap
madchap self-requested a review January 4, 2021 22:55
@ccojocar

ccojocar commented Jan 5, 2021

Copy link
Copy Markdown
Contributor Author

@valentijnscholten I added the field into the form and also added a test to validate the reimport of old findings without closing them.

@valentijnscholten

Copy link
Copy Markdown
Member

The number of notes also changes when closing or not closing findings.
Also, could you make the sample files in the same form as the existing one regarding filenames and contents? (Comment out the findings instead of removing them). So it's easy to see the differences when maintaining/updating tests in the future?
I spent quite some time on making the tests readable / understandable / maintainable.

Also you probably can use the existing sample files as there is already 1 or more testcases testing the reimport with some findings no longer in the report.

@ccojocar
ccojocar force-pushed the add-param-reimport branch from 3669224 to 62a0f05 Compare January 6, 2021 10:05
@ccojocar

ccojocar commented Jan 6, 2021

Copy link
Copy Markdown
Contributor Author

@valentijnscholten I reworked the unit test following your comments and it is now green. Please have a look if you are happy with the current implementation. Thanks!

@valentijnscholten valentijnscholten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks

@madchap
madchap merged commit 0ff8643 into DefectDojo:dev Jan 6, 2021
@madchap madchap mentioned this pull request Jan 19, 2021
9alexx3 pushed a commit to 9alexx3/django-DefectDojo that referenced this pull request Aug 12, 2026
…#3572)

* Add the close_old_findings parameter also to reimport API
* Introduce the close_old_findings as a parameter into the reimport form to keep the functionality in sync with the API
* Add the close_old_findings field to ReImportScanForm
* Add test to validate the reimport of findings without closing old findings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants