Returns a dictionary containing the messages in the "fail", "warn", and "info" levels for this algorithm.
(algorithm: str, alg_type: str)
| 1018 | def build_struct(target_host: str, banner: Optional['Banner'], kex: Optional['SSH2_Kex'] = None, pkm: Optional['SSH1_PublicKeyMessage'] = None, client_host: Optional[str] = None, software: Optional[Software] = None, algorithms: Optional[Algorithms] = None, algorithm_recommendation_suppress_list: Optional[List[str]] = None, additional_notes: List[str] = []) -> Any: # pylint: disable=dangerous-default-value |
| 1019 | |
| 1020 | def fetch_notes(algorithm: str, alg_type: str) -> Dict[str, List[Optional[str]]]: |
| 1021 | '''Returns a dictionary containing the messages in the "fail", "warn", and "info" levels for this algorithm.''' |
| 1022 | alg_db = SSH2_KexDB.get_db() |
| 1023 | alg_info = {} |
| 1024 | if algorithm in alg_db[alg_type]: |
| 1025 | alg_desc = alg_db[alg_type][algorithm] |
| 1026 | alg_desc_len = len(alg_desc) |
| 1027 | |
| 1028 | # If a list for the failure notes exists, add it to the return value. Similarly, add the related lists for the warnings and informational notes. |
| 1029 | if (alg_desc_len >= 2) and (len(alg_desc[1]) > 0): |
| 1030 | alg_info["fail"] = alg_desc[1] |
| 1031 | if (alg_desc_len >= 3) and (len(alg_desc[2]) > 0): |
| 1032 | alg_info["warn"] = alg_desc[2] |
| 1033 | if (alg_desc_len >= 4) and (len(alg_desc[3]) > 0): |
| 1034 | alg_info["info"] = alg_desc[3] |
| 1035 | |
| 1036 | # Add information about when this algorithm was implemented in OpenSSH/Dropbear. |
| 1037 | since_text = Algorithm.get_since_text(alg_desc[0]) |
| 1038 | if (since_text is not None) and (len(since_text) > 0): |
| 1039 | # Add the "info" key with an empty list if the if-block above didn't create it already. |
| 1040 | if "info" not in alg_info: |
| 1041 | alg_info["info"] = [] |
| 1042 | alg_info["info"].append(since_text) |
| 1043 | else: |
| 1044 | alg_info["fail"] = [SSH2_KexDB.FAIL_UNKNOWN] |
| 1045 | |
| 1046 | return alg_info |
| 1047 | |
| 1048 | banner_str = '' |
| 1049 | banner_protocol = None |
no test coverage detected