refactor eventlog checks
This commit is contained in:
parent
79e3639a82
commit
bcf3cab109
|
@ -41,7 +41,7 @@
|
|||
</q-item-section>
|
||||
<q-item-section>Script Check</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="showAddEventLogCheck = true">
|
||||
<q-item clickable v-close-popup @click="showCheck('add', 'eventlog')">
|
||||
<q-item-section side>
|
||||
<q-icon size="xs" name="fas fa-clipboard-list" />
|
||||
</q-item-section>
|
||||
|
@ -208,6 +208,14 @@
|
|||
:checkpk="checkpk"
|
||||
/>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="showEventLogCheck">
|
||||
<EventLogCheck
|
||||
@close="showEventLogCheck = false"
|
||||
:agentpk="selectedAgentPk"
|
||||
:mode="mode"
|
||||
:checkpk="checkpk"
|
||||
/>
|
||||
</q-dialog>
|
||||
<!-- refactor below -->
|
||||
<!-- script check -->
|
||||
<q-dialog v-model="showAddScriptCheck">
|
||||
|
@ -223,17 +231,6 @@
|
|||
<q-dialog v-model="showScriptOutput">
|
||||
<ScriptOutput @close="showScriptOutput = false; scriptInfo = {}" :scriptInfo="scriptInfo" />
|
||||
</q-dialog>
|
||||
<!-- event log check -->
|
||||
<q-dialog v-model="showAddEventLogCheck">
|
||||
<AddEventLogCheck @close="showAddEventLogCheck = false" :agentpk="selectedAgentPk" />
|
||||
</q-dialog>
|
||||
<q-dialog v-model="showEditEventLogCheck">
|
||||
<EditEventLogCheck
|
||||
@close="showEditEventLogCheck = false"
|
||||
:editCheckPK="editCheckPK"
|
||||
:agentpk="selectedAgentPk"
|
||||
/>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="showEventLogOutput">
|
||||
<EventLogCheckOutput
|
||||
@close="showEventLogOutput = false; evtlogdata = {}"
|
||||
|
@ -252,12 +249,11 @@ import MemCheck from "@/components/modals/checks/MemCheck";
|
|||
import CpuLoadCheck from "@/components/modals/checks/CpuLoadCheck";
|
||||
import PingCheck from "@/components/modals/checks/PingCheck";
|
||||
import WinSvcCheck from "@/components/modals/checks/WinSvcCheck";
|
||||
import EventLogCheck from "@/components/modals/checks/EventLogCheck";
|
||||
// refactor below
|
||||
import AddScriptCheck from "@/components/modals/checks/AddScriptCheck";
|
||||
import EditScriptCheck from "@/components/modals/checks/EditScriptCheck";
|
||||
import ScriptOutput from "@/components/modals/checks/ScriptOutput";
|
||||
import AddEventLogCheck from "@/components/modals/checks/AddEventLogCheck";
|
||||
import EditEventLogCheck from "@/components/modals/checks/EditEventLogCheck";
|
||||
import EventLogCheckOutput from "@/components/modals/checks/EventLogCheckOutput";
|
||||
|
||||
export default {
|
||||
|
@ -268,11 +264,10 @@ export default {
|
|||
CpuLoadCheck,
|
||||
PingCheck,
|
||||
WinSvcCheck,
|
||||
EventLogCheck,
|
||||
AddScriptCheck,
|
||||
EditScriptCheck,
|
||||
ScriptOutput,
|
||||
AddEventLogCheck,
|
||||
EditEventLogCheck,
|
||||
EventLogCheckOutput
|
||||
},
|
||||
mixins: [mixins],
|
||||
|
@ -285,12 +280,11 @@ export default {
|
|||
showCpuLoadCheck: false,
|
||||
showPingCheck: false,
|
||||
showWinSvcCheck: false,
|
||||
showEventLogCheck: false,
|
||||
// refactor below
|
||||
showAddScriptCheck: false,
|
||||
showEditScriptCheck: false,
|
||||
showScriptOutput: false,
|
||||
showAddEventLogCheck: false,
|
||||
showEditEventLogCheck: false,
|
||||
showEventLogOutput: false,
|
||||
editCheckPK: null,
|
||||
scriptInfo: {},
|
||||
|
@ -347,6 +341,9 @@ export default {
|
|||
case "winsvc":
|
||||
this.showWinSvcCheck = true;
|
||||
break;
|
||||
case "eventlog":
|
||||
this.showEventLogCheck = true;
|
||||
break;
|
||||
}
|
||||
},
|
||||
checkAlertAction(pk, category, alert_type, alert_action) {
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
<template>
|
||||
<q-card style="min-width: 40vw">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Add Event Log Check</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
|
||||
<q-form @submit.prevent="addCheck">
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model="desc"
|
||||
label="Descriptive Name"
|
||||
:rules="[ val => !!val || '*Required' ]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
dense
|
||||
outlined
|
||||
v-model="logname"
|
||||
:options="logNameOptions"
|
||||
label="Event log to query"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
dense
|
||||
outlined
|
||||
v-model="failWhen"
|
||||
:options="failWhenOptions"
|
||||
label="Fail When"
|
||||
emit-value
|
||||
map-options
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model.number="eventID"
|
||||
label="Event ID"
|
||||
:rules="[
|
||||
val => !!val.toString() || '*Required',
|
||||
val => val >= 0 || 'Min 0',
|
||||
val => val <= 999999 || 'Max 999999'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model.number="searchLastDays"
|
||||
label="How many previous days to search (Enter 0 for the entire log)"
|
||||
:rules="[
|
||||
val => !!val.toString() || '*Required',
|
||||
val => val >= 0 || 'Min 0',
|
||||
val => val <= 9999 || 'Max 9999'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<span>Event Type:</span>
|
||||
<div class="q-gutter-sm">
|
||||
<q-radio dense v-model="eventType" val="INFO" label="Information" />
|
||||
<q-radio dense v-model="eventType" val="WARNING" label="Warning" />
|
||||
<q-radio dense v-model="eventType" val="ERROR" label="Error" />
|
||||
<q-radio dense v-model="eventType" val="AUDIT_SUCCESS" label="Success Audit" />
|
||||
<q-radio dense v-model="eventType" val="AUDIT_FAILURE" label="Failure Audit" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
outlined
|
||||
dense
|
||||
v-model="failure"
|
||||
:options="failures"
|
||||
label="Number of consecutive failures before alert"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn label="Add" color="primary" type="submit" />
|
||||
<q-btn label="Cancel" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import { mapState } from "vuex";
|
||||
import mixins from "@/mixins/mixins";
|
||||
export default {
|
||||
name: "AddEventLogCheck",
|
||||
props: ["agentpk", "policypk"],
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
desc: null,
|
||||
eventID: 0,
|
||||
eventType: "INFO",
|
||||
logname: "Application",
|
||||
logNameOptions: ["Application", "System", "Security"],
|
||||
failWhen: "contains",
|
||||
searchLastDays: 1,
|
||||
failWhenOptions: [
|
||||
{ label: "Log contains", value: "contains" },
|
||||
{ label: "Log does not contain", value: "not_contains" }
|
||||
],
|
||||
failure: 1,
|
||||
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
addCheck() {
|
||||
const pk = this.policypk ? { policy: this.policypk } : { pk: this.agentpk };
|
||||
|
||||
const data = {
|
||||
...pk,
|
||||
check_type: "eventlog",
|
||||
desc: this.desc,
|
||||
log_name: this.logname,
|
||||
event_id: this.eventID,
|
||||
event_type: this.eventType,
|
||||
fail_when: this.failWhen,
|
||||
search_last_days: this.searchLastDays,
|
||||
failure: this.failure
|
||||
};
|
||||
axios
|
||||
.post("/checks/addstandardcheck/", data)
|
||||
.then(r => {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
this.notifySuccess("Event log check was added!");
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data.desc));
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -1,161 +0,0 @@
|
|||
<template>
|
||||
<q-card style="min-width: 40vw">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Edit Event Log Check</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
|
||||
<q-form @submit.prevent="editCheck">
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model="desc"
|
||||
label="Descriptive Name"
|
||||
:rules="[ val => !!val || '*Required' ]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
dense
|
||||
outlined
|
||||
v-model="logname"
|
||||
:options="logNameOptions"
|
||||
label="Event log to query"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
dense
|
||||
outlined
|
||||
v-model="failWhen"
|
||||
:options="failWhenOptions"
|
||||
label="Fail When"
|
||||
emit-value
|
||||
map-options
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model.number="eventID"
|
||||
label="Event ID"
|
||||
:rules="[
|
||||
val => !!val.toString() || '*Required',
|
||||
val => val >= 0 || 'Min 0',
|
||||
val => val <= 999999 || 'Max 999999'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model.number="searchLastDays"
|
||||
label="How many previous days to search (Enter 0 for the entire log)"
|
||||
:rules="[
|
||||
val => !!val.toString() || '*Required',
|
||||
val => val >= 0 || 'Min 0',
|
||||
val => val <= 9999 || 'Max 9999'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<span>Event Type:</span>
|
||||
<div class="q-gutter-sm">
|
||||
<q-radio dense v-model="eventType" val="INFO" label="Information" />
|
||||
<q-radio dense v-model="eventType" val="WARNING" label="Warning" />
|
||||
<q-radio dense v-model="eventType" val="ERROR" label="Error" />
|
||||
<q-radio dense v-model="eventType" val="AUDIT_SUCCESS" label="Success Audit" />
|
||||
<q-radio dense v-model="eventType" val="AUDIT_FAILURE" label="Failure Audit" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
outlined
|
||||
dense
|
||||
v-model="failure"
|
||||
:options="failures"
|
||||
label="Number of consecutive failures before alert"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn label="Edit" color="primary" type="submit" />
|
||||
<q-btn label="Cancel" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import { mapState } from "vuex";
|
||||
import mixins from "@/mixins/mixins";
|
||||
export default {
|
||||
name: "EditEventLogCheck",
|
||||
props: ["agentpk", "policypk", "editCheckPK"],
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
desc: null,
|
||||
eventID: null,
|
||||
eventType: null,
|
||||
logname: null,
|
||||
logNameOptions: ["Application", "System", "Security"],
|
||||
failWhen: null,
|
||||
searchLastDays: null,
|
||||
failWhenOptions: [
|
||||
{ label: "Log contains", value: "contains" },
|
||||
{ label: "Log does not contain", value: "not_contains" }
|
||||
],
|
||||
failure: null,
|
||||
failures: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getCheck() {
|
||||
axios.get(`/checks/getstandardcheck/eventlog/${this.editCheckPK}/`).then(r => {
|
||||
this.desc = r.data.desc;
|
||||
this.eventID = r.data.event_id;
|
||||
this.eventType = r.data.event_type;
|
||||
this.logname = r.data.log_name;
|
||||
this.failWhen = r.data.fail_when;
|
||||
this.searchLastDays = r.data.search_last_days;
|
||||
this.failure = r.data.failures;
|
||||
});
|
||||
},
|
||||
editCheck() {
|
||||
const data = {
|
||||
pk: this.editCheckPK,
|
||||
check_type: "eventlog",
|
||||
desc: this.desc,
|
||||
log_name: this.logname,
|
||||
event_id: this.eventID,
|
||||
event_type: this.eventType,
|
||||
fail_when: this.failWhen,
|
||||
search_last_days: this.searchLastDays,
|
||||
failures: this.failure
|
||||
};
|
||||
axios
|
||||
.patch("/checks/editstandardcheck/", data)
|
||||
.then(r => {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
this.notifySuccess("Event log check was edited!");
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data.desc));
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCheck();
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,178 @@
|
|||
<template>
|
||||
<q-card style="min-width: 40vw">
|
||||
<q-card-section class="row items-center">
|
||||
<div v-if="mode === 'add'" class="text-h6">Add Event Log Check</div>
|
||||
<div v-else-if="mode === 'edit'" class="text-h6">Edit Event Log Check</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
|
||||
<q-form @submit.prevent="mode === 'add' ? addCheck() : editCheck()">
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model="eventlogcheck.name"
|
||||
label="Descriptive Name"
|
||||
:rules="[ val => !!val || '*Required' ]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
dense
|
||||
outlined
|
||||
v-model="eventlogcheck.log_name"
|
||||
:options="logNameOptions"
|
||||
label="Event log to query"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
dense
|
||||
outlined
|
||||
v-model="eventlogcheck.fail_when"
|
||||
:options="failWhenOptions"
|
||||
label="Fail When"
|
||||
emit-value
|
||||
map-options
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model.number="eventlogcheck.event_id"
|
||||
label="Event ID"
|
||||
:rules="[
|
||||
val => !!val.toString() || '*Required',
|
||||
val => val >= 0 || 'Min 0',
|
||||
val => val <= 999999 || 'Max 999999'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model.number="eventlogcheck.search_last_days"
|
||||
label="How many previous days to search (Enter 0 for the entire log)"
|
||||
:rules="[
|
||||
val => !!val.toString() || '*Required',
|
||||
val => val >= 0 || 'Min 0',
|
||||
val => val <= 9999 || 'Max 9999'
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<span>Event Type:</span>
|
||||
<div class="q-gutter-sm">
|
||||
<q-radio dense v-model="eventlogcheck.event_type" val="INFO" label="Information" />
|
||||
<q-radio dense v-model="eventlogcheck.event_type" val="WARNING" label="Warning" />
|
||||
<q-radio dense v-model="eventlogcheck.event_type" val="ERROR" label="Error" />
|
||||
<q-radio
|
||||
dense
|
||||
v-model="eventlogcheck.event_type"
|
||||
val="AUDIT_SUCCESS"
|
||||
label="Success Audit"
|
||||
/>
|
||||
<q-radio
|
||||
dense
|
||||
v-model="eventlogcheck.event_type"
|
||||
val="AUDIT_FAILURE"
|
||||
label="Failure Audit"
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
outlined
|
||||
dense
|
||||
v-model="eventlogcheck.fails_b4_alert"
|
||||
:options="failOptions"
|
||||
label="Number of consecutive failures before alert"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn v-if="mode === 'add'" label="Add" color="primary" type="submit" />
|
||||
<q-btn v-else-if="mode === 'edit'" label="Edit" color="primary" type="submit" />
|
||||
<q-btn label="Cancel" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import mixins from "@/mixins/mixins";
|
||||
export default {
|
||||
name: "EventLogCheck",
|
||||
props: {
|
||||
agentpk: Number,
|
||||
policypk: Number,
|
||||
mode: String,
|
||||
checkpk: Number
|
||||
},
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
eventlogcheck: {
|
||||
check_type: "eventlog",
|
||||
log_name: "Application",
|
||||
event_id: null,
|
||||
event_type: "INFO",
|
||||
fail_when: "contains",
|
||||
search_last_days: 1,
|
||||
fails_b4_alert: 1
|
||||
},
|
||||
logNameOptions: ["Application", "System", "Security"],
|
||||
failWhenOptions: [
|
||||
{ label: "Log contains", value: "contains" },
|
||||
{ label: "Log does not contain", value: "not_contains" }
|
||||
],
|
||||
failOptions: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getCheck() {
|
||||
axios.get(`/checks/${this.checkpk}/check/`).then(r => (this.eventlogcheck = r.data));
|
||||
},
|
||||
addCheck() {
|
||||
const pk = this.policypk ? { policy: this.policypk } : { pk: this.agentpk };
|
||||
const data = {
|
||||
...pk,
|
||||
check: this.eventlogcheck
|
||||
};
|
||||
axios
|
||||
.post("/checks/checks/", data)
|
||||
.then(r => {
|
||||
this.$emit("close");
|
||||
this.reloadChecks();
|
||||
this.notifySuccess(r.data);
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
editCheck() {
|
||||
axios
|
||||
.patch(`/checks/${this.checkpk}/check/`, this.eventlogcheck)
|
||||
.then(r => {
|
||||
this.$emit("close");
|
||||
this.reloadChecks();
|
||||
this.notifySuccess(r.data);
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.mode === "edit") {
|
||||
this.getCheck();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue