feat: 增加防篡改功能 (#4016)

This commit is contained in:
ssongliu 2024-03-01 13:51:01 +08:00 committed by GitHub
parent 73e118a3e5
commit 7e4606eda5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 130 additions and 99 deletions

View file

@ -291,6 +291,7 @@ const message = {
process: 'Process',
network: 'Network',
supervisor: 'Supervisor',
name: 'Tamper Proof',
},
home: {
restart_1panel: 'Restart Panel',
@ -2145,16 +2146,42 @@ const message = {
name: 'X-Pack',
waf: {
name: 'WAF',
blackWhite: 'black and white list',
blackWhite: 'Black and White List',
globalSetting: 'Global Setting',
websiteSetting: 'Website Settings',
blockRecords: 'Block records',
websiteSetting: 'Website Setting',
blockRecords: 'Block Records',
},
monitor: {
name: 'Website monitoring',
name: 'Website Monitoring',
},
tamper: {
name: 'Tamper-proof',
tamperHelper1:
'One-click deployment type of website, it is recommended to enable the application directory anti-tampering function;',
tamperHelper2:
'If the website cannot be used normally or backup and restore fail after enabling the anti-tampering function, please disable the anti-tampering function first;',
tamperHelper3:
'Enabling tamper-proofing will restrict reading, writing, deleting, permission, and owner modification operations of protected files under non-excluded directories. Please choose carefully when setting [Exclude Directory] and [Protect].',
op: 'Operation',
create: 'Create',
file: 'File',
tamperPath: 'Protection Directory',
tamperPathEdit: 'Modify Path',
log: 'Intercept Logs',
totalProtect: 'Total Protection',
todayProtect: 'Todays Protection',
addRule: 'Add Rule',
ignore: 'Exclude Directory',
ignoreHelper: 'One per line, e.g., \ntmp\n./tmp',
ignoreHelper1: 'Add folder names or specific paths to ignore',
ignoreHelper2: 'To ignore specific folders, use relative paths starting with ./',
protect: 'Protect',
protectHelper: 'One per line, e.g., \npng\n./test.css',
protectHelper1: 'Specify file names, suffixes, or specific files for protection',
protectHelper2: 'To protect specific files, use relative paths starting with ./',
enableHelper:
'The anti-tampering function of website {0} is about to be enabled to enhance website security. Do you want to continue?',
disableHelper:
'The anti-tampering function of website {0} is about to be disabled. Do you want to continue?',
},
},
},

View file

@ -288,6 +288,7 @@ const message = {
process: '進程',
network: '網絡',
supervisor: '進程守護',
tamper: '防篡改',
},
home: {
restart_1panel: '重啟面板',
@ -2008,15 +2009,37 @@ const message = {
waf: {
name: 'WAF',
blackWhite: '黑白名單',
globalSetting: '域設定',
websiteSetting: '網站設',
globalSetting: '局設置',
websiteSetting: '網站設',
blockRecords: '封鎖記錄',
},
monitor: {
name: '網站監控',
},
tamper: {
name: '防篡改',
tamperHelper1: '一鍵部署類型的網站建議啟用應用目錄防篡改功能',
tamperHelper2: '如果在啟用防篡改功能後出現網站無法正常使用或備份恢復失敗的情況請先關閉防篡改功能',
tamperHelper3:
'啟用防篡改將限制非排除目錄下受保護文件的讀寫刪除權限和所有者修改操作請在設定 [排除目錄] [保護] 時謹慎選擇',
op: '操作',
create: '創建',
file: '文件',
tamperPath: '防護目錄',
tamperPathEdit: '修改路徑',
log: '攔截日誌',
totalProtect: '總防護',
todayProtect: '今日防護',
addRule: '添加規則',
ignore: '排除目錄',
ignoreHelper: '一行一個 \ntmp\n./tmp',
ignoreHelper1: '添加要忽略的文件夾名或特定路徑',
ignoreHelper2: '要忽略特定文件夾請使用以 ./ 開頭的相對路徑',
protect: '保護',
protectHelper: '一行一個 \npng\n./test.css',
protectHelper1: '可指定文件名後綴名或特定文件進行保護',
protectHelper2: '要保護特定文件請使用以 ./ 開頭的相對路徑',
enableHelper: '即將啟用 {0} 網站的防窜改功能以提升網站安全性是否繼續',
disableHelper: '即將關閉 {0} 網站的防窜改功能是否繼續',
},
},
},

View file

@ -288,6 +288,7 @@ const message = {
process: '进程',
network: '网络',
supervisor: '进程守护',
tamper: '防篡改',
},
home: {
restart_1panel: '重启面板',
@ -2017,7 +2018,30 @@ const message = {
name: '网站监控',
},
tamper: {
name: '防篡改',
tamper: '防篡改',
tamperHelper1: '一键部署类型的网站建议启用应用目录防篡改功能',
tamperHelper2: '如果在启用防篡改功能后出现网站无法正常使用或备份恢复失败的情况请先关闭防篡改功能',
tamperHelper3:
'启用防篡改将限制非排除目录下受保护文件的读写删除权限和所有者修改操作请在设定 [排除目录] [保护] 时谨慎选择',
op: '操作',
create: '创建',
file: '文件',
tamperPath: '防护目录',
tamperPathEdit: '修改路径',
log: '拦截日志',
totalProtect: '总防护',
todayProtect: '今日防护',
addRule: '添加规则',
ignore: '排除目录',
ignoreHelper: '一行一个 \ntmp\n./tmp',
ignoreHelper1: '添加要忽略的文件夹名或特定路径',
ignoreHelper2: '要忽略特定文件夹请使用以 ./ 开头的相对路径',
protect: '保护',
protectHelper: '一行一个 \npng\n./test.css',
protectHelper1: '可指定文件名后缀名或特定文件进行保护',
protectHelper2: '要保护特定文件请使用以 ./ 开头的相对路径',
enableHelper: '即将启用 {0} 网站的防窜改功能以提升网站安全性是否继续',
disableHelper: '即将关闭 {0} 网站的防窜改功能是否继续',
},
},
};

