mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
add security loop
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import type { } from '#ui/types/tabs'
|
|
||||||
|
|
||||||
definePageMeta({ layout: 'dashboard' });
|
definePageMeta({ layout: 'dashboard' });
|
||||||
const activeProjectId = useActiveProjectId();
|
const activeProjectId = useActiveProjectId();
|
||||||
|
|
||||||
|
|||||||
3
security/.env.example
Normal file
3
security/.env.example
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
MONGO_CONNECTION_STRING=
|
||||||
|
EMAIL_SERVICE=
|
||||||
|
BREVO_API_KEY=
|
||||||
3
security/.gitignore
vendored
3
security/.gitignore
vendored
@@ -4,4 +4,5 @@ ecosystem.config.cjs
|
|||||||
dist
|
dist
|
||||||
start_dev.js
|
start_dev.js
|
||||||
package-lock.json
|
package-lock.json
|
||||||
build_all.bat
|
build_all.bat
|
||||||
|
.env
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { anomalyCheckAll, AnomalyReport, findAnomalies } from "./AnomalyService";
|
import { anomalyLoop } from "./AnomalyService";
|
||||||
import { connectDatabase } from '@services/DatabaseService'
|
import { connectDatabase } from '@services/DatabaseService'
|
||||||
import { requireEnv } from '@utils/requireEnv'
|
import { requireEnv } from '@utils/requireEnv'
|
||||||
|
|
||||||
@@ -10,37 +10,18 @@ import { UserModel } from "@schema/UserSchema";
|
|||||||
EmailService.init(requireEnv('BREVO_API_KEY'));
|
EmailService.init(requireEnv('BREVO_API_KEY'));
|
||||||
connectDatabase(requireEnv('MONGO_CONNECTION_STRING'));
|
connectDatabase(requireEnv('MONGO_CONNECTION_STRING'));
|
||||||
|
|
||||||
anomalyCheckAll(async report => {
|
|
||||||
|
|
||||||
|
|
||||||
|
anomalyLoop(async report => {
|
||||||
if (report.visits.length > 0 || report.events.length > 0 || report.dns.length > 0) {
|
if (report.visits.length > 0 || report.events.length > 0 || report.dns.length > 0) {
|
||||||
|
|
||||||
const project = await ProjectModel.findById(report.pid);
|
const project = await ProjectModel.findById(report.pid);
|
||||||
if (!project) return { ok: false, error: 'Cannot find project with id ' + report.pid.toString() }
|
if (!project) return { ok: false, error: 'Cannot find project with id ' + report.pid.toString() }
|
||||||
const user = await UserModel.findById(project.owner);
|
const user = await UserModel.findById(project.owner);
|
||||||
if (!user) return { ok: false, error: 'Cannot find user with id ' + project.owner.toString() }
|
if (!user) return { ok: false, error: 'Cannot find user with id ' + project.owner.toString() }
|
||||||
|
|
||||||
if (report.visits.length > 0 || report.events.length > 0) {
|
if (report.visits.length > 0 || report.events.length > 0) {
|
||||||
|
await EmailService.sendAnomalyVisitsEventsEmail(user.email, project.name, { visits: report.visits, events: report.events });
|
||||||
await EmailService.sendAnomalyVisitsEventsEmail(
|
|
||||||
user.email,
|
|
||||||
project.name,
|
|
||||||
{ visits: report.visits, events: report.events }
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (report.visits.length > 0) {
|
if (report.visits.length > 0) {
|
||||||
|
await EmailService.sendAnomalyDomainEmail(user.email, project.name, report.dns);
|
||||||
await EmailService.sendAnomalyDomainEmail(
|
|
||||||
user.email,
|
|
||||||
project.name,
|
|
||||||
report.dns
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user