Skip to content

Commit c697053

Browse files
authored
Merge pull request #11399 from danog/always_run_taint_analysis
Always run taint analysis by default
2 parents c65b0f0 + ac7ce8c commit c697053

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

config.xsd

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<xs:attribute name="skipChecksOnUnresolvableIncludes" type="xs:boolean" default="false" />
7979
<xs:attribute name="sealAllMethods" type="xs:boolean" default="true" />
8080
<xs:attribute name="sealAllProperties" type="xs:boolean" default="true" />
81-
<xs:attribute name="runTaintAnalysis" type="xs:boolean" default="false" />
81+
<xs:attribute name="runTaintAnalysis" type="xs:boolean" default="true" />
8282
<xs:attribute name="usePhpStormMetaPath" type="xs:boolean" default="true" />
8383
<xs:attribute name="allowInternalNamedArgumentCalls" type="xs:boolean" default="true" />
8484
<xs:attribute name="allowNamedArgumentCalls" type="xs:boolean" default="true" />

docs/running_psalm/configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ When `true`, Psalm will treat all classes as if they had sealed properties, mean
387387
>
388388
```
389389

390-
When `true`, Psalm will run [Taint Analysis](../security_analysis/index.md) on your codebase. This config is the same as if you were running Psalm with `--taint-analysis`.
390+
When `true` (the default), Psalm will run [Taint Analysis](../security_analysis/index.md) on your codebase. This config is the same as if you were running Psalm with `--taint-analysis`.
391391

392392
#### reportInfo
393393

src/Psalm/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ final class Config
388388

389389
public bool $find_unused_issue_handler_suppression = true;
390390

391-
public bool $run_taint_analysis = false;
391+
public bool $run_taint_analysis = true;
392392

393393
public bool $use_phpstorm_meta_path = true;
394394

tests/EndToEnd/PsalmEndToEndTest.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ public function testAlter(): void
115115
{
116116
$this->runPsalmInit();
117117

118+
$psalmXml = file_get_contents(self::$tmpDir . '/psalm.xml');
119+
$psalmXml = str_replace('<psalm', '<psalm runTaintAnalysis="false"', (string)$psalmXml);
120+
file_put_contents(self::$tmpDir . '/psalm.xml', $psalmXml);
121+
118122
$this->assertStringContainsString(
119123
'No errors found!',
120124
$this->runPsalm(['--alter', '--issues=all'], self::$tmpDir, false, true)['STDOUT'],
@@ -126,13 +130,21 @@ public function testAlter(): void
126130
public function testPsalter(): void
127131
{
128132
$this->runPsalmInit();
133+
$psalmXml = file_get_contents(self::$tmpDir . '/psalm.xml');
134+
$psalmXml = str_replace('<psalm', '<psalm runTaintAnalysis="false"', (string)$psalmXml);
135+
file_put_contents(self::$tmpDir . '/psalm.xml', $psalmXml);
136+
129137
(new Process([PHP_BINARY, $this->psalter, '--alter', '--issues=InvalidReturnType'], self::$tmpDir))->mustRun();
130138
$this->assertSame(0, $this->runPsalm([], self::$tmpDir)['CODE']);
131139
}
132140

133141
public function testPsalm(): void
134142
{
135143
$this->runPsalmInit(1);
144+
$psalmXml = file_get_contents(self::$tmpDir . '/psalm.xml');
145+
$psalmXml = str_replace('<psalm', '<psalm runTaintAnalysis="false"', (string)$psalmXml);
146+
file_put_contents(self::$tmpDir . '/psalm.xml', $psalmXml);
147+
136148
$result = $this->runPsalm([], self::$tmpDir, true);
137149
$this->assertStringContainsString(
138150
'Target PHP version: 7.1 (inferred from composer.json)',
@@ -169,6 +181,10 @@ public function testPsalmDiff(): void
169181
copy(__DIR__ . '/../fixtures/DummyProjectWithErrors/diff_composer.lock', self::$tmpDir . '/composer.lock');
170182

171183
$this->runPsalmInit(1);
184+
$psalmXml = file_get_contents(self::$tmpDir . '/psalm.xml');
185+
$psalmXml = str_replace('<psalm', '<psalm runTaintAnalysis="false"', (string)$psalmXml);
186+
file_put_contents(self::$tmpDir . '/psalm.xml', $psalmXml);
187+
172188
$result = $this->runPsalm(['--diff', '-m'], self::$tmpDir, true);
173189
$this->assertStringContainsString('InvalidReturnType', $result['STDOUT']);
174190
$this->assertStringContainsString('InvalidReturnStatement', $result['STDOUT']);
@@ -268,7 +284,7 @@ public function testPsalmWithNoProgressDoesNotProduceOutputOnStderr(): void
268284

269285
$psalmXml = file_get_contents(self::$tmpDir . '/psalm.xml');
270286
assert($psalmXml !== false);
271-
$psalmXml = (string) preg_replace('/findUnusedCode="(true|false)"/', '', $psalmXml, 1);
287+
$psalmXml = (string) preg_replace('/findUnusedCode="(true|false)"/', 'runTaintAnalysis="false"', $psalmXml, 1);
272288
file_put_contents(self::$tmpDir . '/psalm.xml', $psalmXml);
273289

274290
$result = $this->runPsalm(['--no-progress'], self::$tmpDir);

0 commit comments

Comments
 (0)