| @@ 47-90 (lines=44) @@ | ||
| 44 | return port_names_list |
|
| 45 | ||
| 46 | ||
| 47 | def get_config(gmp, debug=False): |
|
| 48 | # get all configs of the openvas instance |
|
| 49 | res = gmp.get_configs() |
|
| 50 | ||
| 51 | # configurable template |
|
| 52 | template = "fast" |
|
| 53 | ||
| 54 | # match the config abbreviation to accepted config names |
|
| 55 | config_list = [ |
|
| 56 | 'Full and fast', |
|
| 57 | 'Full and fast ultimate', |
|
| 58 | 'Full and very deep', |
|
| 59 | 'Full and very deep ultimate', |
|
| 60 | 'System Discovery', |
|
| 61 | ] |
|
| 62 | template_abbreviation_mapper = { |
|
| 63 | "fast": config_list[0], |
|
| 64 | "fast-ulti": config_list[1], |
|
| 65 | "deep": config_list[2], |
|
| 66 | "deep-ulti": config_list[3], |
|
| 67 | "discovery": config_list[4], |
|
| 68 | } |
|
| 69 | ||
| 70 | config_id = "-" |
|
| 71 | for conf in res.xpath('config'): |
|
| 72 | cid = conf.xpath('@id')[0] |
|
| 73 | name = conf.xpath('name/text()')[0] |
|
| 74 | ||
| 75 | # get the config id of the desired template |
|
| 76 | if template_abbreviation_mapper.get(template, "-") == name: |
|
| 77 | config_id = cid |
|
| 78 | if debug: |
|
| 79 | print(name + ": " + config_id) |
|
| 80 | break |
|
| 81 | ||
| 82 | # check for existence of the desired config |
|
| 83 | if config_id == "-": |
|
| 84 | print( |
|
| 85 | "error: could not recognize template '%s'" |
|
| 86 | "\nvalid template names are: %s\n" % (template, config_list) |
|
| 87 | ) |
|
| 88 | exit() |
|
| 89 | ||
| 90 | return config_id |
|
| 91 | ||
| 92 | ||
| 93 | def get_target(gmp, debug=False): |
|
| @@ 47-88 (lines=42) @@ | ||
| 44 | return port_names_list |
|
| 45 | ||
| 46 | ||
| 47 | def get_config(gmp, debug=False): |
|
| 48 | # get all configs of the openvas instance |
|
| 49 | res = gmp.get_configs() |
|
| 50 | ||
| 51 | # configurable template |
|
| 52 | template = "fast" |
|
| 53 | ||
| 54 | # match the config abbreviation to accepted config names |
|
| 55 | config_list = [ |
|
| 56 | 'Full and fast', |
|
| 57 | 'Full and fast ultimate', |
|
| 58 | 'Full and very deep', |
|
| 59 | 'Full and very deep ultimate', |
|
| 60 | 'System Discovery', |
|
| 61 | ] |
|
| 62 | template_abbreviation_mapper = { |
|
| 63 | "fast": config_list[0], |
|
| 64 | "fast-ulti": config_list[1], |
|
| 65 | "deep": config_list[2], |
|
| 66 | "deep-ulti": config_list[3], |
|
| 67 | "discovery": config_list[4], |
|
| 68 | } |
|
| 69 | config_id = "-" |
|
| 70 | for conf in res.xpath('config'): |
|
| 71 | cid = conf.xpath('@id')[0] |
|
| 72 | name = conf.xpath('name/text()')[0] |
|
| 73 | ||
| 74 | # get the config id of the desired template |
|
| 75 | if template_abbreviation_mapper.get(template, "-") == name: |
|
| 76 | config_id = cid |
|
| 77 | if debug: |
|
| 78 | print("%s: %s" % (name, config_id)) |
|
| 79 | break |
|
| 80 | # check for existence of the desired config |
|
| 81 | if config_id == "-": |
|
| 82 | print( |
|
| 83 | "error: could not recognize template '%s'\n" |
|
| 84 | "valid template names are: %s\n" % (template, config_list) |
|
| 85 | ) |
|
| 86 | exit() |
|
| 87 | ||
| 88 | return config_id |
|
| 89 | ||
| 90 | ||
| 91 | def get_target(gmp, debug=False): |
|