Skip to content

added function to handle visualizers errors#1741

Merged
0ssigeno merged 2 commits intodevelopfrom
visualizer-handle-errors
Jun 26, 2023
Merged

added function to handle visualizers errors#1741
0ssigeno merged 2 commits intodevelopfrom
visualizer-handle-errors

Conversation

@drosetti
Copy link
Contributor

@drosetti drosetti commented Jun 15, 2023

Description

Added a decorator to handle the exception and render a placeholder. In this way we avoid to break all the UI for a single component

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist

  • I have read and understood the rules about how to Contribute to this project
  • The pull request is for the branch develop
  • A new plugin (analyzer, connector, visualizer or playbook) was added or changed, in which case:
    • Usage file was updated.
    • Advanced-Usage was updated (in case the plugin provides additional optional configuration).
    • If the plugin requires mocked testing, _monkeypatch() was used in its class to apply the necessary decorators.
    • If a File analyzer was added and it supports a mimetype which is not already supported, you added a sample of that type inside the archive test_files.zip and you added the default tests for that mimetype in test_classes.py.
    • If you created a new analyzer and it is free (does not require API keys), please add it in the FREE_TO_USE_ANALYZERS playbook in playbook_config.json.
    • Check if it could make sense to add that analyzer/connector to other freely available playbooks.
    • I have provided the resulting raw JSON of a finished analysis and a screenshot of the results.
  • If external libraries/packages with restrictive licenses were used, they were added in the Legal Notice section.
  • Linters (Black, Flake, Isort) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved (see tests folder). All the tests (new and old ones) gave 0 errors.
  • If changes were made to an existing model/serializer/view, the docs were updated and regenerated (check CONTRIBUTE.md).
  • If the GUI has been modified:
    • I have a provided a screenshot of the result in the PR.
    • I have created new frontend tests for the new component or updated existing ones.

Important Rules

  • If you miss to compile the Checklist properly, your PR won't be reviewed by the maintainers.
  • If your changes decrease the overall tests coverage (you will know after the Codecov CI job is done), you should add the required tests to fix the problem
  • Everytime you make changes to the PR and you think the work is done, you should explicitly ask for a review. After being reviewed and received a "change request", you should explicitly ask for a review again once you have made the requested changes.

@drosetti drosetti requested a review from 0ssigeno June 15, 2023 16:53
@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Merging #1741 (7710d50) into develop (aa8820f) will increase coverage by 8.02%.
The diff coverage is 75.23%.

❗ Current head 7710d50 differs from pull request most recent head 5af711b. Consider uploading reports for the commit 5af711b to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1741      +/-   ##
===========================================
+ Coverage    66.75%   74.78%   +8.02%     
===========================================
  Files           95      328     +233     
  Lines         3706    11286    +7580     
  Branches       519     1236     +717     
===========================================
+ Hits          2474     8440    +5966     
- Misses         941     2337    +1396     
- Partials       291      509     +218     
Impacted Files Coverage Δ
...analyzers_manager/migrations/0004_datamigration.py 91.30% <ø> (ø)
api_app/management/commands/dumpplugin.py 0.00% <0.00%> (ø)
api_app/management/commands/dumppluginconfig.py 0.00% <0.00%> (ø)
api_app/management/commands/update_analyzer.py 0.00% <0.00%> (ø)
api_app/migrations/0002_added_job_field.py 100.00% <ø> (ø)
api_app/migrations/0003_auto_20201020_1406.py 100.00% <ø> (ø)
api_app/migrations/0004_auto_20201112_0021.py 100.00% <ø> (ø)
api_app/migrations/0005_auto_20210610_1028.py 100.00% <ø> (ø)
api_app/migrations/0006_v3_release.py 100.00% <ø> (ø)
api_app/migrations/0007_alter_tag_color.py 100.00% <ø> (ø)
... and 233 more

... and 138 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7a133a...5af711b. Read the comment docs.

Copy link
Contributor

@0ssigeno 0ssigeno left a comment

Choose a reason for hiding this comment

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

Other than two very minor thing, i really love the decorator.
We can improve it to actually return the same object that the function is decorating (meaning not always a VisualizableTitle), but other than nice work!

# def generate_field1(value):
# ...
# in case the generation of the field will raise an error
# this will handle it allowing to render the other components
Copy link
Member

Choose a reason for hiding this comment

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

I would like you to add something regarding this in the official docs where we explain how to write a visualizer too

@drosetti drosetti requested a review from mlodic June 26, 2023 09:25
@0ssigeno 0ssigeno merged commit 18df41a into develop Jun 26, 2023
@0ssigeno 0ssigeno deleted the visualizer-handle-errors branch June 26, 2023 13:11
carellamartina pushed a commit that referenced this pull request Jul 3, 2023
* added function to handle visualizers errors

* doc update
drosetti added a commit that referenced this pull request Jul 26, 2023
* added CopyToClipboardButton

* adjusted copy_text  field and visualizer tests

