output_html.html 5.11 KB
Newer Older
1 2 3 4 5 6 7 8
{% macro safebrowsing(domain, state) -%}
    {# icon depending on the Safebrowsing online diagnostics state  #}
    {% if state is not none -%}
        <a class='safebrowsing-status'
           href='http://www.google.com/safebrowsing/diagnostic?site={{ domain }}'>{{ {"1":"!", "0":"☀", "":"‽"}[state] }}</a>
    {%- endif %}
{%- endmacro %}

Edvard Rejthar's avatar
Edvard Rejthar committed
9
{% macro shortenable(l, class, max, href_prepend="") -%}
10 11 12 13 14 15
    {# if list is longer than 15, print out first 10 and tell that there is another X hidden #}
    {% if l|length > max -%}
        {% set i = max*2/3|int %}
        {% set text = l|length - i %}
        {% set l = l[:(max*2/3)|int] %}
    {% endif %}
Edvard Rejthar's avatar
Edvard Rejthar committed
16
    <span data-length='{{ l|length }}' class={{ class }}>
17
        {% for el in l -%}
Edvard Rejthar's avatar
Edvard Rejthar committed
18 19 20 21 22
            {% if href_prepend -%}
                <a href="{{ href_prepend }}{{ el }}">{{ el }}</a>
            {% else %}
                <span>{{ el }}</span>
            {%- endif %}
23 24 25 26 27 28 29 30 31 32 33
        {%- endfor %}
        {% if text -%}
            ... ({{ text|int }})
        {%- endif %}
        </span>
{%- endmacro %}

<div class="row">
    <div class='col-sm-8 analysis' data-host='{{ output["host"] }}' data-sfb='{{ output["sfb"] }}'>
        <form>
            <h2>{{ output["title"] }}</h2>
Edvard Rejthar's avatar
Edvard Rejthar committed
34 35 36
            {% if output["paging"] %}
                <div class="pagination" data-pages="{{ output["paging"] }}"></div>
            {% endif %}
Edvard Rejthar's avatar
Edvard Rejthar committed
37

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
            {{ safebrowsing(output["host"], output["sfb"]) }}
            {% if output["scans"] -%}
                <div class="scans">
                    {% for scan in output["scans"] -%}
                        <span data-scan="{{ scan }}">{{ scan|format_datetime }}</span>
                    {%- endfor %}
                </div>
            {% endif %}


            {% for vote in ["block", "log", "suspicious", "n/a", "allow"] -%}
                <div data-group="{{ vote }}">
                    {% for domain in output["domains"][vote].values() -%}
                        <div class=web data-vote='{{ domain["vote"] }}' data-sfb='{{ domain["sfb"] }}'>
                            {{ safebrowsing(domain["domain"], domain["sfb"]) }}

                            <span class='voting'>
                            {% for val in ["block", "log", "n/a", "allow"] -%}
                                <input type=radio name='{{ domain["domain"] }}' value='{{ val }}'
                                       {% if val == domain["vote"] %}checked{% endif %}/>
                            {% endfor %}
                                <label>{{ domain["vote"] }}</label>
                        </span>
                            <span class=domain>{{ domain["domain"] }}</span>
                            <div class=addresses>
                                {% for address_name, address in domain["addresses"].items() -%}
                                    <span class=ip>{{ address_name }}
                                        {% if address.country -%}}
                                            <span class=country>{{ address.country }}</span>
                                        {% endif %}
                                        {% if address.city -%}}
                                            <span class=city>{{ address.city }}</span>
                                        {% endif %}
                                    </span>
                                {% endfor %}
Edvard Rejthar's avatar
Edvard Rejthar committed
73
                                {{ shortenable(domain["related"], "related", 15, "api=html/scan=") }}
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
                                {# # XX PDNS link nelze dát, protože je tolik linku, kolik IP ma navstiveny host. Lze udelat, ze odkaz povede na vypis vsech domen. XDomains.get_pdns_link(crawl[domain]) #}
                                {{ shortenable(domain["pdns"], "pdns", 15) }}
                            </div>
                            <ul class=urls>
                                {% for url_name, url in domain["urls"].items() -%}
                                    <li>
                                        <span class='value'>{{ url_name }}</span>
                                        {% for spyfile in url["spyfiles"].values() -%}
                                            <div class='spyfile'>{{ spyfile["text"]|safe }}</div>
                                            {% if spyfile["full-link"] -%}
                                                <a href='{{ spyfile["full-link"] }}' class='spyfile-full'>-></a>
                                            {%- endif %}

                                        {%- endfor %}


                                        {% for link in url["sourcefiles"] -%}
                                            <a href='{{ link }}' class='sourcefile'></a>
                                        {%- endfor %}
                                    </li>
                                {%- endfor %}
                            </ul>
                        </div>
                    {%- endfor %}
                </div>
            {%- endfor %}
        </form>
    </div>
    {% if output["screenfile"] %}
        <div class="col-sm-4 screenshot">
            <img class='thumbnail' src='data:image/png;base64,{{ output["screenfile"] }}'/>
        </div>
    {% endif %}
</div>