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

Fix get_count_total(). Accept -1 value set by the server. #355

Merged
merged 1 commit into from
Feb 1, 2021

Conversation

jjnicola
Copy link
Member

What:

The value set by the server has priority over the value
calculated from the original target list by ospd.
As ospd is not intelligent enough to check the amount of valid
hosts, check for duplicated or invalid hosts, consider a negative
value set for the server, in case it detects an invalid target string
or a different amount than the orignal amount in the target list.

Why:
Let ospd to set a scan with an invalid target as finished instead of interrupted, but there is no other result than the error message to inform the client about the invalid target.

How:

  • Set debug log level in ospd.
  • Start a scan with an invalid target list (only possible via gvm-cli, as gsa wont you to create a invalid target).
  • check with <get_scans> that the scan results xml element has "status = finished" and "progress=100"
  • check that the only result is the error message.
$ gvm-cli --protocol OSP --timeout 120 socket --socketpath=/home/jnicola/install/var/run/ospd/openvas.sock --xml "<get_scans scan_id='829097a9-85d5-4bb8-bac0-e64c362b2836'/>"|xmlstarlet fo
<?xml version="1.0"?>
<get_scans_response status="200" status_text="OK">
  <scan end_time="1611925139" id="829097a9-85d5-4bb8-bac0-e64c362b2836" progress="100" start_time="1611925136" status="finished" target="some$invalid.target.net.%com">
    <results>
      <result host="" hostname="" name="" port=" " qod="" severity="" test_id="" type="Error Message" uri="">Invalid target list: some$invalid.target.net.%com.</result>
    </results>
  </scan>
</get_scans_response>

Checklist:

The value set by the server has priority over the value
calculated from the original target list by ospd.
As ospd is not intelligent enough to check the amount of valid
hosts, check for duplicated or invalid hosts, consider a negative
value set for the server, in case it detects an invalid target string
or a different amount than the orignal amount in the target list.
@jjnicola
Copy link
Member Author

Depends on PR greenbone/openvas-scanner#646

@codecov
Copy link

codecov bot commented Jan 29, 2021

Codecov Report

Merging #355 (c88399c) into ospd-20.08 (98ebda9) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@              Coverage Diff               @@
##           ospd-20.08     #355      +/-   ##
==============================================
+ Coverage       73.91%   73.93%   +0.02%     
==============================================
  Files              23       23              
  Lines            2603     2605       +2     
==============================================
+ Hits             1924     1926       +2     
  Misses            679      679              
Impacted Files Coverage Δ
ospd/scan.py 92.62% <100.00%> (+0.06%) ⬆️

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 98ebda9...c88399c. Read the comment docs.

@jjnicola jjnicola merged commit 2ac33ea into greenbone:ospd-20.08 Feb 1, 2021
@jjnicola jjnicola deleted the get-host-count branch February 1, 2021 08:46
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