View file

@ -0,0 +1,45 @@
import i18n from '@/lang';
export const shortcuts = [
{
text: i18n.global.t('monitor.today'),
value: () => {
const end = new Date();
const start = new Date(new Date().setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.yesterday'),
value: () => {
const yesterday = new Date(new Date().getTime() - 3600 * 1000 * 24 * 1);
const end = new Date(yesterday.setHours(23, 59, 59, 999));
const start = new Date(yesterday.setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [3]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3);
const end = new Date();
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [7]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7);
const end = new Date();
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [30]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 30);
const end = new Date();
return [start, end];
},
},
];

View file

@ -2,52 +2,6 @@ import { Cronjob } from '@/api/interface/cronjob';
import i18n from '@/lang';
import { loadZero } from '@/utils/util';
export const shortcuts = [
{
text: i18n.global.t('monitor.today'),
value: () => {
const end = new Date(new Date().setHours(23, 59, 59, 999));
const start = new Date(new Date().setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.yesterday'),
value: () => {
const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 1);
const end = new Date(itemDate.setHours(23, 59, 59, 999));
const start = new Date(itemDate.setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [3]),
value: () => {
const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3);
const end = new Date(new Date().setHours(23, 59, 59, 999));
const start = new Date(itemDate.setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [7]),
value: () => {
const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7);
const end = new Date(new Date().setHours(23, 59, 59, 999));
const start = new Date(itemDate.setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [30]),
value: () => {
const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 30);
const end = new Date(new Date().setHours(23, 59, 59, 999));
const start = new Date(itemDate.setHours(0, 0, 0, 0));
return [start, end];
},
},
];
export const specOptions = [
{ label: i18n.global.t('cronjob.perMonth'), value: 'perMonth' },
{ label: i18n.global.t('cronjob.perWeek'), value: 'perWeek' },

View file

@ -245,7 +245,7 @@ import { oneDark } from '@codemirror/theme-one-dark';
import { MsgSuccess } from '@/utils/message';
import { listDbItems } from '@/api/modules/database';
import { ListAppInstalled } from '@/api/modules/app';
import { shortcuts } from './../helper';
import { shortcuts } from '@/utils/shortcuts';
const loading = ref();
const refresh = ref(false);

View file

@ -208,6 +208,7 @@ import { computeSizeFromKBs, dateFormatWithoutYear } from '@/utils/util';
import i18n from '@/lang';
import MonitorRouter from '@/views/host/monitor/index.vue';
import { GlobalStore } from '@/store';
import { shortcuts } from '@/utils/shortcuts';
const globalStore = GlobalStore();
@ -227,49 +228,6 @@ const networkChoose = ref();
const netOptions = ref();
const chartsOption = ref({ loadLoadChart: null, loadCPUChart: null, loadMemoryChart: null, loadNetworkChart: null });
const shortcuts = [
{
text: i18n.global.t('monitor.today'),
value: () => {
const end = new Date();
const start = new Date(new Date().setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.yesterday'),
value: () => {
const yesterday = new Date(new Date().getTime() - 3600 * 1000 * 24 * 1);
const end = new Date(yesterday.setHours(23, 59, 59, 999));
const start = new Date(yesterday.setHours(0, 0, 0, 0));
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [3]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3);
const end = new Date();
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [7]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7);
const end = new Date();
return [start, end];
},
},
{
text: i18n.global.t('monitor.lastNDay', [30]),
value: () => {
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 30);
const end = new Date();
return [start, end];
},
},
];
const searchTime = ref();
const searchInfo = reactive<Monitor.MonitorSearch>({
param: '',