(self, software: Optional['Software'], for_server: bool = True)
| 109 | return timeframe |
| 110 | |
| 111 | def get_recommendations(self, software: Optional['Software'], for_server: bool = True) -> Tuple[Optional['Software'], Dict[int, Dict[str, Dict[str, Dict[str, int]]]]]: |
| 112 | # pylint: disable=too-many-locals,too-many-statements |
| 113 | vproducts = [Product.OpenSSH, |
| 114 | Product.DropbearSSH, |
| 115 | Product.LibSSH, |
| 116 | Product.TinySSH] |
| 117 | # Set to True if server is not one of vproducts, above. |
| 118 | unknown_software = False |
| 119 | if software is not None: |
| 120 | if software.product not in vproducts: |
| 121 | unknown_software = True |
| 122 | |
| 123 | # The code below is commented out because it would try to guess what the server is, |
| 124 | # usually resulting in wild & incorrect recommendations. |
| 125 | # if software is None: |
| 126 | # ssh_timeframe = self.get_ssh_timeframe(for_server) |
| 127 | # for product in vproducts: |
| 128 | # if product not in ssh_timeframe: |
| 129 | # continue |
| 130 | # version = ssh_timeframe.get_from(product, for_server) |
| 131 | # if version is not None: |
| 132 | # software = SSH.Software(None, product, version, None, None) |
| 133 | # break |
| 134 | rec: Dict[int, Dict[str, Dict[str, Dict[str, int]]]] = {} |
| 135 | if software is None: |
| 136 | unknown_software = True |
| 137 | for alg_pair in self.values: |
| 138 | sshv, alg_db = alg_pair.sshv, alg_pair.db |
| 139 | rec[sshv] = {} |
| 140 | for alg_type, alg_list in alg_pair.items(): |
| 141 | if alg_type == 'aut': |
| 142 | continue |
| 143 | rec[sshv][alg_type] = {'add': {}, 'del': {}, 'chg': {}} |
| 144 | for n, alg_desc in alg_db[alg_type].items(): |
| 145 | versions = alg_desc[0] |
| 146 | empty_version = False |
| 147 | if len(versions) == 0 or versions[0] is None: |
| 148 | empty_version = True |
| 149 | else: |
| 150 | matches = False |
| 151 | if unknown_software: |
| 152 | matches = True |
| 153 | for v in versions[0].split(','): |
| 154 | ssh_prefix, ssh_version, is_cli = Algorithm.get_ssh_version(v) |
| 155 | if not ssh_version: |
| 156 | continue |
| 157 | if (software is not None) and (ssh_prefix != software.product): |
| 158 | continue |
| 159 | if is_cli and for_server: |
| 160 | continue |
| 161 | if (software is not None) and (software.compare_version(ssh_version) < 0): |
| 162 | continue |
| 163 | matches = True |
| 164 | break |
| 165 | if not matches: |
| 166 | continue |
| 167 | adl, faults = len(alg_desc), 0 |
| 168 | for i in range(1, 3): |
no test coverage detected