Skip to content

Commit 66845e0

Browse files
authored
Merge pull request #59 from jmarcil/master
updated readme to reflect v3 (coming soon)
2 parents a6b5c5e + 7dd17c0 commit 66845e0

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/vendor
2+
composer.lock

README.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
phpcs-security-audit v2
1+
phpcs-security-audit v3
22
=======================
33

44
About
@@ -7,13 +7,12 @@ phpcs-security-audit is a set of [PHP_CodeSniffer](https://github.com/squizlabs/
77

88
It currently has core PHP rules as well as Drupal 7 specific rules.
99

10-
The tool also checks for CVE issues and security advisories related to CMS/framework. Using it, you can follow the versioning of components during static code analysis.
10+
The tool also checks for CVE issues and security advisories related to the CMS/framework. This enable you to follow the versioning of components during static code analysis.
1111

12-
The main reason of this project for being an extension of PHP_CodeSniffer is to have easy integration into continuous integration systems. It is also able to find security bugs that are not detected with object oriented analysis (like in [RIPS](http://rips-scanner.sourceforge.net/) or [PHPMD](http://phpmd.org/)).
12+
The main reason of this project for being an extension of PHP_CodeSniffer is to have easy integration into continuous integration systems. It is also able to find security bugs that are not detected with some object oriented analysis (such as [PHPMD](http://phpmd.org/)).
1313

14-
phpcs-security-audit is backed by [Floe design + technologies](https://floedesign.ca/) and written by [Jonathan Marcil](https://twitter.com/jonathanmarcil).
14+
phpcs-security-audit in its beginning was backed by Pheromone (later on named Floe design + technologies) and written by [Jonathan Marcil](https://twitter.com/jonathanmarcil).
1515

16-
[<img src="https://floedesign.ca/img/thumbs/floe.jpg" alt="Floe design + technologies" width="100">](https://floedesign.ca/)
1716

1817

1918
Install
@@ -23,14 +22,14 @@ Requires [PHP CodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) version
2322

2423
The easiest way to install is using [Composer](https://getcomposer.org/):
2524
```
25+
#WARNING: this currently doesn't work up until the v3 package is released
26+
#See Contribute section bellow for git clone instruction
2627
composer require --dev pheromone/phpcs-security-audit
2728
./vendor/bin/phpcs --standard=./vendor/pheromone/phpcs-security-audit/example_base_ruleset.xml ./vendor/pheromone/phpcs-security-audit/tests.php
2829
```
2930

3031
This will also install the [DealerDirect Composer PHPCS plugin](https://github.com/Dealerdirect/phpcodesniffer-composer-installer/) which will register the `Security` standard with PHP_CodeSniffer.
3132

32-
It is also possible to install this based on a git clone. In that case, you will need to [register the package with PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths) yourself.
33-
3433
If you want to integrate it all with Jenkins, go see http://jenkins-php.org/ for extensive help.
3534

3635

@@ -116,12 +115,44 @@ You are not required to do your own sniffs for the modification to be useful, si
116115
If you implement any public cms/framework customization please make a pull request to help the project grows.
117116

118117

118+
Contribute
119+
----------
120+
It is possible to install with a `git clone` and play with it in the same folder.
121+
```
122+
composer install
123+
./vendor/bin/phpcs --standard=example_base_ruleset.xml --extensions=php tests.php
124+
```
125+
126+
By default it should set PHPCS to look in the current folder:
127+
```
128+
PHP CodeSniffer Config installed_paths set to ../../../
129+
```
130+
131+
If for any reason you need to change this (should work out of the box) you will need to `phpcs --config-set installed_paths` as explained in [PHP_CodeSniffer docs](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths).
132+
133+
Master can contain breaking changes, so people are better to rely on releases for stable versions.
134+
135+
Those release packages are available [here on GitHub](releases) or on [Packagist](https://packagist.org/packages/pheromone/phpcs-security-audit).
136+
137+
Some guidelines if you want to create new rules:
138+
* Ensure that `ParanoiaMode` controls how verbose your sniff is
139+
* If sometime the sniff is a valid security concern, run it when paranoia=true only
140+
* Warnings are generally issued instead of Errors for most-of-the-time when paranoia=false
141+
* Errors are always generated when you are use about user input being used
142+
* Prefer false positives (annoying results) over false negatives (missing results)
143+
* paranoia=false should solve false positive, otherwise warn on anything remotely suspicious
144+
* Include at least one test that trigger your sniff into `tests.php`
145+
* Keep it as a one liner, doesn't need to make sense
146+
* Don't forget to include your new sniff in the `example_base_ruleset.xml` and `example_drupal7_ruleset.xml` when it applies.
147+
148+
119149
Annoyances
120150
----------
121151

122152
As any security tools, this one comes with it's share of annoyance. At first a focus on finding vulnerabilities will be done, but later it is planned to have a phase where efforts will be towards reducing annoyances, in particular with the number of false positives.
123153

124154
* It's a generator of false positives. This can actually help you learn what are the weak functions in PHP. Paranoia mode will fix that by doing a major cut-off on warnings when set to 0.
155+
* This tool was created around 10 years ago. Some of its parts might look outdated, and support for old PHP code will still be present. The reality is that many code base scanned with it might be as old as the tool.
125156
* It's slow. On big Drupal modules and core it can take too much time (and RAM, reconfigure cli/php.ini to use 512M if needed) to run. Not sure if it's because of bugs in PHPCS or this set of rules, but will be investigated last. Meanwhile you can configure PHPCS to ignore big contrib modules (and run another instance of PHPCS for .info parsing only for them). An example is og taking hours, usually everything runs under 1-2 minutes and sometime around 5 minute. You can try using the `--parallel=8` (or another number) option to try and speed things up on supported OSes. Possible workaround is to use phpcs --ignore=folder to skip scanning of those parts.
126157
* For Drupal advisories checking: a module with multiple versions might be secure if a lesser fixed version exists and you'll still get the error or warning. Keep everything updated at latest as recommended on Drupal's website.
127158

0 commit comments

Comments
 (0)