Some checks failed
Build and Deploy Log Center / build-and-deploy (push) Failing after 5m9s
75 lines
3.0 KiB
SQL
75 lines
3.0 KiB
SQL
-- 创建不同等级的测试Bug
|
||
-- 使用方法:在数据库管理工具中执行此SQL,或使用命令行:
|
||
-- PGPASSWORD='JogNQdtrd3WY8CBCAiYfYEGx' psql -h pgm-7xv4811oj11j86htzo.pg.rds.aliyuncs.com -U log_center -d log_center < create_test_bugs.sql
|
||
|
||
-- Bug 1: 10级 - 支付安全漏洞(最高优先级)
|
||
INSERT INTO errorlog (
|
||
project_id, environment, level, source, error_type, error_message,
|
||
file_path, line_number, stack_trace, context, status, fingerprint,
|
||
timestamp, retry_count, version, commit_hash
|
||
) VALUES (
|
||
'rtc_backend', 'production', 'CRITICAL', 'runtime',
|
||
'PaymentSecurityError',
|
||
'支付金额验证绕过:可通过修改客户端金额完成支付',
|
||
'app/services/payment_service.py', 156,
|
||
'PaymentSecurityError: 支付金额未在服务端验证',
|
||
'{"vulnerability": "payment_bypass", "severity": 10}',
|
||
'NEW', 'bug_payment_sec_10',
|
||
CURRENT_TIMESTAMP, 0, '1.0.0', 'abc123'
|
||
);
|
||
|
||
-- Bug 2: 9级 - 用户数据泄露
|
||
INSERT INTO errorlog (
|
||
project_id, environment, level, source, error_type, error_message,
|
||
file_path, line_number, stack_trace, context, status, fingerprint,
|
||
timestamp, retry_count, version, commit_hash
|
||
) VALUES (
|
||
'rtc_backend', 'production', 'CRITICAL', 'runtime',
|
||
'DataLeakError',
|
||
'API返回了其他用户的敏感信息',
|
||
'app/api/user_api.py', 89,
|
||
'DataLeakError: 未授权访问其他用户数据',
|
||
'{"vulnerability": "data_leak", "severity": 9}',
|
||
'NEW', 'bug_data_leak_9',
|
||
CURRENT_TIMESTAMP, 0, '1.0.0', 'def456'
|
||
);
|
||
|
||
-- Bug 3: 5级 - 业务逻辑错误
|
||
INSERT INTO errorlog (
|
||
project_id, environment, level, source, error_type, error_message,
|
||
file_path, line_number, stack_trace, context, status, fingerprint,
|
||
timestamp, retry_count, version, commit_hash
|
||
) VALUES (
|
||
'rtc_backend', 'production', 'ERROR', 'runtime',
|
||
'BusinessLogicError',
|
||
'设备绑定时未检查设备状态',
|
||
'app/api/device_api.py', 234,
|
||
'BusinessLogicError: 设备已绑定但未检查状态',
|
||
'{"device_sn": "BRAND-P01-001", "severity": 5}',
|
||
'NEW', 'bug_business_logic_5',
|
||
CURRENT_TIMESTAMP, 0, '1.0.0', 'ghi789'
|
||
);
|
||
|
||
-- Bug 4: 3级 - 简单拼写错误
|
||
INSERT INTO errorlog (
|
||
project_id, environment, level, source, error_type, error_message,
|
||
file_path, line_number, stack_trace, context, status, fingerprint,
|
||
timestamp, retry_count, version, commit_hash
|
||
) VALUES (
|
||
'rtc_backend', 'production', 'WARNING', 'runtime',
|
||
'NameError',
|
||
'变量名拼写错误:devce_id 应为 device_id',
|
||
'app/utils/validator.py', 45,
|
||
'NameError: name devce_id is not defined',
|
||
'{"typo": "devce_id", "severity": 3}',
|
||
'NEW', 'bug_typo_3',
|
||
CURRENT_TIMESTAMP, 0, '1.0.0', 'jkl012'
|
||
);
|
||
|
||
-- 查询刚创建的Bug
|
||
SELECT id, error_type, error_message, status,
|
||
context->>'severity' as severity_level
|
||
FROM errorlog
|
||
WHERE fingerprint IN ('bug_payment_sec_10', 'bug_data_leak_9', 'bug_business_logic_5', 'bug_typo_3')
|
||
ORDER BY (context->>'severity')::int DESC;
|