Skip to content

Fix scan findings: price_aggregates table, env vars, zero-div checks - #10

Merged
buzzkillb merged 15 commits into
mainfrom
dev
Mar 17, 2026
Merged

Fix scan findings: price_aggregates table, env vars, zero-div checks#10
buzzkillb merged 15 commits into
mainfrom
dev

Conversation

@buzzkillb

@buzzkillb buzzkillb commented Mar 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add price_aggregates table to database.rs initialization
  • Make shanghai_price_service.rs read UPDATE_INTERVAL_SECONDS from env var
  • Add zero-check before division in bot.rs conversion calculations
  • Remove duplicate comment in bot.rs

These fixes address the valid findings from the code scan.

Note

Low Risk

Overview
This pull request adds the missing price_aggregates table creation to the database initialization in src/database.rs. It updates src/shanghai_price_service.rs to read the UPDATE_INTERVAL_SECONDS value from an environment variable instead of a hard‑coded constant. In src/bot.rs, it inserts a zero‑check before division operations in conversion calculations and removes a duplicate comment. Additionally, it introduces a new GitHub Actions workflow file at .github/workflows/test.yml to configure testing.

Written by Gitzilla for commit 255240b. This will update automatically on new runs. Configure in the Gitzilla dashboard.

@gitzillabot gitzillabot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitzilla has reviewed your changes and found 1 potential issue.

Autofix is OFF. To automatically fix reported issues, enable autofix in the Gitzilla dashboard.

Comment thread src/utils.rs Outdated
Comment on lines +144 to +146
#[test]
fn test_validate_price_invalid() {
assert!(validate_price(-10.0).is_err());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate test function causes compilation failure

High Severity

The test_validate_price_invalid test function is duplicated and has an orphaned statement. Lines 144-149 now contain:

#[test]
fn test_validate_price_invalid() {
#[test]
fn test_validate_price_invalid() {
assert!(validate_price(-10.0).is_err());
assert!(validate_price(-10.0).is_err());

This causes a "function defined multiple times" error and the orphaned assert! outside any function body will fail to compile.

Suggested fix: Remove the duplicate lines. The test should have only one function declaration and one assertion for -10.0. Keep the existing assertions for f64::NAN and f64::INFINITY.

@buzzkillb
buzzkillb merged commit 1e3e74e into main Mar 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant