| @@ 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): |
|
| @@ 38-78 (lines=41) @@ | ||
| 35 | """ |
|
| 36 | ||
| 37 | ||
| 38 | def get_config(gmp, config, debug=False): |
|
| 39 | # get all configs of the openvas instance |
|
| 40 | res = gmp.get_configs() |
|
| 41 | ||
| 42 | # match the config abbreviation to accepted config names |
|
| 43 | config_list = [ |
|
| 44 | 'Full and fast', |
|
| 45 | 'Full and fast ultimate', |
|
| 46 | 'Full and very deep', |
|
| 47 | 'Full and very deep ultimate', |
|
| 48 | 'System Discovery', |
|
| 49 | ] |
|
| 50 | template_abbreviation_mapper = { |
|
| 51 | 0: config_list[0], |
|
| 52 | 1: config_list[1], |
|
| 53 | 2: config_list[2], |
|
| 54 | 3: config_list[3], |
|
| 55 | 4: config_list[4], |
|
| 56 | } |
|
| 57 | ||
| 58 | config_id = "-" |
|
| 59 | for conf in res.xpath('config'): |
|
| 60 | cid = conf.xpath('@id')[0] |
|
| 61 | name = conf.xpath('name/text()')[0] |
|
| 62 | ||
| 63 | # get the config id of the desired template |
|
| 64 | if template_abbreviation_mapper.get(config, "-") == name: |
|
| 65 | config_id = cid |
|
| 66 | if debug: |
|
| 67 | print(name + ": " + config_id) |
|
| 68 | break |
|
| 69 | ||
| 70 | # check for existence of the desired config |
|
| 71 | if config_id == "-": |
|
| 72 | print( |
|
| 73 | "error: could not recognize template '%s'" |
|
| 74 | "\nvalid template names are: %s\n" % (template, config_list) |
|
| 75 | ) |
|
| 76 | exit() |
|
| 77 | ||
| 78 | return config_id |
|
| 79 | ||
| 80 | ||
| 81 | def get_target( |
|