Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can this be simplified?
Message
 
 
To
22/11/2018 15:17:31
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01663691
Message ID:
01663717
Views:
39
>Dmitry,
>
>I'd advise always using parameterized queries:
>
>
MYTABLE.DATE_FLD >=?dDateValue
>
>This works in VFP, but also if you upsize to remote databases like SQL Server or Oracle that expect different date strings from VFP if you concatenate. There's 2 other advantages:
>
>- Against SQL Server, parameterized queries are cached so that subsequent calls are as efficient as a SP, and
>
>- Paramrterized queries are immune to SQL Injection. This isn't a risk in your date example but is a serious risk if you're concatenating string parameters. For anybody who hasn't encountered this:
>
>E.g. app has lots of customers of different salespeople. Salesperson logs in and can look up only their own customers:
>
>
lcloggedinsalesperson="dlitvak'
>lcSQL=[select * from customers where salesperson=']+m.lcloggedinsalesperson+[' and cust_code=']+m.lcUserinput+[']
>
>Which limits searches to your own customers... unless a hacker enters a customer code like
>
>
' or cust_code like '%
>
>And then the query is concatenated:
>
>
select * from customers where salesperson='dlitvak' and cust_code='' or cust_code like '%'
>
>and now the hacker browses the entire customer list. In remote databases, injection has been used destructively by hackers and annoyed ex-employees- e.g. hacker enters
>
>
';drop table customers--
>
>
select * from customers where salesperson='dlitvak' and cust_code='' ; drop table customers--
>
>and now there's no customers table.
>
>In contrast, this is immune to the problem:
>
select * from customers where salesperson=?lcloggedinsalesperson and cust_code=?lcuserinput
Thank you, John.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform