{% extends "base.html" %}

{% block title %}Audit{% endblock %}

{% block headerEnd %}
<script src="{{ url_for('static', filename='audit_selector.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}


{% block content %}
    <h1>Audit</h1>

    <h3>Regular workflow</h3>

    <ol>
        <li>Create Audit in <a href="/audits">PwnDoc</a></li>
        <li>Refresh this page and select it in the selector:
            <select name="audit" id="audit">

                {% for key, value in audit_dict.items()|reverse%}
                    <option value="{{value}}" {{"selected" if audit_id == value else ""}}>{{key}}</option>
                {% endfor %}

            </select>

        </li>
        <li><a href="#" url="{{ url_for('api_process_findings.upload_scanner_result_get', audit_id="AUDIT_ID_PLACEHOLDER")}}" onclick="audit_specific_event(this);">Import scan results using scan2report</a> </li>
        <li>Go to <a href="/audits">PwnDoc</a> and work on the audit</li>
        <li>When you "finish" a new finding that didn't have a prepared template, save the finding and also click button "Propose Creation / Update in Vulnerability Database". After the creation/update is accepted, it will be available for reuse during next imports.</li>
        <li>When audit is ready, trigger <a href="#" url="{{ url_for('api_process_findings.force_upload_services', audit_id="AUDIT_ID_PLACEHOLDER")}}" onclick="audit_specific_event(this);">this workaround for a bug</a> (re-uploads services for the table of open-ports)</li>
        <li>After that you can download the docx report in PwnDoc, or if it times-out, you can <a href="#" url="{{ url_for('api_pwndoc_audit.report_download', audit_id="AUDIT_ID_PLACEHOLDER")}}" onclick="audit_specific_event(this);">extend the download time</a>.</li>
        <li>If you need the findings in machine readable format, you can download them here -
            <a href="#" url="{{ url_for('api_pwndoc_audit.export_findings', audit_id="AUDIT_ID_PLACEHOLDER", file_format='json')}}" onclick="audit_specific_event(this);">JSON</a>,
            <a href="#" url="{{ url_for('api_pwndoc_audit.export_findings', audit_id="AUDIT_ID_PLACEHOLDER", file_format='csv')}}" onclick="audit_specific_event(this);">CSV</a>.
        </li>
    </ol>

    <br>
    <h3>Other actions</h3>

    <p>
        PwnDoc audit doesn't contain just findings, but also text sections (e.g. executive summary). These can also be
        <a href="#" url="{{ url_for('api_pwndoc_audit.export_audit_raw', audit_id="AUDIT_ID_PLACEHOLDER")}}" onclick="audit_specific_event(this);">downloaded as JSON</a>, though beware that the structure of the the JSON is somewhat complicated.
    </p>

    <p>
        If you've modified some of the
        <a href="{{ url_for('api_root.json_editor')}}">scan2report config files</a>
        (for example groups.json), you can
        <a href="#" url="{{ url_for('api_debug.show_newly_grouped_or_aliased_findings', audit_id="AUDIT_ID_PLACEHOLDER")}}" onclick="audit_specific_event(this);">check</a>
        whether a reimport would change the audit. If it would, you can from delete the relevant findings from that view, and then perform a new import.
        <br>
        Importer performs two types of grouping:
        <ul>
            <li>using scan2report based groups.json - this grouping happens independently in each import</li>
            <li>based on identical FID. During each import the Importer downloads findings from PwnDoc and if there already is a finding with a given FID, it will check whether the newly imported finding contains some new affected hosts.
                If it does, it will append the new PoC to the original one. If it does not, it will not overwrite the original finding.
            </li>
        </ul>
    </p>


{% endblock %}