forked from vimeo/psalm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation for taints and global configuration (vimeo#5098)
* [DOCS] Extend documentation on global variables configuration * [DOCS] Synchronize meaning of @psalm-taint-source input with source code * [DOCS] Add documentation for conditional @psalm-taint-escape * [DOCS] Add documentation for @psalm-taint-unescape
- Loading branch information
Showing
5 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
# Security analysis annotations | ||
|
||
## `@psalm-taint-source` | ||
## `@psalm-taint-source <taint-type>` | ||
|
||
See [Custom taint sources](custom_taint_sources.md#taint-source-annotation). | ||
|
||
## `@psalm-taint-sink` | ||
## `@psalm-taint-sink <taint-type> <param-name>` | ||
|
||
See [Custom taint sinks](custom_taint_sinks.md). | ||
|
||
## `@psalm-taint-escape` | ||
## `@psalm-taint-escape <taint-type #conditional>` | ||
|
||
See [Escaping tainted output](avoiding_false_positives.md#escaping-tainted-output). | ||
|
||
## `@psalm-taint-unescape <taint-type>` | ||
|
||
See [Unescaping statements](avoiding_false_negatives.md#unescaping-statements). | ||
|
||
## `@psalm-taint-specialize` | ||
|
||
See [Specializing taints in functions](avoiding_false_positives.md#specializing-taints-in-functions) and [Specializing taints in classes](avoiding_false_positives.md#specializing-taints-in-classes). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Avoiding false-negatives | ||
|
||
## Unescaping statements | ||
|
||
Post-processing previously escaped/encoded statements can cause insecure scenarios. | ||
`@psalm-taint-unescape <taint-type>` allows to declare those components insecure explicitly. | ||
|
||
```php | ||
<?php | ||
|
||
/** | ||
* @psalm-taint-unescape html | ||
*/ | ||
function decode(string $str): string | ||
{ | ||
return str_replace( | ||
['<', '>', '"', '''], | ||
['<', '>', '"', '"'], | ||
$str | ||
); | ||
} | ||
|
||
$safe = htmlspecialchars($_GET['text']); | ||
echo decode($safe); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters