File: options.py

package info (click to toggle)
mitmproxy 8.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 38,952 kB
  • sloc: python: 53,389; javascript: 1,603; xml: 186; sh: 105; ansic: 68; makefile: 13
file content (59 lines) | stat: -rwxr-xr-x 1,578 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import asyncio

from mitmproxy import options, optmanager
from mitmproxy.tools import dump, console, web

masters = {
    "mitmproxy": console.master.ConsoleMaster,
    "mitmdump": dump.DumpMaster,
    "mitmweb": web.master.WebMaster,
}

unified_options = {}


async def dump():
    for tool_name, master in masters.items():
        opts = options.Options()
        _ = master(opts)
        for key, option in optmanager.dump_dicts(opts).items():
            if key in unified_options:
                unified_options[key]["tools"].append(tool_name)
            else:
                unified_options[key] = option
                unified_options[key]["tools"] = [tool_name]


asyncio.run(dump())

print(
    """
      <table class=\"table optiontable\">
        <thead>
          <tr>
            <th>Name</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
        </thead>
        <tbody>
      """.strip()
)
for key, option in sorted(unified_options.items(), key=lambda t: t[0]):
    print(
        f"""
          <tr id="{key}">
          <th>
            <a class="anchor" href="#{key}">#&nbsp;&nbsp;</a>
            {key}<br/>
            {' '.join(["<span class='badge'>{}</span>".format(t) for t in option['tools']])}</th>
          <td>{option['type']}</td>
          <td>{option['help']}<br/>
            Default: {option['default']}
            {"<br/>Choices: {}".format(', '.join(option['choices'])) if option['choices'] else ""}
          </td>
          </tr>
          """.strip()
    )
print("</tbody></table>")