Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serverside cli, tasks, and scripts. Plus REST URL Actions #18

Merged
merged 58 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0fbd3a5
init
sadnub Apr 2, 2024
b8379c4
removed unused imports in bulk action
sadnub Apr 2, 2024
ff81f7a
add message for server task and remove console.log line
sadnub Apr 2, 2024
b332332
actually show the server task run results instantly
sadnub Apr 2, 2024
33216fd
remove testing example files and packages
sadnub Apr 2, 2024
e83463a
Split up global settings rest/web actions in th eUI
sadnub Apr 14, 2024
d4d4bda
fix vuex in the cmd placeholder computed function and cleanup the scr…
sadnub Apr 15, 2024
3465211
Fix a typo in the frontend and change a field name in alert template …
sadnub Apr 16, 2024
e0f6f4f
fix webhooks labels
wh1te909 Apr 16, 2024
cb2a740
package.lock
sadnub Apr 17, 2024
08edca4
fix webhook editor bug
wh1te909 Apr 17, 2024
31f2807
fix script dropdowns and default script values updating
sadnub Apr 18, 2024
c8f1b1b
Add new roles to frontend
sadnub Apr 18, 2024
60ddf07
Hide Server Tasks in settings
sadnub Apr 18, 2024
5113f42
missed a couple things for server tasks
sadnub Apr 18, 2024
592909d
fix totp setup view
sadnub Apr 18, 2024
7f5d5db
add test button to web hooks form
sadnub Apr 19, 2024
3fa26a6
update reqs and handle new xterm packages
wh1te909 Apr 19, 2024
dd5c009
fix xterm css import
wh1te909 Apr 19, 2024
575ef6f
fix alert template bugs
wh1te909 Apr 20, 2024
589b36d
fix format options to not add cat field. Fixes only categories gettin…
sadnub Apr 23, 2024
c6e34dd
modify the text on url action modal buttons and make Test easier to …
sadnub Apr 23, 2024
1864a4e
fix custom field dropdown and script dropdown not properly setting name
sadnub Apr 23, 2024
b2fb45f
truncate text in url action table
sadnub Apr 23, 2024
f9333c5
fix instance not passing to backend
sadnub Apr 23, 2024
3642407
start removing tasks rework
sadnub Apr 27, 2024
2bf32ae
fix opening automated tasks form and make it so only web actions are …
sadnub Apr 29, 2024
ae3acfb
fix a couple issues with the urls opening
sadnub Apr 29, 2024
62fd3a2
filter url action dropdowns by web type
sadnub May 8, 2024
857a744
update reqs
wh1te909 May 16, 2024
c3098f0
remove server tasks/script run
wh1te909 May 22, 2024
a51939d
rework web terminal to open in new window
wh1te909 May 22, 2024
b840ee5
notify if no web terminal perms
wh1te909 May 22, 2024
4da70dd
don't show in hosted
wh1te909 May 22, 2024
de25074
add server scripts/terminal enabled status to vuex
wh1te909 May 22, 2024
794e128
format
wh1te909 May 22, 2024
b014f9a
more scripts/terminal rework
wh1te909 May 23, 2024
19315b6
use same var names as before rework
wh1te909 May 24, 2024
58a120e
grammar
wh1te909 May 28, 2024
2419179
add request body to debug
sadnub May 30, 2024
7e54f24
fix icon
sadnub May 30, 2024
6c4d95e
add loading indicator
sadnub May 30, 2024
e407a8c
update reqs
wh1te909 Jun 4, 2024
0f0a7ed
wrong var
wh1te909 Jun 7, 2024
32dae6e
use v2 urls
wh1te909 Jun 8, 2024
e670e67
Merge branch 'develop' into urlaction-rework
wh1te909 Jun 8, 2024
be508d9
fix lint
wh1te909 Jun 8, 2024
e001887
rename fields
wh1te909 Jun 10, 2024
8a388db
change title
wh1te909 Jun 12, 2024
5e2602c
make descriptions textfields
wh1te909 Jun 12, 2024
1a6cb09
fix 2fa not clearing and add error handling
wh1te909 Jun 12, 2024
b539df0
disable instead of hide if server scripts are disabled
wh1te909 Jun 14, 2024
0a1f33f
make post the default webhook type
wh1te909 Jun 14, 2024
51cc895
update reqs
wh1te909 Jun 15, 2024
3e52924
move role to scripts section
wh1te909 Jun 19, 2024
c872764
change wording and add some ghetto form validation
wh1te909 Jun 19, 2024
24ba9fb
fix truncate length
wh1te909 Jun 24, 2024
c420e06
update reqs
wh1te909 Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ version: '3.7'
services:
app-dev:
container_name: trmm-app-dev
image: node:18-alpine
image: node:20-alpine
restart: always
command: /bin/sh -c "npm install --cache ~/.npm && npm run serve"
user: 1000:1000
command: /bin/sh -c "npm install --cache ~/.npm && npm i -g @quasar/cli && npm run serve"
working_dir: /workspace/web
volumes:
- ..:/workspace:cached
Expand Down
2,722 changes: 1,694 additions & 1,028 deletions package-lock.json

