From 2193d214c7b9fd7cbdeab94bbbf65994cf851617 Mon Sep 17 00:00:00 2001
From: Javier Marcos <1271349+javuto@users.noreply.github.com>
Date: Fri, 18 Oct 2024 17:23:05 +0200
Subject: [PATCH] Modal in osctrl-admin to add a new query to schedule
---
admin/static/js/configuration.js | 23 ++++++++++++
admin/templates/components/page-modals.html | 41 +++++++++++++++++++++
admin/templates/conf.html | 8 +++-
admin/templates/tags.html | 2 +-
logging/process.go | 6 +--
5 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/admin/static/js/configuration.js b/admin/static/js/configuration.js
index 5bd3ac4c..f00c30c3 100644
--- a/admin/static/js/configuration.js
+++ b/admin/static/js/configuration.js
@@ -37,6 +37,29 @@ function saveATC() {
saveB64Blob('atc_conf', 'atc', 'atc_header');
}
+function addQuerySchedule() {
+ $("#addquery_action").click(function () {
+ $("#addQueryModal").modal("hide");
+ confirmAddQuerySchedule();
+ });
+ $("#query_name").val("");
+ $("#query_sql").val("");
+ $("#query_interval").val("");
+ $("#addQueryModal").modal();
+}
+
+function confirmAddQuerySchedule() {
+ var _editor = $("#schedule_conf").data("CodeMirrorInstance");
+ var _schedule = _editor.getValue();
+ var obj = JSON.parse(_schedule);
+ var _query = {
+ "query": $("#query_sql").val(),
+ "interval": parseInt($("#query_interval").val()),
+ };
+ obj[$("#query_name").val()] = _query;
+ _editor.setValue(JSON.stringify(obj, null, "\t"));
+}
+
function saveIntervals() {
var _csrftoken = $("#csrftoken").val();
var _config = $("#conf_range").val();
diff --git a/admin/templates/components/page-modals.html b/admin/templates/components/page-modals.html
index 6a122247..67ffc9da 100644
--- a/admin/templates/components/page-modals.html
+++ b/admin/templates/components/page-modals.html
@@ -182,4 +182,45 @@
Upload new certificate
+
+
+
{{ end }}
diff --git a/admin/templates/conf.html b/admin/templates/conf.html
index b5f965fb..29566156 100644
--- a/admin/templates/conf.html
+++ b/admin/templates/conf.html
@@ -116,6 +116,10 @@
data-tooltip="true" data-placement="bottom" title="Documentation" onclick="javascript:window.open('https://osquery.readthedocs.io/en/stable/deployment/configuration/#schedule', '_blank');">
+