sqlite-web 0.7.2
gitea.db
issue
Create
Query
access
access_token
action
action_artifact
action_run
action_run_index
action_run_job
action_runner
action_runner_token
action_schedule
action_schedule_spec
action_task
action_task_output
action_task_step
action_tasks_version
action_variable
app_state
attachment
auth_token
badge
branch
collaboration
comment
commit_status
commit_status_index
commit_status_summary
commit_sync_log
commit_sync_status
dbfs_data
dbfs_meta
deploy_key
email_address
email_hash
external_login_user
follow
gpg_key
gpg_key_import
hook_task
issue
issue_assignees
issue_content_history
issue_dependency
issue_index
issue_label
issue_pin
issue_user
issue_watch
label
language_stat
lfs_lock
lfs_meta_object
login_source
milestone
mirror
notice
notification
oauth2_application
oauth2_authorization_code
oauth2_grant
org_user
package
package_blob
package_blob_upload
package_cleanup_rule
package_file
package_property
package_version
project
project_board
project_issue
protected_branch
protected_tag
public_key
pull_auto_merge
pull_request
push_mirror
reaction
release
renamed_branch
repo_archiver
repo_hidden_file
repo_indexer_status
repo_license
repo_redirect
repo_topic
repo_transfer
repo_unit
repository
review
review_state
secret
session
sqlite_sequence
star
stopwatch
system_setting
task
team
team_invite
team_repo
team_unit
team_user
topic
tracked_time
two_factor
upload
user
user_badge
user_blocking
user_open_id
user_redirect
user_setting
version
watch
webauthn_credential
webhook
Toggle helper tables
Structure
Content
Query
Insert
Drop
Import
Export
Update row 10 in issue
id
Primary key.
INTEGER NOT NULL
repo_id
INTEGER
index
INTEGER
poster_id
INTEGER
original_author
TEXT
original_author_id
INTEGER
name
🔍 代码审查报告:main 分支 - 修改测试111
TEXT
content
## 自动代码审查报告 **分支**: main **提交**: `252852cf322c50ffd2a193223a08e9e4b567bf78` **时间**: 2026-03-17 11:15:38 **审查模型**: qwen3.5-plus --- [2026-03-17 11:13:55] 正在调用 Qwen API 进行代码审查... [2026-03-17 11:15:38] 审查结果已保存到:/root/gitea-code-review/logs/results/code-review-20260317-111355.md ## 📋 审查摘要 - **变更文件数**: 1 - **严重问题**: 1 - **高危问题**: 3 - **中危问题**: 4 - **建议优化**: 3 ## 🐛 发现的问题 ### [安全隐患] 越权访问风险 (IDOR) - **严重程度**: 严重 - **文件**: pc/application/controllers/Bill.php - **行号**: 135 (getDetail 方法) - **问题描述**: 在 `getDetail` 方法中,查询账单详情时仅使用了 `bill_no` 和 `unique_key`,未校验当前登录用户的 `merchant_id` 是否拥有该账单的权限。攻击者若获取到其他商户的账单号和唯一键,可越权查看敏感账单信息。 - **修复建议**: 在调用模型查询时,必须传入 `merchant_id` 并在模型层或控制器层进行权限校验。 ```php // 修复示例 $bill_detail = $this->ahead_bill_model->get_detail($bill_no, $unique_key, $merchant_id); // 或者查询后校验 if (empty($bill_detail) || $bill_detail['_merchant_id'] != $merchant_id) { $this->error_response('账单不存在或无权访问'); } ``` ### [安全隐患] SQL 注入风险 - **严重程度**: 高危 - **文件**: pc/application/controllers/Bill.php - **行号**: 256, 266 (export 方法) - **问题描述**: 在 `export` 方法中,`$bill_no` 等参数直接来自 `$_GET`,虽然使用了 `trim`,但在构建查询条件 `$bill_where['a._bill_no like'] = '%' . $bill_no;` 时,直接拼接字符串。如果底层模型 `ahead_bill_model` 未对数组值进行严格的转义处理,存在 SQL 注入风险。 - **修复建议**: 使用框架提供的参数绑定或转义函数,不要直接拼接 SQL 片段。 ```php // 修复建议:确保模型层使用预处理,或在此处转义 $bill_no = $this->db->escape_like_str($bill_no); $bill_where['a._bill_no like'] = '%' . $bill_no . '%'; ``` ### [逻辑 BUG] 金额计算错误 - **严重程度**: 高危 - **文件**: pc/application/controllers/Bill.php - **行号**: 167 (getDetail 方法) - **问题描述**: `$bill_detail['manager_discounts']` 计算逻辑疑似错误,将 `goods_info` 中的折扣与 `bill_detail` 自身的折扣相加,但变量名重复,可能是想加其他字段,或者是重复计算了自身。 ```php // 当前代码 $bill_detail['manager_discounts'] = number_format($bill_detail['goods_info']['manager_discounts'] + $bill_detail['manager_discounts'], 2, '.', ''); ``` - **修复建议**: 确认业务逻辑,如果是累加,确保变量来源正确;如果是赋值,移除加法。 ```php // 修复示例(假设是累加) $bill_detail['manager_discounts'] = number_format(($bill_detail['goods_info']['manager_discounts'] ?? 0) + ($bill_detail['manager_discounts'] ?? 0), 2, '.', ''); ``` ### [代码质量] 方法名拼写错误 - **严重程度**: 中危 - **文件**: pc/application/controllers/Bill.php - **行号**: 76 (getList 方法) - **问题描述**: 调用模型方法 `get_clean_datedd` 多了一个 'd',而在 `export` 方法(行 242)中调用的是 `get_clean_date`。这会导致 `getList` 方法报错或调用不存在的方法。 - **修复建议**: 统一修正为正确的方法名。 ```php // 修复 $start_date = $this->ahead_setting_clean_data_model->get_clean_date($merchant_id, 2, $start_date); ``` ### [代码质量] 响应格式不一致 - **严重程度**: 中危 - **文件**: pc/application/controllers/Bill.php - **行号**: 232, 236, 240 (export 方法) - **问题描述**: `export` 方法在错误处理时直接使用 `exit()` 输出字符串,而 `getList` 等其他方法使用 `$this->error_response()` 返回标准 JSON 格式。这会导致前端处理逻辑不一致,且 `exit` 可能绕过框架的日志记录或后续清理逻辑。 - **修复建议**: 统一使用框架的响应方法。 ```php // 修复 if (empty($merchant_id)) { $this->error_response('账号异常,请重新登录'); return; } ``` ### [安全隐患] 输入来源不一致 - **严重程度**: 中危 - **文件**: pc/application/controllers/Bill.php - **行号**: 222 (export 方法) - **问题描述**: `export` 方法直接使用 `$_GET` 获取参数,而 `getList` 使用 `$this->param`。`$this->param` 通常在父类 `PcServer` 中经过统一 sanitization 或合并处理,直接使用 `$_GET` 可能绕过安全过滤。 - **修复建议**: 统一使用 `$this->param` 获取输入参数。 ```php // 修复 $param = $this->param; ``` ### [语法/规范] 多余的分号 - **严重程度**: 低危 - **文件**: pc/application/controllers/Bill.php - **行号**: 191 (printInvoice 方法) - **问题描述**: 行尾出现双分号 `;;`。 - **修复建议**: 删除多余分号。 ```php // 修复 $invoice_amount = is_numeric($param['invoice_amount']) ? floatval($param['invoice_amount']) : $this->error_response('请输入正确的发票金额'); ``` ### [代码质量] 代码重复 - **严重程度**: 低危 - **文件**: pc/application/controllers/Bill.php - **行号**: 45-115 与 222-290 - **问题描述**: `getList` 和 `export` 方法中构建查询条件 (`$bill_where`, `$bill_count_where`) 的逻辑高度重复。 - **修复建议**: 提取公共逻辑到私有方法 `_build_bill_query_conditions()`,减少维护成本。 ## ✅ 代码亮点 1. **入口安全**: 文件开头使用了 `defined('BASEPATH') or exit(...)` 防止直接访问,符合 CodeIgniter 安全规范。 2. **辅助函数加载**: 在需要使用 `isDateDayTime` 前正确加载了 `check` helper。 3. **权限意识**: 大部分查询都考虑了 `merchant_id` 和 `priv_shop_ids` 的权限隔离(除了 `getDetail` 的疏漏)。 ## 📝 总体建议 1. **安全优先**: 立即修复 `getDetail` 的越权漏洞和 `export` 的 SQL 注入风险。这是最严重的问题。 2. **统一规范**: 统一控制器中的参数获取方式(建议全部使用 `$this->param`)和错误响应方式(全部使用 `$this->error_response`)。 3. **重构优化**: `Bill` 控制器过于臃肿,建议将查询构建逻辑、数据格式化逻辑抽取到 Model 或 Service 层,控制器只负责流程调度。 4. **事务管理**: 在 `printInvoice` 方法中,更新账单表和插入发票记录表应该放在数据库事务中,保证数据一致性。 5. **测试覆盖**: 修复 `get_clean_datedd` 拼写错误后,需回归测试 `getList` 接口,确保日期过滤功能正常。 --- *此 Issue 由代码审查服务自动创建 | 审查基于提交时的代码快照*
TEXT
milestone_id
INTEGER
priority
INTEGER
is_closed
INTEGER
is_pull
INTEGER
num_comments
INTEGER
ref
TEXT
deadline_unix
INTEGER
created_unix
INTEGER
updated_unix
INTEGER
closed_unix
INTEGER
is_locked
INTEGER NOT NULL (default 0
content_version
INTEGER NOT NULL (default 0
time_estimate
INTEGER NOT NULL (default 0
Update
Cancel