Skip to content

Commit

Permalink
Add text field
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasReschke committed Nov 17, 2020
1 parent 061116c commit 9ac917b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion foo.sarif
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2.1.0","runs":[{"tool":{"driver":{"name":"Psalm","version":"dev-master@4e8fb9c37f182f9f556f2d2d95d7e1d824490175","rules":[{"id":"205","name":"TaintedInput","shortDescription":{"text":"TaintedInput"},"properties":{"tags":["security"]},"help":{"markdown":"# TaintedInput\n\nEmitted when tainted input detection is turned on\n"}}]}},"results":[{"ruleId":"205","message":{"text":"Detected tainted html"},"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":3,"endLine":3,"startColumn":6,"endColumn":19}}}],"codeFlows":[{"message":{"text":"Tracing the path from user input to insecure usage"},"threadFlows":[{"locations":[{"location":{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":3,"endLine":3,"startColumn":6,"endColumn":12}}}},{"location":{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":3,"endLine":3,"startColumn":6,"endColumn":19}}}}]}]}]}]}]}
{"version":"2.1.0","runs":[{"tool":{"driver":{"name":"Psalm","version":"dev-master@4e8fb9c37f182f9f556f2d2d95d7e1d824490175","rules":[{"id":"205","name":"TaintedInput","shortDescription":{"text":"TaintedInput"},"properties":{"tags":["security"]},"help":{"markdown":"# TaintedInput\n\nEmitted when tainted input detection is turned on\n","text":"# TaintedInput\n\nEmitted when tainted input detection is turned on\n"}}]}},"results":[{"ruleId":"205","message":{"text":"Detected tainted shell"},"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":3,"endLine":3,"startColumn":12,"endColumn":24}}}],"codeFlows":[{"message":{"text":"Tracing the path from user input to insecure usage"},"threadFlows":[{"locations":[{"location":{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":3,"endLine":3,"startColumn":12,"endColumn":17}}}},{"location":{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":3,"endLine":3,"startColumn":12,"endColumn":24}}}}]}]}]},{"ruleId":"205","message":{"text":"Detected tainted html"},"level":"error","locations":[{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":4,"endLine":4,"startColumn":6,"endColumn":19}}}],"codeFlows":[{"message":{"text":"Tracing the path from user input to insecure usage"},"threadFlows":[{"locations":[{"location":{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":4,"endLine":4,"startColumn":6,"endColumn":12}}}},{"location":{"physicalLocation":{"artifactLocation":{"uri":"test.php"},"region":{"startLine":4,"endLine":4,"startColumn":6,"endColumn":19}}}}]}]}]}]}]}
8 changes: 6 additions & 2 deletions src/Psalm/Report/SarifReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Psalm\Config;
use Psalm\Issue;
use Psalm\Report;
use function file_exists;
use function file_get_contents;

/**
* SARIF report format suitable for import into any SARIF compatible solution
Expand Down Expand Up @@ -48,8 +50,10 @@ public function create(): string
];

$markdown_documentation_path = __DIR__ . '/../../../docs/running_psalm/issues/' . $issue_data->type . '.md';
if(file_exists($markdown_documentation_path)) {
$rules[$issue_data->shortcode]['help']['markdown'] = file_get_contents($markdown_documentation_path);
if (file_exists($markdown_documentation_path)) {
$markdown_documentation = file_get_contents($markdown_documentation_path);
$rules[$issue_data->shortcode]['help']['markdown'] = $markdown_documentation;
$rules[$issue_data->shortcode]['help']['text'] = $markdown_documentation;
}

$jsonEntry = [
Expand Down
3 changes: 2 additions & 1 deletion tests/ReportOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public function testSarifReport(): void
],
],
'help' => [
'markdown' => file_get_contents(__DIR__ . '/../docs/running_psalm/issues/TaintedInput.md')
'markdown' => file_get_contents(__DIR__ . '/../docs/running_psalm/issues/TaintedInput.md'),
'text' => file_get_contents(__DIR__ . '/../docs/running_psalm/issues/TaintedInput.md'),
],
]
]
Expand Down

0 comments on commit 9ac917b

Please sign in to comment.