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

Niceness #109

Merged
merged 10 commits into from
Jun 3, 2019
Merged

Niceness #109

merged 10 commits into from
Jun 3, 2019

Conversation

jjnicola
Copy link
Member

@jjnicola jjnicola commented Jun 3, 2019

Add the --niceness option. Each scan will be run with the passed niceness.
Default is 10.

@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #109 into master will increase coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #109      +/-   ##
==========================================
+ Coverage   68.07%   68.19%   +0.11%     
==========================================
  Files           8        8              
  Lines        1604     1610       +6     
==========================================
+ Hits         1092     1098       +6     
  Misses        512      512
Impacted Files Coverage Δ
ospd/ospd.py 66.07% <100%> (ø) ⬆️
ospd/misc.py 70.08% <100%> (+0.15%) ⬆️
ospd/ospd_ssh.py 89.13% <100%> (+0.75%) ⬆️

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 16ca130...96d409a. Read the comment docs.

ospd/misc.py Outdated
@@ -868,6 +878,9 @@ def filename(string):
help='Path to the logging file.')
parser.add_argument('--version', action='store_true',
help='Print version then exit.')
parser.add_argument('--niceness', default=NICENESS, type=niceness,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason for defining an own type instead using the default int type https://docs.python.org/3/library/argparse.html#type ?

ospd/ospd.py Outdated
@@ -200,7 +200,7 @@ class OSPDaemon(object):
specific options eg. the w3af profile for w3af wrapper.
"""

def __init__(self, certfile, keyfile, cafile,
def __init__(self, certfile, keyfile, cafile, niceness,
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I would make niceness optional

Suggested change
def __init__(self, certfile, keyfile, cafile, niceness,
def __init__(self, certfile, keyfile, cafile, niceness=None,

ospd/ospd_ssh.py Outdated
@@ -140,6 +142,7 @@ def run_command(self, scan_id, host, cmd):
self.add_scan_error(scan_id, host=host, value=str(err))
return None

cmd = "nice -n %s %s" % (self.NICENESS, cmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cmd = "nice -n %s %s" % (self.NICENESS, cmd)
if self.NICENESS is not None:
cmd = "nice -n %s %s" % (self.NICENESS, cmd)

ospd/ospd_ssh.py Outdated
cafile=cafile)
cafile=cafile, niceness=niceness)

self.NICENESS = niceness
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why self.NICENESS is all uppercase here? I would mark it as a private variable by using

Suggested change
self.NICENESS = niceness
self._niceness = niceness

@jjnicola jjnicola requested a review from bjoernricks June 3, 2019 12:53
ospd/ospd_ssh.py Outdated
@@ -77,11 +77,13 @@ class OSPDaemonSimpleSSH(OSPDaemon):
an array.
"""

def __init__(self, certfile, keyfile, cafile):
def __init__(self, certfile, keyfile, cafile, niceness):
Copy link
Contributor

Choose a reason for hiding this comment

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

Just this single change is missing to make niceness optional here too

Suggested change
def __init__(self, certfile, keyfile, cafile, niceness):
def __init__(self, certfile, keyfile, cafile, niceness=None):

ospd/misc.py Outdated Show resolved Hide resolved
bjoernricks
bjoernricks previously approved these changes Jun 3, 2019
Co-Authored-By: Björn Ricks <[email protected]>
@jjnicola jjnicola dismissed stale reviews from bjoernricks via 96d409a June 3, 2019 13:19
@jjnicola jjnicola merged commit 3b01902 into greenbone:master Jun 3, 2019
@jjnicola jjnicola deleted the niceness branch June 3, 2019 13:26
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