You are here

API.txt in Security Review 7

Same filename and directory in other branches
  1. 8 API.txt
  2. 6 API.txt
## Security Review API

* hook_security_checks() and check returns
* Check help
* Standalone use of the checklist
* Drush

### hook_security_checks()

Checks returned from an implementation of hook_security_checks() look like the
following.

array(
  $namespace => array(
    $check_name => array(
     'title' => 'Simple title of this check',
     'callback' => 'function to invoke for check, see section on check returns',
     'success' => 'One-line description of a successful check',
     'failure' => 'One-line description of a failed check listing what the risk is',
    )
  )
)

The top level index is often the module name. Each check name (not title) should
attempt to be unique.

### Check return values

A check can return a boolean or NULL. A return value of TRUE means the check
passed and the 'success' description will be used. FALSE means failure. A return
value of NULL is used in case the check can not run for any reason, an example
being if a dependency is nesecessary to run the check and that depenency is not
met.

### Check help

Implement $callback . '_help' to provide help for a check.

Help functions should return an array like so:

array(
  'title' => '',
  'descriptions' => array('Check descriptions', 'Link off to something'),
  'findings' => array(
    'descriptions' => array('Descriptions of findings'),
    'items' => array('Specific findings'),
  )
)

Consult security_review.help.inc for details.

## Standalone use of the checklist

The Security Review module need not be installed to use the checklist, though
no logging, UI, or check result storage will be available.

To run the checklist include the following code in your own module.

  include_once('security_review.inc');
  $checklist = security_review_get_checklist();
  $checklist_results = security_review_run($checklist);

Note that the some checks may take long to complete, so it is advised that you
plan accordingly or unset those checks.

## Drush

Run the checklist via Drush with the following command

drush security-review

Consult the Drush help on the security-review command for more information.

You can also run the drush command without installing the module so long as the
the security_review.drush.inc and security_review.inc files can be found by
drush. For instance you could place these files in your ~/.drush/ directory.

File

API.txt
View source
  1. ## Security Review API
  2. * hook_security_checks() and check returns
  3. * Check help
  4. * Standalone use of the checklist
  5. * Drush
  6. ### hook_security_checks()
  7. Checks returned from an implementation of hook_security_checks() look like the
  8. following.
  9. array(
  10. $namespace => array(
  11. $check_name => array(
  12. 'title' => 'Simple title of this check',
  13. 'callback' => 'function to invoke for check, see section on check returns',
  14. 'success' => 'One-line description of a successful check',
  15. 'failure' => 'One-line description of a failed check listing what the risk is',
  16. )
  17. )
  18. )
  19. The top level index is often the module name. Each check name (not title) should
  20. attempt to be unique.
  21. ### Check return values
  22. A check can return a boolean or NULL. A return value of TRUE means the check
  23. passed and the 'success' description will be used. FALSE means failure. A return
  24. value of NULL is used in case the check can not run for any reason, an example
  25. being if a dependency is nesecessary to run the check and that depenency is not
  26. met.
  27. ### Check help
  28. Implement $callback . '_help' to provide help for a check.
  29. Help functions should return an array like so:
  30. array(
  31. 'title' => '',
  32. 'descriptions' => array('Check descriptions', 'Link off to something'),
  33. 'findings' => array(
  34. 'descriptions' => array('Descriptions of findings'),
  35. 'items' => array('Specific findings'),
  36. )
  37. )
  38. Consult security_review.help.inc for details.
  39. ## Standalone use of the checklist
  40. The Security Review module need not be installed to use the checklist, though
  41. no logging, UI, or check result storage will be available.
  42. To run the checklist include the following code in your own module.
  43. include_once('security_review.inc');
  44. $checklist = security_review_get_checklist();
  45. $checklist_results = security_review_run($checklist);
  46. Note that the some checks may take long to complete, so it is advised that you
  47. plan accordingly or unset those checks.
  48. ## Drush
  49. Run the checklist via Drush with the following command
  50. drush security-review
  51. Consult the Drush help on the security-review command for more information.
  52. You can also run the drush command without installing the module so long as the
  53. the security_review.drush.inc and security_review.inc files can be found by
  54. drush. For instance you could place these files in your ~/.drush/ directory.