## Zend_Environment_Security_Test

Description

- abstract:

Located in /Environment/Security/Test.php (line 30)

Direct descendents

Class | Description
--- | ---
Zend_Environment_Security_Test_CGI |
Zend_Environment_Security_Test_Core |
Zend_Environment_Security_Test_Curl |
Zend_Environment_Security_Test_Session |

Class Constant Summary
COMMON_TMPDIR = '/tmp'
LANG_DEFAULT = 'en'
MOREINFO_BASEURL = 'http://phpsec.org/projects/phpsecinfo/tests/'
RESULT_ERROR = -1024
RESULT_NOTICE = -2
RESULT_NOTRUN = -2048
RESULT_OK = -1
RESULT_WARN = -4
Variable Summary
mixed $_current_value
mixed $_data
string $_group
string $_language
string $_message
array $_messages
string $_name
mixed $_recommended_value
integer $_result
Method Summary
PhpSecInfo_Test __construct ()
string getCurrentTestValue ()
boolean|mixed getIniValue (string $ini_key)
string getMessage ()
string|boolean getMoreInfoURL ()
string getRecommendedTestValue ()
integer getResult ()
string getStringValue (mixed $val)
string getTestGroup ()
string getTestName ()
boolean isTestable ()
boolean osIsWindows ()
integer returnBytes (string $val)
void setMessageForResult (integer $result_code, [string $language_code = self::LANG_DEFAULT], string $message)
void setTestGroup ( $_group, string $test_group)
void setTestName ( $_name, string $test_name)
string|NULL sys_get_temp_dir ()
void test ()
integer _execTest ()
void _retrieveCurrentValue ()
void _setMessage (integer $result_code, string $language_code)
void _setMessages ()
void _setResult (integer $result_code)
Variables
mixed $_current_value = NULL (line 104)

Enter description here...

- access: protected

mixed $_data = array(
) (line 121)

- access: protected
- todo: move most properties into this array

string $_group = NULL (line 57)

This value is used to group test results together.

For example, all tests related to the mysql lib should be grouped under "mysql."

- access: protected

Redefined in descendants as:

- Zend_Environment_Security_Test_CGI::$_group
- Zend_Environment_Security_Test_Core::$_group
- Zend_Environment_Security_Test_Curl::$_group
- Zend_Environment_Security_Test_Session::$_group

string $_language = self::LANG_DEFAULT (line 97)

the language code. Should be a pointer to the setting in the PhpSecInfo object

- access: protected

string $_message = NULL (line 89)

The message corresponding to the result of the test

- access: protected

array $_messages = array() (line 116)

This is a hash of messages that correspond to various test result levels.

There are five messages, each corresponding to one of the result constants (self::RESULT_OK, self::RESULT_NOTICE, self::RESULT_WARN, self::RESULT_ERROR, self::RESULT_NOTRUN)

- access: protected

string $_name = NULL (line 65)

This should be a unique, human-readable identifier for this test

- access: protected

Redefined in descendants as:

- Zend_Environment_Security_Test_CGI_ForceRedirect::$_name
- Zend_Environment_Security_Test_Curl_FileSupport::$_name

mixed $_recommended_value = NULL (line 73)

This is the recommended value the test will be looking for

- access: protected

Redefined in descendants as:

- Zend_Environment_Security_Test_CGI_ForceRedirect::$_recommended_value
- Zend_Environment_Security_Test_Curl_FileSupport::$_recommended_value

integer $_result = self::RESULT_NOTRUN (line 81)

The result returned from the test

- access: protected

Methods
Constructor __construct (line 132)

Constructor for Test skeleton class

- access: public

PhpSecInfo_Test __construct ()
getCurrentTestValue (line 259)

returns the current value. This function should be used to access the value for display. All values are cast as strings

- access: public

string getCurrentTestValue ()
getIniValue (line 434)

This method converts the several possible return values from allegedly "boolean" ini settings to proper booleans

