User Control Panel
Advertisements

HELP US, HELP YOU!

MarzQL
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Bot Depot Forum Index -> Modules & Add-ons
View unanswered posts
Author Message
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Thu Feb 03, 2005 11:59 pm    Post subject: Reply with quote

The keys of the hash are the SQL field names and the values of the hash are the SQL field values.
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Sun Feb 06, 2005 5:10 am    Post subject: Reply with quote

A minor update has been posted. Changes are noted in the readme. MarzQL 1.1.0
_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Mon Feb 07, 2005 6:55 am    Post subject: Reply with quote

QUOTE(alienz @ Feb 3 2005, 03:06 PM)
Ok, but wouldn't injection only be bad if say, someone else could put them in?

True. I assume however that you expect your code to be used by new people to programming. If so then not letting them use placeholders effectively teaches them not to. What if they do something like

Code:
<br />if ($msg =~ /find user (.*)/) {<br />  my $user = $db->select("SELECT * FROM users where user_name = $1");<br />}<br />


You now have a gapping security whole. Granted it might not be your modules job to baby sit programmers, but adding a small amount of code to the module could get new users the following code instead.


Code:
<br />if ($msg =~ /find user (.*)/) {<br />  my $user = $db->select("SELECT * FROM users where user_name = ?", $1);<br />}<br />


Such a minor change encourages the learning of good practices and greatly enhances the security of the code.

_________________
Eric256
Proud previous owner and current admin of Bot-depot.com
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Mon Feb 07, 2005 4:40 pm    Post subject: Reply with quote

I've been working on using placeholders. I've managed to be able to pass the SQL statement with the placeholder and the values it needs, but then it keeps telling me the query fields don't match the number of fields on execution. Blah. This occurs when I try to send two values with placeholders, which was my first test..I haven't gotten any further yet because of some other things.

As for the injection, you have a good point. Currently it's best to use this module internally, where you control the values being sent and not the user. However, I personally haven't even found a reason for allowing users to introduce any values to the database yet. The majority of the db interaction is internal to the bot. So...if you're using this module, please be aware of SQL injection! Don't allow users the ability to introduce their own values to the db. Once I have the code in place for using placeholders, this will be fixed. Wink

_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
mattaustin
Sentinel
Sentinel


Joined: 19 Jul 2004
Posts: 556
Location: Los Angeles, CA
Reputation: 50.7
votes: 1

PostPosted: Tue Feb 08, 2005 3:15 am    Post subject: Reply with quote

I think the point eveone is trying to make here, is that this module is rather pointless sence you just basically pass in sql statements anyways. Maybe you should just write a toturial on how to use mysql instead of waisting your time on this. It really does nothing new.

you have 6 subs that do exactly the same thing (take the sql statemsnt and run it)
altertable, drop, create, delete, update, insert

when it could be done with one DO call:
$dbh->do("CREATE TABLE foo (id INTEGER, name VARCHAR(20))");

_________________
[ matt ]
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Feb 08, 2005 12:13 pm    Post subject: Reply with quote

QUOTE(mattaustin @ Feb 7 2005, 10:15 PM)
I think the point eveone is trying to make here, is that this module is rather pointless

You are the first I've seen that says it's pointless, the other posts have been suggestions and constructive criticism. Besides passing the SQL, it also has some good error/debugging info and does profiling, so it does have a point.

_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Fri Feb 18, 2005 12:25 am    Post subject: Reply with quote

Update- This is version 2.0.0 of MarzQL. Several major changes have been done. The methods now all build the SQL for you, so instead of just passing the statement to them you pass a hashref of things like the table name, fields, etc. Where variables are supplied the methods now use placeholders. You can pass an array of values to be executed. Some you can pass the number of placeholders, others are fixed. View the examples in the readme for more. Here's a peek at one:

Code:
my @values = ("value",);<br />   my $database = {'table' =>'tablename', 'fields' =>'fieldnames', 'placeholders' =>'?'};<br />   $db->insert($database,@values);


Changes in this version include:
All methods now build the SQL statement and take placeholders where needed.
Database info now passed as a hashref.
Methods ALTER and CREATE renamed to ALTER_TABLE and CREATE_TABLE.
Added new methods SELECT_WHERE, UPDATE_WHERE.
Updated the readme.

NONE of the previous methods are depreciated, although they could be if there was enough of a demand.

Get it at the link in the beginning of the thread or here: MarzQL Module

_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Modules & Add-ons All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group