We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23478
    • 133 Posts
    hello

    I’ve just looked at the dbapi... so I explain you my wish to see modX being strengthen there.

    When I develop, I usually block SQL injection risk at the core level ... so if I ever forget one time at the frontend, it less risky. I’d like modX help doing so.

    I’d like the query function to be improved, including (before the mysql_query) a call to a check_hacking function

    function check_hacking($req)
    {
    $fail = false;
    
    if (strpos($req, 'union') !== false && preg_match('~(^|[^a-z])union($|[^[a-z])~s', $req) != 0)
    	$fail = true;
    // pas de comentaire dans les requêtes...
    // pas de ; qui sépare 2 requêtes
    elseif (strpos($req, '/*') > 2 || strpos($req, '--') !== false || strpos($req, ';') !== false)
    	$fail = true;
    // Tentative de chagement des mots de passe, de ralentissement ?
    elseif (strpos($req, 'set password') !== false && preg_match('~(^|[^a-z])set password($|[^[a-z])~s', $req) != 0)
    	$fail = true;
    elseif (strpos($req, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $req) != 0)
    	$fail = true;
    
    if($fail)
    	die("Tentative de Hacking");
    
    Return ;
    }


    The only drawback is the query function would one accept queries one by one...

    I’ve got a second wish, inspired by SMF code :
    instead of showing a message when the mysql_query return false, could you test the reason of the error ?
    For instance, when SMF has lost connexion with DBserver, it tries once again the whole bunch and send a mail to the webmaster saying there are SQL problems. thus, when operating a small server, the web admin knows when reaching the limits... and visitors are not bored with error pages.
      • 25663 MODX Staff
      • 12,272 Posts
      Good suggestions. I think you’ll see a lot more improvements to the DB API after the 0.9.5 release. wink
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me