Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Add filter option to get_vts #94

Merged
merged 4 commits into from
Mar 21, 2019
Merged

Conversation

jjnicola
Copy link
Member

It is possible to get a specific collection of VTS with the filter.
Use:
<get_vts filter='modification_time>20190320'/>

@jjnicola jjnicola requested a review from bjoernricks March 20, 2019 14:44
@codecov
Copy link

codecov bot commented Mar 20, 2019

Codecov Report

Merging #94 into master will increase coverage by 0.54%.
The diff coverage is 85.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #94      +/-   ##
==========================================
+ Coverage   66.22%   66.77%   +0.54%     
==========================================
  Files           5        6       +1     
  Lines        1448     1496      +48     
==========================================
+ Hits          959      999      +40     
- Misses        489      497       +8
Impacted Files Coverage Δ
ospd/vtfilter.py 82.92% <82.92%> (ø)
ospd/ospd.py 67.03% <92.3%> (+0.16%) ⬆️

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 476648b...f805149. Read the comment docs.

@jjnicola jjnicola marked this pull request as ready for review March 21, 2019 11:10
@jjnicola jjnicola requested a review from a team March 21, 2019 11:10
Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

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

Just some minor hints from my side 👍

ospd/misc.py Outdated
@@ -852,7 +852,7 @@ def main(name, klass):
cargs = get_common_args(parser)
logging.getLogger().setLevel(cargs['log_level'])
wrapper = klass(certfile=cargs['certfile'], keyfile=cargs['keyfile'],
cafile=cargs['cafile'])
cafile=cargs['cafile'], customvtfilter=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required. It's an optional keyword that defaults to None.

Suggested change
cafile=cargs['cafile'], customvtfilter=None)
cafile=cargs['cafile'])


_vts_aux = vts.copy()
for _element, _oper, _filter_val in filters:
for vt_id in _vts_aux.copy():
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is not necessary to create another copy by using? Not sure.

Suggested change
for vt_id in _vts_aux.copy():
for vt_id in vts:

Copy link
Member Author

Choose a reason for hiding this comment

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

The copy is need since the _vts_aux dictionary is change during the iteration.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah but _vts_aux is already a copy of vts. Therefore IMHO it should be possible to iterate over the original unchanged vts variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

At this moment you can pass more than one filter option separated by a semicolon. E.g. :
<get_vts filter='modification_time&gt;201903130813;modification_time&lt;201903130815'/>

The second one must be applied over the result of the first one (logical AND operation).
If vts is used instead, the logical operation will be an OR, and the result will be the whole vts collection.

ospd/vtfilter.py Outdated
format_func = self.allowed_filter.get(element)
return format_func(value)

def get_filtered_vts_list(self, vts, vt_filter=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not use a optional keyword argument for a required parameter. instead

Suggested change
def get_filtered_vts_list(self, vts, vt_filter=None):
def get_filtered_vts_list(self, vts, vt_filter):

Besides that the vts argument isn't documented.

@jjnicola jjnicola requested a review from bjoernricks March 21, 2019 13:59
@jjnicola
Copy link
Member Author

@bjoernricks Thanks a lot for the review!

@jjnicola jjnicola merged commit eafcd61 into greenbone:master Mar 21, 2019
@jjnicola jjnicola deleted the get-vts-filter branch March 21, 2019 14:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants