Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Business logic data validation testing examines whether the application correctly validates data according to business rules, not just technical constraints. While technical validation (data type, format, length) is often implemented, business-level validation (logical ranges, relationships, state transitions) may be missing. Attackers can exploit these gaps to submit data that is technically valid but violates business logic.
from decimal import Decimal
classOrderValidator:
defvalidate_quantity(self, quantity, product):
"""Validate quantity against business rules"""ifnotisinstance(quantity, int):
raise ValueError("Quantity must be an integer")
if quantity <= 0:
raise ValueError("Quantity must be positive")
if quantity > product.max_order_quantity:
raise ValueError(f"Maximum quantity is {product.max_order_quantity}")
if quantity > product.stock:
raise ValueError("Insufficient stock")
returnTruedefvalidate_order(self, order):
"""Validate entire order"""# Validate each itemfor item in order.items:
self.validate_quantity(item.quantity, item.product)
# Validate calculations server-side
calculated_subtotal = sum(
item.product.price * item.quantity
for item in order.items
)
if order.subtotal != calculated_subtotal:
raise ValueError("Invalid subtotal")
# Validate discountif order.discount:
if order.discount.percent > 100or order.discount.percent < 0:
raise ValueError("Invalid discount")
# Calculate total server-side
order.total = self.calculate_total(order)
returnTrue
2. State Machine for Status Transitions
classOrderStateMachine:
VALID_TRANSITIONS = {
'pending': ['paid', 'cancelled'],
'paid': ['processing', 'refunded'],
'processing': ['shipped', 'cancelled'],
'shipped': ['delivered', 'returned'],
'delivered': ['completed', 'returned'],
'completed': [],
'cancelled': [],
'refunded': [],
'returned': ['refunded']
}
defcan_transition(self, current_state, new_state):
"""Check if transition is valid"""
allowed = self.VALID_TRANSITIONS.get(current_state, [])
return new_state in allowed
deftransition(self, order, new_state):
"""Perform state transition with validation"""ifnotself.can_transition(order.status, new_state):
raise ValueError(
f"Cannot transition from {order.status} to {new_state}"
)
order.status = new_state
order.status_history.append({
'from': order.status,
'to': new_state,
'timestamp': datetime.utcnow(),
'user': current_user.id
})
return order
3. Date/Time Validation
from datetime import datetime, timedelta
defvalidate_booking_dates(check_in, check_out):
"""Validate booking date logic"""
today = datetime.now().date()
# Must be in the futureif check_in < today:
raise ValueError("Check-in date must be in the future")
# Check-out must be after check-inif check_out <= check_in:
raise ValueError("Check-out must be after check-in")
# Maximum booking lengthif (check_out - check_in).days > 30:
raise ValueError("Maximum booking length is 30 days")
# Must be within bookable range (e.g., 1 year ahead)
max_date = today + timedelta(days=365)
if check_in > max_date:
raise ValueError("Cannot book more than 1 year in advance")
returnTrue
4. Never Trust Client-Side Calculations
@app.route('/api/checkout', methods=['POST'])defcheckout():
cart = get_user_cart(current_user)
# Recalculate everything server-side
subtotal = Decimal('0')
for item in cart.items:
# Get current price from database
product = Product.query.get(item.product_id)
item_total = product.current_price * item.quantity
subtotal += item_total
# Apply discount server-side
discount = calculate_discount(cart.discount_code, subtotal)
# Calculate tax server-side
tax = calculate_tax(subtotal - discount, current_user.address)
# Final total
total = subtotal - discount + tax
# Ignore any totals sent by client
order = create_order(
items=cart.items,
subtotal=subtotal,
discount=discount,
tax=tax,
total=total
)
return jsonify(order.to_dict())