递归进行分析是否存在key被获取
(res, k="", skeys: list=[], s="")
| 1 | |
| 2 | def rec_search_key(res, k="", skeys: list=[], s=""): |
| 3 | '''递归进行分析是否存在key被获取''' |
| 4 | if isinstance(res, dict): |
| 5 | for new_k, v in res.items(): |
| 6 | try: |
| 7 | skeys = rec_search_key(v, ".".join([str(k), str(new_k)]) if k else new_k, skeys, s) |
| 8 | except Exception as e: |
| 9 | print(res, k, new_k) |
| 10 | raise e |
| 11 | elif isinstance(res, list): |
| 12 | for i in res: |
| 13 | skeys = rec_search_key(i, k + ".list", skeys, s) |
| 14 | else: |
| 15 | if str(res) in str(s): |
| 16 | skeys.append(k[:-5] if k[-5:] == ".list" else k) |
| 17 | return list(set(skeys)) |
| 18 | return list(set(skeys)) |
| 19 | |
| 20 | |
| 21 |
no outgoing calls
no test coverage detected