Skip to content

Commit 2969a36

Browse files
committed
feat(vulnTestServer): add coupon system with Base64 encoded parameters
- Add coupon query/search/category APIs with Base64 encoded parameters - Add member center and review center modal dialogs - Fix duplicate menu items issue in sidebar - Add shopping styles and UI improvements
1 parent 55f39f8 commit 2969a36

8 files changed

Lines changed: 1565 additions & 631 deletions

File tree

src/vulnTestServer/database.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,44 @@ def init_database():
150150
notes TEXT
151151
)
152152
''')
153+
154+
# 创建优惠券表(用于 Base64 加密参数 SQL 注入演示)
155+
cursor.execute('''
156+
CREATE TABLE IF NOT EXISTS coupons (
157+
id INTEGER PRIMARY KEY AUTOINCREMENT,
158+
coupon_code TEXT NOT NULL UNIQUE,
159+
discount_type TEXT DEFAULT 'percent',
160+
discount_value REAL NOT NULL,
161+
min_purchase REAL DEFAULT 0,
162+
max_discount REAL,
163+
category TEXT,
164+
status TEXT DEFAULT 'active',
165+
valid_from TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
166+
valid_until TIMESTAMP,
167+
usage_limit INTEGER DEFAULT 100,
168+
used_count INTEGER DEFAULT 0,
169+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
170+
)
171+
''')
172+
173+
# 创建用户评价表
174+
cursor.execute('''
175+
CREATE TABLE IF NOT EXISTS reviews (
176+
id INTEGER PRIMARY KEY AUTOINCREMENT,
177+
user_id INTEGER NOT NULL,
178+
product_id INTEGER NOT NULL,
179+
order_id INTEGER,
180+
rating INTEGER NOT NULL CHECK(rating >= 1 AND rating <= 5),
181+
title TEXT,
182+
content TEXT,
183+
is_anonymous INTEGER DEFAULT 0,
184+
helpful_count INTEGER DEFAULT 0,
185+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
186+
FOREIGN KEY (user_id) REFERENCES users(id),
187+
FOREIGN KEY (product_id) REFERENCES products(id),
188+
FOREIGN KEY (order_id) REFERENCES orders(id)
189+
)
190+
''')
153191

154192
# 插入测试用户
155193
test_users = [
@@ -245,6 +283,43 @@ def init_database():
245283
except:
246284
pass
247285

286+
# 插入优惠券测试数据(用于 Base64 加密参数 SQL 注入演示)
287+
test_coupons = [
288+
('SAVE10', 'percent', 10.0, 100.0, 50.0, 'electronics', 'active'),
289+
('NEWUSER20', 'percent', 20.0, 0, 100.0, None, 'active'),
290+
('FLASH50', 'fixed', 50.0, 200.0, 50.0, 'fashion', 'active'),
291+
('VIP30', 'percent', 30.0, 500.0, 200.0, None, 'active'),
292+
('BOOKS15', 'percent', 15.0, 50.0, 30.0, 'books', 'active'),
293+
('EXPIRED99', 'percent', 99.0, 0, 999.0, None, 'expired'),
294+
]
295+
296+
for coupon in test_coupons:
297+
try:
298+
cursor.execute('''
299+
INSERT INTO coupons (coupon_code, discount_type, discount_value, min_purchase, max_discount, category, status)
300+
VALUES (?, ?, ?, ?, ?, ?, ?)
301+
''', coupon)
302+
except:
303+
pass
304+
305+
# 插入评价测试数据
306+
test_reviews = [
307+
(2, 1, 1, 5, '非常满意', 'iPhone 15 Pro 手感超级好,性能强劲!', 0, 15),
308+
(3, 2, 3, 4, '工作利器', 'MacBook Pro 屏幕素质极佳,适合设计工作', 0, 8),
309+
(4, 5, 4, 5, '经典之作', 'Levi\'s 质量一如既往的好', 0, 23),
310+
(2, 3, 2, 5, '降噪效果好', 'AirPods Pro 降噪效果超出预期', 0, 45),
311+
(3, 6, 5, 4, '入门必读', 'Python书籍内容详实,适合初学者', 0, 12),
312+
]
313+
314+
for review in test_reviews:
315+
try:
316+
cursor.execute('''
317+
INSERT INTO reviews (user_id, product_id, order_id, rating, title, content, is_anonymous, helpful_count)
318+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
319+
''', review)
320+
except:
321+
pass
322+
248323
conn.commit()
249324
conn.close()
250325
print("[*] Database initialized with test data")

src/vulnTestServer/handlers/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,30 @@
99
- order_handlers: 订单相关(创建、查询、取消)
1010
- cart_handlers: 购物车相关(添加、更新)
1111
- system_handlers: 系统相关(配置、重置、API信息、反馈)
12+
- secrets_handlers: 敏感信息相关(创建、查询、搜索)
13+
- shipping_handlers: 物流相关(XML SQL注入演示)
14+
- encrypted_handlers: 加密参数相关(Base64编码参数演示)
15+
- coupon_handlers: 优惠券相关(Base64加密参数演示)
1216
"""
1317

1418
from .user_handlers import UserHandlerMixin
1519
from .product_handlers import ProductHandlerMixin
1620
from .order_handlers import OrderHandlerMixin
1721
from .cart_handlers import CartHandlerMixin
1822
from .system_handlers import SystemHandlerMixin
23+
from .secrets_handlers import SecretsHandlerMixin
24+
from .shipping_handlers import ShippingHandlerMixin
25+
from .encrypted_handlers import EncryptedHandlerMixin
26+
from .coupon_handlers import CouponHandlerMixin
1927

2028
__all__ = [
2129
'UserHandlerMixin',
2230
'ProductHandlerMixin',
2331
'OrderHandlerMixin',
2432
'CartHandlerMixin',
2533
'SystemHandlerMixin',
34+
'SecretsHandlerMixin',
35+
'ShippingHandlerMixin',
36+
'EncryptedHandlerMixin',
37+
'CouponHandlerMixin',
2638
]

0 commit comments

Comments
 (0)