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

Support scan queuing #278

Merged
merged 31 commits into from
Jun 4, 2020
Merged

Support scan queuing #278

merged 31 commits into from
Jun 4, 2020

Conversation

jjnicola
Copy link
Member

No description provided.

Move the check from star_scan command handler to
start_pending_scans().
This is because the new scans are not rejected anymore,
but will not be started if the max_scans value was reached or if there is no
enough free memory.
Also, replace the error raise for a debug log message.
Receive the directory path where the picked scan info will be stored.
Initialize the ScanCollection() with this path.
Only the minimal information is stored.
Other information is prepared in a dictionary to be pickled later.

The credentials are taken from the target dictionary and stored in the
scan_table. This prevent to pickle sensitive information.
Storing credentials does not have big impact in the memory usage.
Call the new method from create_scan()
The info is stored in the corresponding slot in the scan_table

Call the method to unpickle from start_scan().
The file will be deleted.
Removes the file with the pickled scan_info and set the scan status to STOPPED.
This allows the client to delete the scan
@codecov
Copy link

codecov bot commented May 28, 2020

Codecov Report

Merging #278 into master will increase coverage by 0.35%.
The diff coverage is 77.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #278      +/-   ##
==========================================
+ Coverage   74.57%   74.92%   +0.35%     
==========================================
  Files          21       22       +1     
  Lines        2332     2469     +137     
==========================================
+ Hits         1739     1850     +111     
- Misses        593      619      +26     
Impacted Files Coverage Δ
ospd/main.py 0.00% <0.00%> (ø)
ospd/ospd.py 75.36% <61.29%> (-1.85%) ⬇️
ospd/scan.py 89.90% <83.33%> (-2.24%) ⬇️
ospd/datapickler.py 88.15% <88.15%> (ø)
ospd/command/command.py 87.53% <100.00%> (+1.86%) ⬆️
ospd/parser.py 88.50% <100.00%> (+4.98%) ⬆️

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 1ed431a...4081913. Read the comment docs.

@jjnicola jjnicola force-pushed the queue branch 2 times, most recently from c6b468e to d232623 Compare May 29, 2020 09:57
@jjnicola jjnicola marked this pull request as ready for review May 29, 2020 10:01
@jjnicola jjnicola marked this pull request as draft May 29, 2020 10:46
@jjnicola jjnicola marked this pull request as ready for review May 29, 2020 14:13
@jjnicola jjnicola marked this pull request as draft June 2, 2020 06:26
If there is no enough memory, the scan is kept in the queue.
A minimum free memory value in MB must be given as option, otherwise
no free memory check will be performed.
This will remove the pickled scan info files.
@jjnicola jjnicola marked this pull request as ready for review June 2, 2020 14:57
@jjnicola jjnicola marked this pull request as draft June 3, 2020 10:46
@jjnicola jjnicola marked this pull request as ready for review June 3, 2020 11:26
ospd/datapickler.py Outdated Show resolved Hide resolved
ospd/datapickler.py Outdated Show resolved Hide resolved
ospd/datapickler.py Outdated Show resolved Hide resolved
ospd/main.py Outdated Show resolved Hide resolved
ospd/ospd.py Show resolved Hide resolved
ospd/ospd.py Outdated Show resolved Hide resolved
ospd/ospd.py Show resolved Hide resolved
ospd/scan.py Outdated Show resolved Hide resolved
Instead use a method wrapper to perform the file clean up.
Also, remove the file before raising an error when the unpickling fails.
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 additional type hints. Afterwards it is ready to be merged.

ospd/scan.py Outdated Show resolved Hide resolved
ospd/scan.py Outdated Show resolved Hide resolved
ospd/scan.py Outdated Show resolved Hide resolved
ospd/ospd.py Outdated Show resolved Hide resolved
ospd/ospd.py Outdated Show resolved Hide resolved
@jjnicola jjnicola requested a review from bjoernricks June 4, 2020 12:39
@bjoernricks bjoernricks merged commit 35dbabe into greenbone:master Jun 4, 2020
@jjnicola jjnicola deleted the queue branch June 4, 2020 12:57
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.

None yet

2 participants