<!-- Faraday Penetration Test IDE -->
<!-- Copyright (C) 2013  Infobyte LLC (http://www.infobytesec.com/) -->
<!-- See the file 'doc/LICENSE' for the license information -->

<form name="formEdit" novalidate>
    <div class="modal-header">
        <div class="modal-button">
            <button class="btn btn-success" ng-click="modal.ok()" ng-disabled="formEdit.$invalid || modal.data.severity === undefined">OK</button>
            <button class="btn btn-danger" ng-click="modal.cancel()">Cancel</button>
        </div>
        <h3 class="modal-title">Vuln edit</h3>
    </div>
    <div class="modal-body">
        <div class="form-horizontal">
            <div class="form-group">
                <div class="col-md-12">
                    <h5>Vulnerability template</h5>
                    <input type="text" ng-model="modal.cwe_selected" class="form-control input-sm" placeholder="Search for vulnerability template" uib-typeahead="cwe as cwe.name for cwe in modal.cweList | filter:{name: $viewValue} | limitTo:10" typeahead-on-select="modal.populate($item, $model, $label)">
                </div>
            </div>
            <div class="form-group">
                 <div class="col-md-3 severities">
                    <h5>Severity</h5>
                    <button type="button" class="btn btn-default dropdown-toggle color-{{modal.data.severity}}" name="severity" data-toggle="dropdown" title="Change severity" ng-class="{'button-error': modal.data.severity === undefined}">
                    {{modal.data.severity || 'Edit severity'}} <span class="caret" style="color:#000"></span>
                    </button>
                    <ul id="nav" class="dropdown-menu dropdown-menu-left" role="menu">
                        <li ng-repeat="s in modal.severities"><a href="" class="ws color-{{s}}" ng-click="modal.data.severity=s">{{s}}</a></li>
                    </ul><!-- WS navigation -->
                </div>
                <div class="col-md-3">
                    <h5>Ease of Resolution</h5>
                    <select class="form-control" ng-model="modal.data.easeofresolution" ng-options="e as e for e in modal.easeofresolution">
                        <option value=""></option>
                    </select>
                </div>
                <div class="col-md-3">
                    <h5>Status</h5>
                    <select class="form-control" ng-model="modal.data.status" ng-options="e as e for e in modal.statuses">
                        <option value=""></option>
                    </select>
                </div>
                <div class="col-md-3">
                    <h5>Confirmed</h5>
                    <input type="checkbox" id="confirmed" ng-model="modal.data.confirmed" />
                    <span class="normal-size">Confirmed</span>
                </div>
            </div><!-- .form-group -->
            <div class="form-group" ng-class="{'has-error': formEdit.name.$invalid }">
                <div class="col-md-12">
                    <label class="sr-only" for="vuln-name">Vuln name</label>
                    <input type="text" class="form-control" id="vuln-name" name="name" placeholder="Name" ng-model="modal.data.name" required/>
                </div>
            </div><!-- .form-group -->
            <div class="form-group" ng-class="{'has-error': formEdit.desc.$invalid }">
                <div class="col-md-12">
                    <label class="sr-only" for="vuln-desc">Vuln description</label>
                    <textarea class="form-control" id="vuln-desc" name="desc" placeholder="Description" ng-model="modal.data.desc" required></textarea>
                </div>
            </div><!-- .form-group -->
            <div class="form-group">
                <div class="col-md-12">
                    <label class="sr-only" for="vuln-data">Vuln data</label>
                    <textarea class="form-control" id="vuln-data" placeholder="Data" ng-model="modal.data.data"></textarea>
                </div>
            </div><!-- .form-group -->
            <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group margin-bottom-sm">
                        <label class="sr-only" for="vuln-refs">References</label>
                        <input type="text" class="form-control" id="vuln-refs" placeholder="Reference" ng-model="modal.new_ref"/>
                        <span class="input-group-addon cursor" ng-click="modal.newReference()"><i class="fa fa-plus-circle"></i></span>
                    </div>
                </div>
                <div class="col-md-12 reference" ng-repeat="reference in modal.data.refs">
                    <div class="input-group margin-bottom-sm">
                        <label class="sr-only" for="vuln-refs">References</label>
                        <input type="text" class="form-control" id="vuln-refs" placeholder="Reference" ng-model="reference.value" disabled/>
                        <span class="input-group-addon cursor" ng-click="modal.data.refs.splice($index, 1)"><i class="fa fa-minus-circle"></i></span>
                    </div>
                </div>
            </div><!-- .form-group -->
            <div class="form-group">
                <div class="col-md-12">
                    <label class="sr-only" for="vuln-resolution">Vuln Resolution</label>
                    <textarea class="form-control" id="vuln-resolution" placeholder="Resolution" ng-model="modal.data.resolution"></textarea>
                </div>
            </div><!-- .form-group -->
                        <div class="form-group">
                <div class="col-md-12">
                    <div class="input-group margin-bottom-sm">
                        <label class="sr-only" for="vuln-policyviolations">Policy Violations</label>
                        <input type="text" class="form-control" id="vuln-policyviolations" placeholder="Policy Violations" ng-model="modal.new_policyviolation"/>
                        <span class="input-group-addon cursor" ng-click="modal.newPolicyViolation()"><i class="fa fa-plus-circle"></i></span>
                    </div>
                </div>
                <div class="col-md-12 reference" ng-repeat="policyviolation in modal.data.policyviolations">
                    <div class="input-group margin-bottom-sm">
                        <label class="sr-only" for="vuln-policyviolations">Policy Violation</label>
                        <input type="text" class="form-control" id="vuln-policyviolations" placeholder="Policy Violation" ng-model="policyviolation.value" disabled/>
                        <span class="input-group-addon cursor" ng-click="modal.data.policyviolations.splice($index, 1)"><i class="fa fa-minus-circle"></i></span>
                    </div>
                </div>
            </div><!-- .form-group -->
            <div ng-if="modal.vuln.type === 'VulnerabilityWeb'">
                <div class="form-group">
                    <div class="col-md-4">
                        <label class="sr-only control-label" for="vuln-method">Method</label>
                        <input type="text" class="form-control input-error" id="vuln-method" placeholder="Method" ng-model="modal.data.method"/>
                    </div>
                    <div class="col-md-3">
                        <label class="sr-only control-label" for="vuln-pname">Param Name</label>
                        <input type="text" class="form-control input-error" id="vuln-pname" placeholder="Param name" ng-model="modal.data.pname"/>
                    </div>
                    <div class="col-md-5">
                        <label class="sr-only control-label" for="vuln-params">Params</label>
                        <input type="text" class="form-control input-error" id="vuln-params" placeholder="Params" ng-model="modal.data.params"/>
                    </div>
                </div><!-- .form-group -->
                <div class="form-group">
                    <div class="col-md-4">
                        <label class="sr-only control-label" for="vuln-path">Path</label>
                        <input type="text" class="form-control input-error" id="vuln-path" placeholder="Path" ng-model="modal.data.path"/>
                    </div>
                    <div class="col-md-4">
                        <label class="sr-only control-label" for="vuln-query">Query</label>
                        <input type="text" class="form-control input-error" id="vuln-query" placeholder="Query" ng-model="modal.data.query"/>
                    </div>
                    <div class="col-md-4">
                        <label class="sr-only control-label" for="vuln-website">Website</label>
                        <input type="text" class="form-control input-error" id="vuln-website" placeholder="Website" ng-model="modal.data.website"/>
                    </div>
                </div><!-- .form-group -->
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="sr-only control-label" for="vuln-request">Request</label>
                        <textarea class="form-control input-error" id="vuln-request" placeholder="Request" ng-model="modal.data.request"></textarea>
                    </div>
                </div><!-- .form-group -->
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="sr-only control-label" for="vuln-response">Response</label>
                        <textarea class="form-control input-error" id="vuln-response" placeholder="Response" ng-model="modal.data.response"></textarea>
                    </div>
                </div><!-- .form-group -->
            </div><!-- ng-if -->
        </div><!-- .form-horizontal -->

        <h4>Impact</h4>
        <div ng-repeat="(key, value) in modal.data.impact" class="normal-size" style="cursor: pointer;">
            <h4><span ng-class="{'label label-default': !value, 'label label-success': value}" ng-click="modal.toggleImpact(key)">{{key}}</span></h4>
        </div><!-- .normal-size -->

        <div>
            <h4>Evidence</h4>
            <div class="alert alert-danger normal-size" role="alert" ng-if="modal.file_name_error">
              <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
              <span class="sr-only">Error:</span>
              Cannot upload evidence starting with underscore, please choose a different name for the file.
            </div>
            <div class="form-group normal-size">
                <input type="file" id="evidence" ng-file-select ng-multiple="true" resetOnClick="false" ng-file-change="modal.selectedFiles($files, $event)"/>
                <p class="help-block">Multiple files are allowed.</p>
            </div><!-- .form-group -->
            <div id="evidenceFiles" class="normal-size" ng-if="modal.data._attachments">
                <ul>
                    <li ng-repeat="(name, file) in modal.data._attachments">
                        <div class="btn-group">
                            <button type="button" class="btn btn-default">
                                <span class="fa {{icons[name]}}" title="Evidence {{name | decodeURIComponent}}"></span> {{name | decodeURIComponent}}
                            </button><!-- ng-repeat -->
                            <button type="button" class="btn btn-danger" ng-click="modal.removeEvidence(name)">
                                <span class="glyphicon glyphicon-trash"></span>
                            </button>
                        </div>
                    </li>
                </ul>
            </div><!-- #evidenceFiles -->
        </div><!-- ng-if -->
    <div class="modal-footer">
        <div class="modal-button">
            <button class="btn btn-success" ng-click="modal.ok()" ng-disabled="formEdit.$invalid">OK</button>
            <button class="btn btn-danger" ng-click="modal.cancel()">Cancel</button>
        </div>
    </div>
</form>
