mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-16 01:06:59 +08:00
fix(security): harden auth flows and lock down telegram bot tool
- config: require JWT_SECRET >=32 bytes and reject the historical default fallback; MustInit aborts startup under an insecure config - api: CORS now uses CORS_ALLOWED_ORIGINS allowlist with safe localhost defaults instead of returning Access-Control-Allow-Origin: * - api: /api/reset-password and /api/reset-account stay public so recovery still works, but require an explicit confirm phrase in the body to block accidental and drive-by triggers - api: drop adoptOrphanRecords so wiping the account no longer hands the next registrant the previous owner's wallet keys and exchange API credentials - api: getTraderFromQuery now does a soft ownership check; equity-history is restricted to traders with show_in_competition=true and GetOrderFills joins on trader_id - telegram: bot api_request tool uses a default-deny method+path allowlist so prompt injection cannot reach password, exchange key, AI provider or wallet endpoints - ci: drop @master / @main on trivy-action and trufflehog; pin to released versions with a TODO to move to SHA + Dependabot - web: reset flows send the required confirm phrase; "Forgot account" copy (en/zh/id) warns that wallet and exchange keys will be lost - docker-compose: keep ./.env mount for onboarding wallet persistence with an inline note on the tradeoff, drop the host-exposed pprof port
This commit is contained in:
@@ -258,12 +258,17 @@ func (s *OrderStore) GetTraderOrdersFiltered(traderID string, symbol string, sta
|
||||
return orders, nil
|
||||
}
|
||||
|
||||
// GetOrderFills gets order's fill records
|
||||
func (s *OrderStore) GetOrderFills(orderID int64) ([]*TraderFill, error) {
|
||||
// GetOrderFills gets fill records for a specific order. The traderID arg
|
||||
// scopes the join so a caller cannot read fills for an order that does not
|
||||
// belong to their trader (IDOR boundary). Pass an empty traderID only from
|
||||
// trusted internal callers that have already verified ownership.
|
||||
func (s *OrderStore) GetOrderFills(traderID string, orderID int64) ([]*TraderFill, error) {
|
||||
q := s.db.Where("order_id = ?", orderID)
|
||||
if traderID != "" {
|
||||
q = q.Where("trader_id = ?", traderID)
|
||||
}
|
||||
var fills []*TraderFill
|
||||
err := s.db.Where("order_id = ?", orderID).
|
||||
Order("created_at ASC").
|
||||
Find(&fills).Error
|
||||
err := q.Order("created_at ASC").Find(&fills).Error
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query fills: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user