Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit ed4ed7d

Browse files
committed
Fix handling of default values for scanners (fixes #60)
The default values for dropdowns and checkboxes were not being populated, and then the client side was initializing them to blank strings, which caused the default values to be wrong for script and pingless fields. This commit initializes default values for these field types, removes the int() coercion for pingless, and changes how the client side intializes values from default (since "false" is a valid default).
1 parent 5acb62b commit ed4ed7d

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

app/pathfinder_svc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def enrich_report(self, report):
174174
cves = self.host_enrich(host.os)
175175
if cves:
176176
host.cves.append(cves)
177-
report.hosts[key] = host
177+
report.hosts[key] = host
178178
return report
179179

180180
def software_enrich(self, software):

scanners/fields.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ def __init__(self, param, label=None, default=None):
77

88

99
class PulldownField:
10-
def __init__(self, param, values, label=None, prompt=None):
10+
def __init__(self, param, values, label=None, prompt=None, default=None):
1111
self.type = 'pulldown'
1212
self.param = param
1313
self.name = label or param
1414
self.values = values
1515
self.prompt = prompt
16+
self.default = values[0] if default is None else default
1617

1718

1819
class CheckboxField:
19-
def __init__(self, param, label=None):
20+
def __init__(self, param, label=None, default=None):
2021
self.type = 'checkbox'
2122
self.param = param
2223
self.name = label or param
24+
self.default = False if default is None else default

scanners/nmap/scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async def scan(self):
5656
script_args = (
5757
"--script-args %s" % self.script_args if self.script_args else ""
5858
)
59-
no_ping = "-Pn" if int(self.pingless) else ""
59+
no_ping = "-Pn" if self.pingless else ""
6060
ports = "-p %s" % self.ports if self.ports else ""
6161
command = "nmap --script %s %s -sV %s -oX %s %s %s" % (
6262
self.format_script(self.script),

templates/pathfinder.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ <h2>Create an Adversary</h2>
302302
response.fields.forEach((field) => {
303303
this.scannerFields.push({
304304
...field,
305-
value: field.default || ''
305+
value: field.default === null ? '' : field.default
306306
})
307307
});
308308
} catch(error) {

0 commit comments

Comments
 (0)