Properly converted input values are: 'off', 'on', 'false', 'true', '', '0', '1' (the last two might not be neccessary, but I'd rather be safe)

If the ini_value doesn't match any of those, the value is returned as-is.

- access: protected

boolean|mixed getIniValue (string $ini_key)

- string $ini_key: the ini_key you need the value of

getMessage (line 214)

Retrieves the message for the current result

- access: public

string getMessage ()
getMoreInfoURL (line 306)

Returns a link to a page with detailed information about the test

URL is formatted as self::MOREINFO_BASEURL + testName

- access: public
- see: self::MOREINFO_BASEURL

string|boolean getMoreInfoURL ()
getRecommendedTestValue (line 269)

returns the recommended value. This function should be used to access the value for display. All values are cast as strings

- access: public

string getRecommendedTestValue ()
getResult (line 202)

Retrieves the result

- access: public

integer getResult ()
getStringValue (line 413)

This just does the usual PHP string casting, except for the boolean FALSE value, where the string "0" is returned instead of an empty string

- access: protected

string getStringValue (mixed $val)

- mixed $val

getTestGroup (line 354)

Returns the test group this test belongs to

- access: public

string getTestGroup ()
getTestName (line 324)

This retrieves the name of this test.

If a name has not been set, this returns a formatted version of the class name.

- access: public

string getTestName ()
isTestable (line 150)

Determines whether or not it's appropriate to run this test (for example, if this test is for a particular library, it shouldn't be run if the lib isn't loaded).

This is a terrible name, but I couldn't think of a better one atm.

- abstract:
- access: public

boolean isTestable ()

Redefined in descendants as:

- Zend_Environment_Security_Test_CGI::isTestable() : No CGI tests should be run if the CGI SAPI isn't being used
- Zend_Environment_Security_Test_Core::isTestable() : "Core" tests should pretty much be always testable, so the default is just to return true
- Zend_Environment_Security_Test_Core_AllowUrlInclude::isTestable() : allow_url_include is only available since PHP 5.2
- Zend_Environment_Security_Test_Core_MagicQuotesGPC::isTestable() : magic_quotes_gpc has been removed since PHP 6.0
- Zend_Environment_Security_Test_Core_RegisterGlobals::isTestable() : register_globals has been removed since PHP 6.0
- Zend_Environment_Security_Test_Core_UploadTmpDir::isTestable() : We are disabling this function on Windows OSes right now until we can be certain of the proper way to check world-readability
- Zend_Environment_Security_Test_Curl::isTestable() : if curl extension is not loaded, no curl tests should be run
- Zend_Environment_Security_Test_Session::isTestable() : "Session" tests should pretty much be always testable, so the default is just to return true

osIsWindows (line 495)

A quick function to determine whether we're running on Windows.

Uses the PHP_OS constant.

- access: public

boolean osIsWindows ()
returnBytes (line 383)

This function takes the shorthand notation used in memory limit settings for PHP and returns the byte value. Totally stolen from http://us3.php.net/manual/en/function.ini-get.php

1. echo 'post_max_size in bytes = ' . $this->return_bytes(ini_get('post_max_size'));

- access: protected
- link: http://php.net/manual/en/function.ini-get.php

integer returnBytes (string $val)

- string $val

setMessageForResult (line 236)

Sets the message for a given result code and language

1. $this->setMessageForResult(self::RESULT_NOTRUN, 'en', 'This test cannot be run');

- access: protected

void setMessageForResult (integer $result_code, [string $language_code = self::LANG_DEFAULT], string $message)

- integer $result_code
- string $language_code
- string $message

setTestGroup (line 365)

sets the test group. This is private, and intended for loading data from an external config file (to-do)

- access: protected

void setTestGroup ( $_group, string $test_group)

- string $test_group
- $_group

setTestName (line 344)

sets the test name. This is private, and intended for loading data from an external config file (to-do)

- access: protected

void setTestName ( $_name, string $test_name)

- string $test_name
- $_name

sys_get_temp_dir (line 475)

sys_get_temp_dir provides some temp dir detection capability that is lacking in versions of PHP that do not have the sys_get_temp_dir() function

- access: public

string|NULL sys_get_temp_dir ()
test (line 189)

This is the wrapper that executes the test and sets the result code and message

- access: public

void test ()
_execTest (line 158)

The "meat" of the test. This is where the real test code goes. You should override this when extending

- abstract:
- access: protected

integer _execTest ()

Redefined in descendants as:

- Zend_Environment_Security_Test_CGI_ForceRedirect::_execTest() : Checks to see if cgi.force_redirect is enabled
- Zend_Environment_Security_Test_Core_AllowUrlFopen::_execTest() : Checks to see if allow_url_fopen is enabled
- Zend_Environment_Security_Test_Core_AllowUrlInclude::_execTest() : Checks to see if allow_url_fopen is enabled
- Zend_Environment_Security_Test_Core_DisplayErrors::_execTest() : Checks to see if display_errors is enabled
- Zend_Environment_Security_Test_Core_ExposePhp::_execTest() : Checks to see if expose_php is enabled
- Zend_Environment_Security_Test_Core_FileUploads::_execTest() : Checks to see if expose_php is enabled
- Zend_Environment_Security_Test_Core_Gid::_execTest() : Checks the GID of the PHP process to make sure it is above PHPSECINFO_MIN_SAFE_GID
- Zend_Environment_Security_Test_Core_MagicQuotesGPC::_execTest() : Checks to see if allow_url_fopen is enabled
- Zend_Environment_Security_Test_Core_MemoryLimit::_execTest() : Check to see if the memory_limit setting is enabled.
- Zend_Environment_Security_Test_Core_OpenBasedir::_execTest() : Checks to see if allow_url_fopen is enabled
- Zend_Environment_Security_Test_Core_PostMaxSize::_execTest() : Check to see if the post_max_size setting is enabled.
- Zend_Environment_Security_Test_Core_RegisterGlobals::_execTest() : Checks to see if allow_url_fopen is enabled
- Zend_Environment_Security_Test_Core_Uid::_execTest() : Checks the GID of the PHP process to make sure it is above PHPSECINFO_MIN_SAFE_UID
- Zend_Environment_Security_Test_Core_UploadMaxFilesize::_execTest() : Check to see if the post_max_size setting is enabled.
- Zend_Environment_Security_Test_Core_UploadTmpDir::_execTest() : Check if upload_tmp_dir matches self::COMMON_TMPDIR, or is word-writable
- Zend_Environment_Security_Test_Curl_FileSupport::_execTest() : Checks to see if libcurl's "file://" support is enabled by examining the "protocols" array
- Zend_Environment_Security_Test_Session_UseTransSid::_execTest() : Checks to see if allow_url_fopen is enabled

_retrieveCurrentValue (line 182)

Placeholder - extend for tests

- abstract:
- access: protected

void _retrieveCurrentValue ()

Redefined in descendants as:

- Zend_Environment_Security_Test_CGI_ForceRedirect::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_AllowUrlFopen::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_AllowUrlInclude::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_DisplayErrors::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_ExposePhp::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_FileUploads::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_Gid::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_MagicQuotesGPC::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_MemoryLimit::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_OpenBasedir::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_PostMaxSize::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_RegisterGlobals::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_Uid::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_UploadMaxFilesize::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Core_UploadTmpDir::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Curl_FileSupport::_retrieveCurrentValue()
- Zend_Environment_Security_Test_Session_UseTransSid::_retrieveCurrentValue()

_setMessage (line 290)

Sets the $this->_message variable based on the passed result and language codes

- access: protected

void _setMessage (integer $result_code, string $language_code)

- integer $result_code
- string $language_code

_setMessages (line 170)

This function loads up result messages into the $this->_messages array.

Using this method rather than setting $this->_messages directly allows result messages to be inherited. This is broken out into a separate function rather than the constructor for ease of extension purposes (don't have to include a __construct() method in all extended classes).

- access: protected

void _setMessages ()

Redefined in descendants as:

- Zend_Environment_Security_Test_CGI::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_CGI_ForceRedirect::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_AllowUrlFopen::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_AllowUrlInclude::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_DisplayErrors::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_ExposePhp::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_FileUploads::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_Gid::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_MagicQuotesGPC::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_MemoryLimit::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_OpenBasedir::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_PostMaxSize::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_RegisterGlobals::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_Uid::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_UploadMaxFilesize::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Core_UploadTmpDir::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Curl::_setMessages() : Extended for curl-specific message
- Zend_Environment_Security_Test_Curl_FileSupport::_setMessages() : Set the messages specific to this test
- Zend_Environment_Security_Test_Session_UseTransSid::_setMessages() : Set the messages specific to this test

_setResult (line 279)

Sets the result code

- access: protected

void _setResult (integer $result_code)

- integer $result_code

Class Constants
COMMON_TMPDIR = '/tmp' (line 44)
LANG_DEFAULT = 'en' (line 32)
MOREINFO_BASEURL = 'http://phpsec.org/projects/phpsecinfo/tests/' (line 46)
RESULT_ERROR = -1024 (line 40)
RESULT_NOTICE = -2 (line 36)
RESULT_NOTRUN = -2048 (line 42)
RESULT_OK = -1 (line 34)
RESULT_WARN = -4 (line 38)

Documentation generated on Wed, 21 Feb 2007 12:03:02 -0800 by phpDocumentor 1.3.1