Large diffs are not rendered by default.

41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,37 @@
},
"dependencies": {
"@quasar/extras": "1.16.11",
"apexcharts": "3.48.0",
"axios": "1.6.8",
"@vueuse/core": "10.11.0",
"@vueuse/integrations": "10.11.0",
"@vueuse/shared": "10.11.0",
"apexcharts": "3.49.2",
"axios": "1.7.2",
"dotenv": "16.4.5",
"pinia": "^2.1.7",
"qrcode.vue": "3.4.1",
"quasar": "2.15.3",
"vue": "3.4.23",
"vue3-apexcharts": "1.5.2",
"monaco-editor": "0.50.0",
"pinia": "2.1.7",
"qrcode": "1.5.3",
"quasar": "2.16.4",
"vue": "3.4.31",
"vue-router": "4.4.0",
"vue3-apexcharts": "1.5.3",
"vuedraggable": "4.1.0",
"vue-router": "4.3.2",
"@vueuse/core": "10.9.0",
"@vueuse/shared": "10.9.0",
"monaco-editor": "0.47.0",
"vuex": "4.1.0",
"xterm": "^5.3.0",
"xterm-addon-fit": "^0.8.0",
"yaml": "2.4.1"
"@xterm/xterm": "5.5.0",
"@xterm/addon-fit": "0.10.0",
"yaml": "2.4.5"
},
"devDependencies": {
"@quasar/cli": "2.4.0",
"@intlify/unplugin-vue-i18n": "4.0.0",
"@quasar/app-vite": "1.8.1",
"@types/node": "20.12.7",
"@typescript-eslint/eslint-plugin": "7.7.0",
"@typescript-eslint/parser": "7.7.0",
"@quasar/app-vite": "1.9.3",
"@quasar/cli": "2.4.1",
"@types/node": "20.14.9",
"@typescript-eslint/eslint-plugin": "7.14.1",
"@typescript-eslint/parser": "7.14.1",
"autoprefixer": "10.4.19",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-vue": "8.7.1",
"prettier": "3.2.5",
"typescript": "5.4.5"
"typescript": "5.5.2"
}
}
4 changes: 2 additions & 2 deletions quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ module.exports = configure(function (/* ctx */) {
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: ["axios", "monaco", "integrations"],
boot: ["pinia", "axios", "monaco", "integrations"],

// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
css: ["app.sass"],

// https://github.com/quasarframework/quasar/tree/dev/extras
extras: [
"ionicons-v4",
"mdi-v5",
"mdi-v7",
"fontawesome-v6",
// 'eva-icons',
// 'themify',
Expand Down
10 changes: 5 additions & 5 deletions src/api/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function openAgentWindow(agent_id) {

export function runRemoteBackground(agent_id, agentPlatform) {
const url = router.resolve(
`/remotebackground/${agent_id}?agentPlatform=${agentPlatform}`
`/remotebackground/${agent_id}?agentPlatform=${agentPlatform}`,
).href;
openURL(url, null, {
popup: true,
Expand Down Expand Up @@ -129,7 +129,7 @@ export async function refreshAgentWMI(agent_id) {
export async function runScript(agent_id, payload) {
const { data } = await axios.post(
`${baseUrl}/${agent_id}/runscript/`,
payload
payload,
);
return data;
}
Expand All @@ -153,7 +153,7 @@ export async function fetchAgentProcesses(agent_id, params = {}) {
export async function killAgentProcess(agent_id, pid, params = {}) {
const { data } = await axios.delete(
`${baseUrl}/${agent_id}/processes/${pid}/`,
{ params: params }
{ params: params },
);
return data;
}
Expand All @@ -162,7 +162,7 @@ export async function fetchAgentEventLog(agent_id, logType, days, params = {}) {
try {
const { data } = await axios.get(
`${baseUrl}/${agent_id}/eventlog/${logType}/${days}/`,
{ params: params }
{ params: params },
);
return data;
} catch (e) {
Expand Down Expand Up @@ -199,7 +199,7 @@ export async function agentShutdown(agent_id) {
export async function sendAgentRecoverMesh(agent_id, params = {}) {
const { data } = await axios.post(
`${baseUrl}/${agent_id}/meshcentral/recover/`,
{ params: params }
{ params: params },
);
return data;
}
Expand Down
13 changes: 13 additions & 0 deletions src/api/alerts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from "axios";

import type { AlertTemplate } from "@/types/alerts";

export async function saveAlertTemplate(id: number, payload: AlertTemplate) {
const { data } = await axios.put(`alerts/templates/${id}/`, payload);
return data;
}

export async function addAlertTemplate(payload: AlertTemplate) {
const { data } = await axios.post("alerts/templates/", payload);
return data;
}
45 changes: 0 additions & 45 deletions src/api/core.js

This file was deleted.

97 changes: 97 additions & 0 deletions src/api/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import axios from "axios";
import { openURL } from "quasar";
import { router } from "@/router";

import type {
URLAction,
TestRunURLActionRequest,
TestRunURLActionResponse,
} from "@/types/core/urlactions";

const baseUrl = "/core";

export async function fetchDashboardInfo(params = {}) {
const { data } = await axios.get(`${baseUrl}/dashinfo/`, { params: params });
return data;
}

export async function fetchCustomFields(params = {}) {
try {
const { data } = await axios.get(`${baseUrl}/customfields/`, {
params: params,
});
return data;
} catch (e) {
console.error(e);
}
}

export async function fetchURLActions(params = {}): Promise<URLAction[]> {
const { data } = await axios.get(`${baseUrl}/urlaction/`, {
params: params,
});
return data;
}

export async function saveURLAction(action: URLAction) {
const { data } = await axios.post(`${baseUrl}/urlaction/`, action);
return data;
}

export async function editURLAction(id: number, action: URLAction) {
const { data } = await axios.put(`${baseUrl}/urlaction/${id}/`, action);
return data;
}

export async function removeURLAction(id: number) {
const { data } = await axios.delete(`${baseUrl}/urlaction/${id}/`);
return data;
}

interface RunURLActionRequest {
agent_id?: string;
client?: number;
site?: number;
action: number;
}

export async function runURLAction(payload: RunURLActionRequest) {
const { data } = await axios.patch(`${baseUrl}/urlaction/run/`, payload);
openURL(data);
}

export async function runTestURLAction(
payload: TestRunURLActionRequest,
): Promise<TestRunURLActionResponse> {
const { data } = await axios.post(`${baseUrl}/urlaction/run/test/`, payload);
return data;
}

export async function checkWebTermPerms(): Promise<{
message: string;
status: number;
}> {
const ret = await axios.post(`${baseUrl}/webtermperms/`);
return { message: ret.data, status: ret.status };
}

export function openWebTerminal(): void {
const url: string = router.resolve("/webterm").href;
openURL(url, undefined, {
popup: true,
scrollbars: false,
location: false,
status: false,
toolbar: false,
menubar: false,
width: 1280,
height: 720,
});
}

// TODO: Build out type for openai payload
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function generateScript(payload: any) {
const { data } = await axios.post(`${baseUrl}/openai/generate/`, payload);
return data;
}
7 changes: 6 additions & 1 deletion src/api/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export async function testScript(agent_id, payload) {
return data;
}

export async function testScriptOnServer(payload) {
const { data } = await axios.post("core/serverscript/test/", payload);
return data;
}

export async function saveScript(payload) {
const { data } = await axios.post(`${baseUrl}/`, payload);
return data;
Expand Down Expand Up @@ -56,7 +61,7 @@ export async function fetchScriptSnippet(id, params = {}) {
export async function editScriptSnippet(payload) {
const { data } = await axios.put(
`${baseUrl}/snippets/${payload.id}/`,
payload
payload,
);
return data;
}
Expand Down
16 changes: 6 additions & 10 deletions src/boot/axios.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from "axios";
import { useAuthStore } from "@/stores/auth";
import { Notify } from "quasar";

export const getBaseUrl = () => {
Expand All @@ -18,27 +19,22 @@ export function setErrorMessage(data, message) {
];
}

export default function ({ app, router, store }) {
export default function ({ app, router }) {
app.config.globalProperties.$axios = axios;

axios.interceptors.request.use(
function (config) {
const auth = useAuthStore();
config.baseURL = getBaseUrl();
const token = store.state.token;
const token = auth.token;
if (token != null) {
config.headers.Authorization = `Token ${token}`;
}
// config.transformResponse = [
// function (data) {
// console.log(data);
// return data;
// },
// ];
return config;
},
function (err) {
return Promise.reject(err);
}
},
);

axios.interceptors.response.use(
Expand Down Expand Up @@ -101,6 +97,6 @@ export default function ({ app, router, store }) {
}

return Promise.reject({ ...error });
}
},
);
}
11 changes: 11 additions & 0 deletions src/boot/pinia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { boot } from "quasar/wrappers";
import { createPinia } from "pinia";

export default boot(({ app }) => {
const pinia = createPinia();

app.use(pinia);

// You can add Pinia plugins here
// pinia.use(SomePiniaPlugin)
});
4 changes: 2 additions & 2 deletions src/components/AlertsManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export default {
},
{
name: "resolved_action_name",
label: "Resolve Action",
label: "Resolved Action",
field: "resolved_action_name",
align: "left",
},
Expand Down Expand Up @@ -326,7 +326,7 @@ export default {
this.refresh();
this.$q.loading.hide();
this.notifySuccess(
`Alert template ${template.name} was deleted!`
`Alert template ${template.name} was deleted!`,
);
})
.catch(() => {
Expand Down
Loading
Loading