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

Add AUDIT and POLICY to EntityType enum #353

Merged

Conversation

timopollmeier
Copy link
Member

@timopollmeier timopollmeier commented Dec 3, 2020

What:
The types AUDIT and POLICY are added to the EntityType enum and
the functions using them are updated to change them to TASK and
SCAN_CONFIG internally.

Why:
This allows using these compliance types in commands that distinguish
them from TASK and SCAN_CONFIG.
One such command will be GET_AGGREGATES where it will determine
what the usage_type option is set to in the GMP command.
The new types will be translated to TASK and SCAN_CONFIG for the GMP
commands.

How:
Tested by running a test script that uses the affected function with new entity types:
https://gist.github.com/timopollmeier/d6d45c832e49771b73e0b94d8b94daaa

Checklist:

This allows using these compliance types in commands that distinguish
them from TASK and SCAN_CONFIG.
The new types will be translated to TASK and SCAN_CONFIG for the GMP
commands.
@codecov
Copy link

codecov bot commented Dec 3, 2020

Codecov Report

Merging #353 (6cb0a1a) into master (9d0301f) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #353      +/-   ##
==========================================
+ Coverage   97.51%   97.58%   +0.07%     
==========================================
  Files          20       20              
  Lines        4311     4438     +127     
==========================================
+ Hits         4204     4331     +127     
  Misses        107      107              
Impacted Files Coverage Δ
gvm/protocols/gmpv208/types.py 100.00% <100.00%> (ø)
gvm/protocols/gmpv9/gmpv9.py 98.21% <100.00%> (+0.57%) ⬆️
gvm/protocols/gmpv9/types.py 97.18% <100.00%> (+0.02%) ⬆️

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 9d0301f...6cb0a1a. Read the comment docs.

@y0urself
Copy link
Member

y0urself commented Dec 4, 2020

You somehow also added create/modify permission/tags ... is that intended?

The checks only recognize the enum variables as equal if the
values are compared explicitly.
@timopollmeier
Copy link
Member Author

timopollmeier commented Dec 5, 2020

You somehow also added create/modify permission/tags ... is that intended?

Yes, I added new versions of those functions that translate AUDIT into TASK and POLICY into SCAN_CONFIG because gvmd does not recognize the compliance types as valid resource/entity types.
Maybe there's a way to just call the old version with modified parameters but I don't know how well this would work
and if we want these kinds of dependencies between protocol versions.

@timopollmeier timopollmeier marked this pull request as ready for review December 5, 2020 10:39
@timopollmeier timopollmeier requested a review from a team as a code owner December 5, 2020 10:39
@y0urself
Copy link
Member

y0urself commented Dec 5, 2020

You need to provide tests for the new functions and Types.

These tests cover the new entity types and the special cases for
handling permissions and tags referencing them.
@timopollmeier timopollmeier force-pushed the add-compliance-entity-types branch from 850cdde to 73e7181 Compare December 7, 2020 09:43
These tests check if the create and modify functions for permissions
and tags detect an invalid resource type.
@y0urself y0urself merged commit 629a56c into greenbone:master Dec 7, 2020
@timopollmeier timopollmeier deleted the add-compliance-entity-types branch December 7, 2020 12:45
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.

2 participants