@davoodmehraban89 / VELYQOR / commits / 56c5be4
Fork 0

Intelligence, Advanced Charting & Trading Platform

security(risk): reject cross-instrument, wrong-side or untrusted provider quotes before reading state

davoodmehraban89 committed Oct 22, 2026 at 23:37 UTC 56c5be456e22b3fa0283f9b66f1a5838176626e6
1 file changed +6 -3
packages/market-domain/src/alert-postgres-coordinator.mjs
+6 -3
@@ -51,13 +51,16 @@ function validateArgs({db,domain,principal,rule,recipient,observation,now}){
51 typeof rule.provider!=='string'||!rule.provider||
52 typeof rule.symbol!=='string'||!rule.symbol||
53 typeof rule.unit!=='string'||!rule.unit||
54 - !Array.isArray(rule.legs))
54 + !Array.isArray(rule.legs)||rule.legs.length<1||rule.legs.length>2||
55 + !['BUY','SELL'].includes(rule.legs[0]?.side))
56 throw new TypeError('trusted rule contract required');
57 if(!ID.test(recipient?.recipientRef)||!ALLOWED_CHANNELS.has(recipient?.channel)||
58 recipient.optInVerified!==true)
59 throw new TypeError('verified recipient mapping required');
59 - if(!observation||typeof observation!=='object')
60 - throw new TypeError('observation required');
60 + if(!observation||typeof observation!=='object'||
61 + observation.symbol!==rule.symbol||observation.provider!==rule.provider||
62 + observation.unit!==rule.unit||observation.side!==rule.legs[0].side)
63 + throw new TypeError('observation must match trusted source, unit and exit side');
64 if(typeof now!=='string'||!Number.isFinite(Date.parse(now)))
65 throw new TypeError('valid server time required');
66 }