Just for clarification, why is the query argument replacement done manually instead of using the db abstraction layer for the same?
function autopilot_save_target($target) {
$values = array(db_escape_string($target['name']),
db_escape_string($target['host']),
db_escape_string($target['path']),
db_escape_string($target['active']));
$query = "INSERT INTO {autopilot_targets} (name, host, path, active) values('%s', '%s', '%s', '%s')";
if ($target['tid']) {
$query = "UPDATE {autopilot_targets} set name='%s', host='%s', path='%s', active='%s' where tid=%s";
$values[] = $target['tid'];
}
$resultset = db_query(vsprintf($query, $values)); <---- why vsprintf instead of passing values into db_query?
}
Comments
Comment #1
IncrediblyKenzi commentedPartially force of habit, and partially because depending on how it's called (either a new target or an existing) there's a different number of arguments passed into the query.
Comment #2
IncrediblyKenzi commentedOop.. on closer inspection, db_query auto-handles this.. Cancel the second argument.. just force of habit :).
Comment #3
robertdouglass commentedCool. While I'm nitpicking... Drupal SQL is much nicer (and will play better with alternate drivers like Oracle) if the SQL keywords are capitalized: SET, WHERE, INSERT, DELETE etc.
Looking forward to the full release of this stuff =)
Comment #4
robertdouglass commentedComment #5
gregglesI also noticed that in _autopilot_admin_log_view_page($build_id)
By concatenating the build_id into the query you allow user submitted data (from the url, right?) into the query which is a potentially bad idea.
Granted only admins should be able to access this page, but this iss combined with account escalation could lead to further problems.
Comment #6
gregglesautopilot_get_target also does query building in a manner that skips the internal Drupal query protections.
I think that all of the queries (and the text handling, especially since this module doesn't use t()) could use a review.
Comment #7
akalsey commentedThese concerns are no longer an issue now that AP has been redone from the ground up.