You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-7Lines changed: 38 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
phpcs-security-audit v2
1
+
phpcs-security-audit v3
2
2
=======================
3
3
4
4
About
@@ -7,13 +7,12 @@ phpcs-security-audit is a set of [PHP_CodeSniffer](https://github.com/squizlabs/
7
7
8
8
It currently has core PHP rules as well as Drupal 7 specific rules.
9
9
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.
11
11
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/)).
13
13
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).
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.
31
32
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
-
34
33
If you want to integrate it all with Jenkins, go see http://jenkins-php.org/ for extensive help.
35
34
36
35
@@ -116,12 +115,44 @@ You are not required to do your own sniffs for the modification to be useful, si
116
115
If you implement any public cms/framework customization please make a pull request to help the project grows.
117
116
118
117
118
+
Contribute
119
+
----------
120
+
It is possible to install with a `git clone` and play with it in the same folder.
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
* 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
+
119
149
Annoyances
120
150
----------
121
151
122
152
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.
123
153
124
154
* 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.
125
156
* 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.
126
157
* 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.
0 commit comments