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

Fix "given type was invalid" error for saving filters #1428

Merged
merged 3 commits into from May 28, 2019

Conversation

sarahd93
Copy link
Contributor

Checklist:

@sarahd93 sarahd93 marked this pull request as ready for review May 28, 2019 10:42
@sarahd93 sarahd93 requested a review from a team May 28, 2019 10:42
swaterkamp
swaterkamp previously approved these changes May 28, 2019
@codecov
Copy link

codecov bot commented May 28, 2019

Codecov Report

Merging #1428 into gsa-8.0 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           gsa-8.0   #1428   +/-   ##
=======================================
  Coverage     37.1%   37.1%           
=======================================
  Files          961     961           
  Lines        21742   21742           
  Branches      6025    6047   +22     
=======================================
  Hits          8067    8067           
  Misses       12365   12365           
  Partials      1310    1310
Impacted Files Coverage Δ
gsa/src/web/entities/container.js 1.09% <ø> (ø) ⬆️
gsa/src/web/pages/vulns/listpage.js 42.85% <0%> (ø) ⬆️

Continue to review full report at Codecov.

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

@@ -604,7 +604,7 @@ class EntitiesContainer extends React.Component {
<React.Fragment>
{children({
...other,
createFilterType: this.props.gmpname,
createFilterType: apiType(this.props.gmpname),
Copy link
Member

Choose a reason for hiding this comment

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

If I remember correctly we have done a similar fix already at another place. Would be better if the command class method to create the filter gets fixed instead.
I really would like to use our names at all places in GSA and convert the names to api types when doing an api call only.

Copy link
Member

Choose a reason for hiding this comment

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

In that case my suggestion is to change gmp/commands/filters.js line 46 from
resource_type: type,
to
resource_type: apiType(type),

Copy link
Member

Choose a reason for hiding this comment

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

Yes but all calls of this API need to be checked carefully before. Changing it may brake other code.

Copy link
Member

Choose a reason for hiding this comment

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

Currently our code is full of special handling of the type at different places. We really should move all special handling to the commands (and models). We need to abstract the types away and be consistent in GSA.

But also this can be done in another PR.

Copy link
Member

Choose a reason for hiding this comment

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

The other place that you mentioned, seems to be getTagsByType() in the container (line 530). But here we are stitching together a filter string, where the apiType is needed at that very place.

Copy link
Member

Choose a reason for hiding this comment

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

The other place that you mentioned, seems to be getTagsByType() in the container (line 530).

Was't sure about that. Just had in mind we already did implement a similar fix.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, just found another place: it's for the EntityVerifyIcon where we use apiType again. The thing is, that in this place as well, we are stitching together a string for a request.

My suggestion for this PR and the current type problem: Merge PR as is and add "unifying types" to our to-do for the near future. I would really like the filter creation to work for 5.0.2, but with your concerns about breaking other API calls, I would refrain from changing the command directly. I believe that filter.create() is not used very often and we might be able to test it manually, but with the current time pressure for 5.0.2 we should not take any risks.

Copy link
Member

Choose a reason for hiding this comment

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

I am all for merging this PR. Just wanted to notice we need a better fix in the future

@swaterkamp swaterkamp self-requested a review May 28, 2019 12:53
@swaterkamp swaterkamp merged commit 7b83b82 into greenbone:gsa-8.0 May 28, 2019
@sarahd93 sarahd93 deleted the save_filter_gsa8 branch May 28, 2019 13:00
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.

None yet

3 participants