mirror of https://github.com/MISP/misp-modules
chg: [website] parser view for result
parent
ad6397b294
commit
67a0110ef7
|
@ -2,6 +2,7 @@ from flask import Flask
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from flask_wtf import CSRFProtect
|
from flask_wtf import CSRFProtect
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
|
from flask_session import Session
|
||||||
|
|
||||||
from config import config as Config
|
from config import config as Config
|
||||||
import os
|
import os
|
||||||
|
@ -10,6 +11,7 @@ import os
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
csrf = CSRFProtect()
|
csrf = CSRFProtect()
|
||||||
migrate = Migrate()
|
migrate = Migrate()
|
||||||
|
sess = Session()
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
@ -22,6 +24,8 @@ def create_app():
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
csrf.init_app(app)
|
csrf.init_app(app)
|
||||||
migrate.init_app(app, db, render_as_batch=True)
|
migrate.init_app(app, db, render_as_batch=True)
|
||||||
|
app.config["SESSION_SQLALCHEMY"] = db
|
||||||
|
sess.init_app(app)
|
||||||
|
|
||||||
from .home import home_blueprint
|
from .home import home_blueprint
|
||||||
app.register_blueprint(home_blueprint, url_prefix="/")
|
app.register_blueprint(home_blueprint, url_prefix="/")
|
||||||
|
|
|
@ -50,9 +50,62 @@
|
||||||
|
|
||||||
<!-- Results Part -->
|
<!-- Results Part -->
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row" v-if="Object.keys(modules_res).length">
|
<ul class="nav nav-tabs" style="margin-bottom: 10px;">
|
||||||
<div class="col-10">
|
<li class="nav-item">
|
||||||
<h3 id="results_part">Results</h3>
|
<button class="nav-link active" id="tab-json" aria-current="page" @click="active_tab(true)">Json</button>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<button class="nav-link" id="tab-parser" @click="active_tab(false)">Parser</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<template v-if="json_tab">
|
||||||
|
<div class="row" v-if="Object.keys(modules_res).length">
|
||||||
|
<div class="col-10">
|
||||||
|
<h3 id="results_part">Results</h3>
|
||||||
|
<div class="accordion">
|
||||||
|
<div class="accordion-item" v-for="result, key in modules_res">
|
||||||
|
<template v-if="!('error' in result)">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button" type="button" data-bs-toggle="collapse" :data-bs-target="'#panelsStayOpen-'+key" aria-expanded="true" :aria-controls="'panelsStayOpen-'+key">
|
||||||
|
[[key]]
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div :id="'panelsStayOpen-'+key" class="accordion-collapse collapse show">
|
||||||
|
<div class="accordion-body" v-html="generateCoreFormatUI(result)[0].outerHTML"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Errors Part -->
|
||||||
|
<hr style="margin-top: 50px">
|
||||||
|
<h3 id="errors_part">Errors</h3>
|
||||||
|
<div class="accordion">
|
||||||
|
<div class="accordion-item" v-for="result, key in modules_res">
|
||||||
|
<template v-if="'error' in result">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button" type="button" data-bs-toggle="collapse" :data-bs-target="'#panelsStayOpen-'+key" aria-expanded="true" :aria-controls="'panelsStayOpen-'+key">
|
||||||
|
[[key]]
|
||||||
|
<span style="margin-left: 5px;" title="Error">❌</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div :id="'panelsStayOpen-'+key" class="accordion-collapse collapse show">
|
||||||
|
<div class="accordion-body" v-html="generateCoreFormatUI(result)[0].outerHTML"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-1" style="position: fixed; right: 0px; box-shadow: 0 2px 5px 0 rgb(0 0 0 / 5%), 0 2px 10px 0 rgb(0 0 0 / 5%);">
|
||||||
|
<div style="padding: 10px;"><a style="text-decoration: none;" href="#results_part">Results</a></div>
|
||||||
|
<div style="padding: 10px;"><a style="text-decoration: none;" href="#errors_part">Errors</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<div v-if="Object.keys(modules_res).length">
|
||||||
<div class="accordion">
|
<div class="accordion">
|
||||||
<div class="accordion-item" v-for="result, key in modules_res">
|
<div class="accordion-item" v-for="result, key in modules_res">
|
||||||
<template v-if="!('error' in result)">
|
<template v-if="!('error' in result)">
|
||||||
|
@ -62,36 +115,30 @@
|
||||||
</button>
|
</button>
|
||||||
</h2>
|
</h2>
|
||||||
<div :id="'panelsStayOpen-'+key" class="accordion-collapse collapse show">
|
<div :id="'panelsStayOpen-'+key" class="accordion-collapse collapse show">
|
||||||
<div class="accordion-body" v-html="generateCoreFormatUI(result)[0].outerHTML"></div>
|
<div class="accordion-body row">
|
||||||
|
<template v-for="obj, key_obj in result.results.Object">
|
||||||
|
<h4>Object #[[key_obj+1]] - <small>[[obj.name]]</small></h4>
|
||||||
|
<div class="row" style="margin: 5px; padding: 5px;">
|
||||||
|
<div class="col-4 mb-3" style="border: 1px solid #939393; border-radius: 10px;" v-for="attr, key_attr in obj.Attribute">
|
||||||
|
<h6>Attributes #[[key_attr+1]]</h6>
|
||||||
|
<div>
|
||||||
|
Type: [[attr.type]]
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Value: [[attr.value]]
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- Errors Part -->
|
|
||||||
<hr style="margin-top: 50px">
|
|
||||||
<h3 id="errors_part">Errors</h3>
|
|
||||||
<div class="accordion">
|
|
||||||
<div class="accordion-item" v-for="result, key in modules_res">
|
|
||||||
<template v-if="'error' in result">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" :data-bs-target="'#panelsStayOpen-'+key" aria-expanded="true" :aria-controls="'panelsStayOpen-'+key">
|
|
||||||
[[key]]
|
|
||||||
<span style="margin-left: 5px;" title="Error">❌</span>
|
|
||||||
</button>
|
|
||||||
</h2>
|
|
||||||
<div :id="'panelsStayOpen-'+key" class="accordion-collapse collapse show">
|
|
||||||
<div class="accordion-body" v-html="generateCoreFormatUI(result)[0].outerHTML"></div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-1" style="position: fixed; right: 0px; box-shadow: 0 2px 5px 0 rgb(0 0 0 / 5%), 0 2px 10px 0 rgb(0 0 0 / 5%);">
|
|
||||||
<div style="padding: 10px;"><a style="text-decoration: none;" href="#results_part">Results</a></div>
|
|
||||||
<div style="padding: 10px;"><a style="text-decoration: none;" href="#errors_part">Errors</a></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span id="goTop">[<a href="#top">Go Back Top</a>]</span>
|
<span id="goTop">[<a href="#top">Go Back Top</a>]</span>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -109,6 +156,7 @@
|
||||||
const modules_res = ref({})
|
const modules_res = ref({})
|
||||||
const progress = ref(0)
|
const progress = ref(0)
|
||||||
const status_site = ref()
|
const status_site = ref()
|
||||||
|
const json_tab = ref(true)
|
||||||
|
|
||||||
|
|
||||||
function actionQuery(){
|
function actionQuery(){
|
||||||
|
@ -148,18 +196,35 @@
|
||||||
modules_res.value = loc
|
modules_res.value = loc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function active_tab(is_json){
|
||||||
|
if(is_json){
|
||||||
|
json_tab.value = true
|
||||||
|
if ( !document.getElementById("tab-json").classList.contains("active") ){
|
||||||
|
document.getElementById("tab-json").classList.add("active")
|
||||||
|
document.getElementById("tab-parser").classList.remove("active")
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
json_tab.value = false
|
||||||
|
if ( !document.getElementById("tab-parser").classList.contains("active") ){
|
||||||
|
document.getElementById("tab-parser").classList.add("active")
|
||||||
|
document.getElementById("tab-json").classList.remove("active")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
actionQuery()
|
actionQuery()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message_list,
|
message_list,
|
||||||
progress,
|
progress,
|
||||||
status_site,
|
status_site,
|
||||||
is_searching,
|
is_searching,
|
||||||
modules_res,
|
modules_res,
|
||||||
generateCoreFormatUI
|
json_tab,
|
||||||
|
generateCoreFormatUI,
|
||||||
|
active_tab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).mount('.container')
|
}).mount('.container')
|
||||||
|
|
|
@ -8,6 +8,8 @@ class Config:
|
||||||
class DevelopmentConfig(Config):
|
class DevelopmentConfig(Config):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
SQLALCHEMY_DATABASE_URI = "sqlite:///misp-module.sqlite"
|
SQLALCHEMY_DATABASE_URI = "sqlite:///misp-module.sqlite"
|
||||||
|
SESSION_TYPE = "sqlalchemy"
|
||||||
|
SESSION_SQLALCHEMY_TABLE = "flask_sessions"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def init_app(cls, app):
|
def init_app(cls, app):
|
||||||
|
|
Loading…
Reference in New Issue