13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Securing Your Code<br />

377<br />

n<br />

n<br />

Have your developers use some sort of testing methodology.This might not help<br />

us find all the bugs that a tester would, but this will definitely help the product<br />

from regressing—a phenomenon in which problems or bugs that were fixed some<br />

time ago are reintroduced because of other code changes. Developers should not<br />

be allowed to commit recent changes to the project unless all the unit tests continue<br />

to succeed.<br />

Monitor the application as it runs after it is deployed. By browsing regularly<br />

through the logs, looking at user/customer comments, you should be able to see if<br />

any major problems or possible security holes are cropping up. If so, you can act to<br />

address them before they become more serious.<br />

Execution Quotes <strong>and</strong> exec<br />

We briefly mentioned a feature previously called the shell comm<strong>and</strong> executor or execution<br />

quotes.This is basically a language operator via which you can execute arbitrary comm<strong>and</strong>s<br />

in a comm<strong>and</strong> shell (some flavor of sh under UNIX-like operating systems or<br />

cmd.exe under Windows) by enclosing the comm<strong>and</strong> in back quotes (`)—notice that<br />

they are different from regular single quotes (').The key is typically located in the<br />

upper-left of English-language keyboards <strong>and</strong> can be quite challenging to find on other<br />

keyboard layouts.<br />

Execution quotes return a string value with the text output of the program executed.<br />

If we had a text file with a list of names <strong>and</strong> phone numbers in it, we might use the<br />

grep comm<strong>and</strong> to find a list of names that contain “Smith” .grep is a UNIX-like comm<strong>and</strong><br />

that takes a string pattern to look for <strong>and</strong> list of files in which to find it. It turns<br />

those lines in those files that match the pattern to find.<br />

grep [args] pattern files-to-search...<br />

There are Windows versions of grep, <strong>and</strong> Windows does in fact ship with a program<br />

called findstr.exe, which can be used similarly.To find people named “Smith”, we could<br />

execute the following:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!