* added function to handle visualizers errors (#1741)

* added function to handle visualizers errors

* doc update

* More status mgmt (#1740)

* More status mgmt

Signed-off-by: 0ssigeno <[email protected]>

* Black

Signed-off-by: 0ssigeno <[email protected]>

* Minor fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fix migrations

Signed-off-by: 0ssigeno <[email protected]>

* Fix migrations

Signed-off-by: 0ssigeno <[email protected]>

* Prettier

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

---------

Signed-off-by: 0ssigeno <[email protected]>

* updated frontend dependencies

* Visualizer connected to playbook (#1755)

* Start

Signed-off-by: 0ssigeno <[email protected]>

* More stuff

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fix

Signed-off-by: 0ssigeno <[email protected]>

* Fix

Signed-off-by: 0ssigeno <[email protected]>

* Blake

Signed-off-by: 0ssigeno <[email protected]>

* Visualizer config points only to a single playbook, not many

Signed-off-by: 0ssigeno <[email protected]>

* Fix migration

Signed-off-by: 0ssigeno <[email protected]>

* Fix tests

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fix post review

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Blake

Signed-off-by: 0ssigeno <[email protected]>

* little adjustments

* Blake

Signed-off-by: 0ssigeno <[email protected]>

* Unused migration

Signed-off-by: 0ssigeno <[email protected]>

* Fix page order

Signed-off-by: 0ssigeno <[email protected]>

* Fix migration

Signed-off-by: 0ssigeno <[email protected]>

* Fix

Signed-off-by: 0ssigeno <[email protected]>

---------

Signed-off-by: 0ssigeno <[email protected]>
Co-authored-by: Matteo Lodi <[email protected]>

* adjusted order in docs

* added link to HackinBo presentation

* Bump ossf/scorecard-action from 2.1.2 to 2.2.0 (#1763)

Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.1.2 to 2.2.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](ossf/scorecard-action@e38b190...08b4669)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pre-commit from 3.2.1 to 3.3.3 in /requirements (#1764)

Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 3.2.1 to 3.3.3.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](pre-commit/pre-commit@v3.2.1...v3.3.3)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix captcha (#1761)

* Fix captcha

Signed-off-by: 0ssigeno <[email protected]>

* Fix backend

Signed-off-by: 0ssigeno <[email protected]>

* fix frontend

* Fix environments

Signed-off-by: 0ssigeno <[email protected]>

* Fix

Signed-off-by: 0ssigeno <[email protected]>

* black

* Fix deepsource

Signed-off-by: 0ssigeno <[email protected]>

---------

Signed-off-by: 0ssigeno <[email protected]>
Co-authored-by: Daniele Rosetti <[email protected]>

* Fix waiting

Signed-off-by: 0ssigeno <[email protected]>

* Pivot framework (#1739)

* Pivot

Signed-off-by: 0ssigeno <[email protected]>

* More stuff

Signed-off-by: 0ssigeno <[email protected]>

* More stuff

Signed-off-by: 0ssigeno <[email protected]>

* Typo

Signed-off-by: 0ssigeno <[email protected]>

* Pivot

Signed-off-by: 0ssigeno <[email protected]>

* Minor fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Update tests/pivot_manager/test_views.py

Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>

* Update tests/pivot_manager/test_views.py

Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>

* Update api_app/pivots_manager/models.py

Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>

* Fix post review

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* More fixes and tests

Signed-off-by: 0ssigeno <[email protected]>

* More fixes

Signed-off-by: 0ssigeno <[email protected]>

* Minor fixes

Signed-off-by: 0ssigeno <[email protected]>

* deepsource

Signed-off-by: 0ssigeno <[email protected]>

* typo

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Blake

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Fixes

Signed-off-by: 0ssigeno <[email protected]>

* Manage files

Signed-off-by: 0ssigeno <[email protected]>

* Fix test

Signed-off-by: 0ssigeno <[email protected]>

---------

Signed-off-by: 0ssigeno <[email protected]>
Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
Co-authored-by: Matteo Lodi <[email protected]>

* set USE_RECAPTCHA as False by default

* collapsed job metadata in job result (#1754)

* collapsed jobInfoCard in jobResult

* adjusted UncontrolledTooltip message

* added collapse test

* Fix

Signed-off-by: 0ssigeno <[email protected]>

* Frontend improvements (#1772)

* fixed status

* changed size for children elements

* removed test

* test modify

* added small

* improved small value

* fixed frontend tests

* prettier

* Fix migrations

Signed-off-by: 0ssigeno <[email protected]>

* added CopyToClipboardButton

* adjusted copy_text  field and visualizer tests

* added VisualizerTooltip component + adjusted tests

* removed redundant default arguments

* adjusted tooltip position + tests

* fix

* adjested buttons

* fixed tests

---------

Signed-off-by: 0ssigeno <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Daniele Rosetti <[email protected]>
Co-authored-by: Simone Berni <[email protected]>
Co-authored-by: Daniele Rosetti <[email protected]>
Co-authored-by: Matteo Lodi <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: 0ssigeno <[email protected]>
Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants