- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Obviously somebody hasn't used Windows 2003 Server where EVERYTHING is disabled by default. IIS6 doesn't install by default, services are disabled, etc etc. I think you meant "classic Windows security" which I will admit (being a Unix Admin myself) was horrible. But if I'm going to defend Windows I should also point out that IIS6 is almost 2 years old and there hasn't been a single security flaw found, Apache (both 1.. and 2.0 have had many, about 7 in the past 2 years.
Admin
Well you have now hardcoded two seperate and unrelated systems. Your application cannot scale well because it assume the database will be structured one specific way. Your problem is that you are mixing layers, presentation layer should not understand the logic of a system that's on another box. If somebody comes along and wants to improve the database, they MUST modify your code. If they need to use a whole different database solution, they will have to modify your code again (instead of just the connection data, which should be outside the code anyways).
And I won't even get into the security issue of sql injection, you can Google if you don't know about that.
Leave it to say, it's systems like YOURS that hackers love.
Admin
Sean Connery is right. A SQL-based approach to the front end is very secure, if you know what you are doing. And, such an approach is extremely maintainable, if care was taken to structure everything well. Finally, there is such a thing as legitimate power users. (Gasp!) If nothing else, it makes it easier for other programmers to use your web site in interesting ways.
Such an approach can lead to a very powerful and flexible front-end. Personally, I'd rather see more SQL-based frontends than 1,000,001 ad-hoc query languages that get buggily translated to SQL, or worse, a site that offers nothing more than a few pre-programmed queries to their users.
Storing SQL in the URL string has the distinct advantage that now queries that originated with your web address are conveniently located in your webserver's log.
Not to mention that the page already almost conforms to the RESTful philosophy of web development, which is probably a good philosophy to be using in the context to a web-interface to a database. (I can think of other web situations where REST is not applicable... Can you?)
It all depends on the context. There simply hasn't been enough context in any of these discussions to make any real judgement on the merits and demerits of any approach described here. I've read little more than ideology.
Beware the 180 degree turn. Be wary of the knee-jerk reaction. Recognize that one data point does not a curve make. All things in moderation, especially moderation.
Now, what would be the best way to protect a site that opens up their database in such a way from SQL injection attacks? Properly setting up user accounts is a big start, but even that is not necessary. (Though I certainly would set up accounts, special views, and column permissions.)
Sit down with the SQL grammar. Find a restricted grammar that produces a subset of SQL that you find acceptable. Then write a parser that recognizes that subset... it doesn't even have to do anything with the SQL command. (After all, a parser is not a compiler.) You should have the programming ability to do this without using YACC or regular expressions. (If you are using regular expressions here, I almost guarantee it won't work.)
All your parser does is check that a query is in your restricted SQL grammar, and maybe some simple checks that can't be encoded in grammar. If your parser says, "yes! that string is in my grammar!" then pass it along, unchanged, to your SQL backend. Otherwise, return an error message indicating the point at which your parser stopped recognizing the string, and what could happen after that point.
This really isn't difficult. But, oh yeah, I forgot. 80% of programmers with a B.S. in Computer Science don't really understand context-free grammars. Handed a CFG, they couldn't write a robust parser to save their life, let alone modify the grammar to suit their purposes. This is why we have such atrocities as the DOM, the W3C's verbose and easily-misunderstood English definition of XML, and widespread abuse of regular expressions.
And no, that's not ideology. Context free grammars are a fundamental concept in computer science. They are not tied to any particular programming language, software engineering philosophy, or development methodology.