{% load analysis_tags %}

<section id="summary-signatures">
    <h4><i class="fa fa-qrcode"></i> Signatures</h4>

    <div class="cuckoo-analysis__panels">

        {% for signature in report.analysis.signatures %}
            <section class="cuckoo-analysis__panel {% if signature.severity <= 1 %}info{% elif signature.severity == 2 %}warning{% else %}danger{% endif %}">

                <a href="#signature_{{signature.name}}" class="cuckoo-analysis__panel--toggle" data-toggle="collapse">
                    {{signature.description}}
                    {% if signature.marks %}
                        {% if signature.marks|length == 1 %}
                        (1 event)
                        {% elif signature.markcount == signature.marks|length %}
                        ({{ signature.marks|length }} events)
                        {% elif signature.markcount %}
                        ({{ signature.marks|length }} out of {{ signature.markcount }} events)
                        {% else %}
                        ({{ signature.marks|length }} events)
                        {% endif %}
                    {% endif %}
                </a>

                <div class="cuckoo-analysis__panel--body collapse" id="signature_{{signature.name}}">

                    <table class="cuckoo-table">
                        
                        {% for mark in signature.marks|sigsort %}

                            {% if mark.type == "call" %}

                                {% if mark.first %}

                                    <!-- {% if not forloop.first %}
                                        </table>
                                        <table class="cuckoo-table">
                                    {% endif %} -->

                                    <thead>
                                        <tr>
                                            <th>Time &amp; API</th>
                                            <th>Arguments</th>
                                            <th>Status</th>
                                            <th>Return</th>
                                            <th>Repeated</th>
                                        </tr>
                                    </thead><tbody>

                                {% endif %}

                                <tr>
                                    {% include "analysis/pages/behavior/_api_call.html" with call=mark.call pid=mark.pid cid=mark.cid %}
                                </tr>

                            {% elif mark.type == "ioc" %}

                                <tr>
                                    <td>{{ mark.category }}</td>
                                    <td>{{ mark.ioc }}</td>
                                    {% if mark.description %}
                                    <td>{{ mark.description }}</td>
                                    {% endif %}
                                </tr>

                            {% elif mark.type == "generic" %}

                                <tr>
                                    {% for key, value in mark.items %}
                                        {% if key != "type" %}
                                            <td colspan="1">{{ key }}</td>
                                            <td colspan="4">{{ value }}</td>
                                        {% endif %}
                                    {% endfor %}
                                </tr>

                            {% endif %}

                        {% endfor %}

                    </tbody></table>

                </div>
            </section>            
        {% endfor %}

        {% if not report.analysis.signatures %}
            <p>No signatures</p>
        {% endif %}

    </div>

</section>