feat: pydantic response schemas for misp endpoints

This commit is contained in:
Chris Milne 2026-05-13 12:42:08 +01:00
parent d81f865ec2
commit 6a9a31b973
4 changed files with 81 additions and 22 deletions

View file

@ -57,6 +57,7 @@ class UI {
this.domain_search_btn = document.getElementById("domain_search_btn")
this.false_positive_actions = document.getElementById("false_positive_actions")
this.false_positive_load_btn = document.getElementById("false_positive_load_btn")
this.event_container = document.getElementById("events_container")
@ -105,12 +106,12 @@ class UI {
render_search_results(results) {
const container = document.getElementById("domain_search_results");
container.innerHTML = "";
const result_count = Object.keys(results).length;
if (!result_count) {
container.innerHTML = `<div class="search-result">No results found.</div>`;
return;
}
container.innerHTML = "";
for (const [key, value] of Object.entries(results)) {
const row = document.createElement("div");
row.className = "search-result";
@ -221,7 +222,7 @@ class UI {
}
render_false_positive_controls(domain_data) {
document.getElementById("false_positive_actions").style.display = "block";
ui.false_positive_actions.style.display = "block";
const always_allow_btn = document.getElementById("always_allow_btn");
always_allow_btn.innerText = domain_data.always_allow ? "Enabled" : "Disabled";
@ -296,7 +297,7 @@ class UI {
ui.set_loading("domain_search_btn", true);
try {
const data = await api.domain_search()
ui.render_search_results(data)
ui.render_search_results(data.domains)
} catch (error) {
console.error(error);
} finally {
@ -306,8 +307,12 @@ class UI {
async load_false_positive_controls(){
ui.set_loading("false_positive_load_btn", true);
ui.false_positive_actions.style.display = "none";
ui.event_container.innerHTML = "";
console.log(".")
try {
const data = await api.load_domain_fp()
if(!data){return;}
const parsed_data= {
domain: data.domain,
always_allow: data.always_allowed,
@ -317,7 +322,6 @@ class UI {
data.events.forEach(event => {
parsed_data.events.push({"id": event, "ignored": data.ignored_events.includes(event)});
})
ui.render_false_positive_controls(parsed_data)
} catch (error) {
console.error(error);