{% extends "layout.html" %}
{% block title %}
AWS Vulnerability Test
{% endblock %}
{% block content %}
<script type='text/javascript'>
    $(function(){
		$(document).ready(function(){
            var socket = io.connect("http://" + document.domain + ":" + location.port + "/awstest")
            socket.on('connect', function(){
                var package_name = document.baseURI.substring(document.baseURI.lastIndexOf("/")+1);
                socket.emit("awstest_start", {"package_name":package_name});
            });
            socket.on("log", function(data){
                $("#aws_log").append(data['msg']+"<br>");
            });
            socket.on("manual_log", function(data){
                $("#aws_manual_log").append(data.data+"<br>");
            });
            $("#cmd_form").on("keyup", function(e){
                if(e.keyCode == 13){
                    $("#aws_manual_log").append("<br><p class='text-success'>$ "+$(this).val()+"</p>");
                    socket.emit("manual_log_cmd", {"data":$(this).val()});
                    $(this).val("");
                }
            });
        });
	});
</script>
<div class="container-fluid" style="font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;">
	<ol class="breadcrumb">
		<li class="breadcrumb-item">
			<a href="#">Instruction</a>
		</li>
		<li class="breadcrumb-item">
            <a href="{{ url_for('assets_layout') }}">Assets</a>
        </li>
        <li class="breadcrumb-item active">Analyze</li>
        <li class="breadcrumb-item active">AWS Vulnerability Test</li>
    </ol>
    <div class="card mb-3">
        <div class="card-header">
            <i class="fas fa-cloud"></i>
            Service List
        </div>
        <div class="card-body">
            {% for path in services %}
                <img src="{{ path }}" alt="">
            {% endfor %}
        </div>
    </div>
    <div class="card mb-3">
        <div class="card-header">
            <i class="fas fa-cloud"></i>
            AWS Vulnerability Test
        </div>
        <div class="card-body">
            <p id="aws_log">

            </p>
        </div>
    </div>
    <div class="card mb-3">
        <div class="card-header">
            AWS Manual Test
        </div>
        <div class="card-body overflow-auto">
            <p id="aws_manual_log" style="height: 40vh;">

            </p>
        </div>
        <div class="card-footer">
            <div class="input-group">
				<input type="text" class="form-control" placeholder="ex) aws s3 ls s3://bucketname" spellcheck="false" id="cmd_form">
			</div>
        </div>
    </div>
</div>
{% endblock %}