-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[taint] Follow field accesses based on a config option
Summary: While it does make sense to follow field access for taint propagation in some cases in other cases it may result in FPs which are very hard to follow so this diff makes this behaviour configurable instead of unconditionally enable it based on a language. Reviewed By: skcho Differential Revision: D62099585 Privacy Context Container: L1208441 fbshipit-source-id: 1b801ec5962b4f41cce18380b92207e0b67ac6fc
- Loading branch information
1 parent
a9f9cd8
commit 19550b5
Showing
13 changed files
with
144 additions
and
1 deletion.
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
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
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
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
9 changes: 9 additions & 0 deletions
9
infer/tests/build_systems/pulse_taint_hack_no_follow_field_accesses/.inferconfig
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,9 @@ | ||
{ | ||
"scheduler": "callgraph", | ||
"pulse-specialization-partial": true, | ||
"pulse-taint-short-traces": true, | ||
"pulse-taint-follow-field-accesses": false, | ||
"pulse-taint-config": [ | ||
"taint_config.json" | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
infer/tests/build_systems/pulse_taint_hack_no_follow_field_accesses/Makefile
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,16 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
TESTS_DIR = ../.. | ||
|
||
INFER_OPTIONS = \ | ||
--pulse-only --debug-exceptions --no-pulse-force-continue | ||
|
||
INFERPRINT_OPTIONS = --issues-tests | ||
|
||
HH_SOURCES = $(sort $(wildcard hh/*.hack)) | ||
SOURCES = $(sort $(wildcard *.hack)) | ||
|
||
include $(TESTS_DIR)/hack.make |
10 changes: 10 additions & 0 deletions
10
infer/tests/build_systems/pulse_taint_hack_no_follow_field_accesses/hh/shapes.hack
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,10 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. | ||
// | ||
// This source code is licensed under the MIT license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
|
||
namespace Shapes; | ||
|
||
function unknown(mixed $sc): string { | ||
return "42"; | ||
} |
1 change: 1 addition & 0 deletions
1
infer/tests/build_systems/pulse_taint_hack_no_follow_field_accesses/issues.exp
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 @@ | ||
shapes.hack, Shapes::C1.passViaShapeGetBad, 2, TAINT_ERROR, no_bucket, ERROR, [source of the taint here: value passed as argument `#0` to `Shapes::C1.passViaShapeGetBad` with kind `Shapes`,flows to this sink: value passed as argument `#0` to `Shapes::ShapeLogger$static.taintSink` with kind `Shapes`], source: Shapes::C1.passViaShapeGetBad, sink: Shapes::ShapeLogger$static.taintSink, tainted expression: $s->debug_data |
55 changes: 55 additions & 0 deletions
55
infer/tests/build_systems/pulse_taint_hack_no_follow_field_accesses/shapes.hack
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,55 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. | ||
// | ||
// This source code is licensed under the MIT license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
|
||
namespace Shapes; | ||
|
||
class SensitiveClass { | ||
public string $sensitiveField = "42"; | ||
|
||
public function getId(): string { | ||
return $this->sensitiveField; | ||
} | ||
} | ||
|
||
class ShapeLogger { | ||
const type TSchemaShape = shape( | ||
'msg' => string, | ||
?'debug_data' => ?string, | ||
); | ||
|
||
public static function logData(this::TSchemaShape $data): void { | ||
self::taintSink($data); | ||
} | ||
|
||
public static function taintSink(mixed $data): void {} | ||
} | ||
|
||
class C1 { | ||
public function passViaShapeOk(SensitiveClass $sc): void { | ||
ShapeLogger::logData( | ||
shape('msg' => 'Oh-oh', 'debug_data' => $sc->sensitiveField), | ||
); | ||
} | ||
|
||
public function passViaShapeGetBad(SensitiveClass $sc): void { | ||
$s = shape('msg' => 'Oh-oh', 'debug_data' => $sc->sensitiveField); | ||
ShapeLogger::taintSink($s['debug_data']); | ||
} | ||
|
||
public function passUnrelatedViaShapeGetOk(SensitiveClass $sc): void { | ||
$s = shape('msg' => 'Oh-oh', 'debug_data' => $sc->sensitiveField); | ||
ShapeLogger::taintSink($s['msg']); | ||
} | ||
|
||
public function passViaUnknownOk(SensitiveClass $sc): void { | ||
$data = unknown($sc); | ||
ShapeLogger::logData(shape('msg' => 'Oh-oh', 'debug_data' => $data)); | ||
} | ||
|
||
public function passViaShapeAndUnknownOk(SensitiveClass $sc): void { | ||
$data = unknown(shape("sc" => $sc)); | ||
ShapeLogger::logData(shape('msg' => 'Oh-oh', 'debug_data' => $data)); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
infer/tests/build_systems/pulse_taint_hack_no_follow_field_accesses/taint_config.json
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,23 @@ | ||
{ | ||
"pulse-taint-sources": [ | ||
{ | ||
"procedure_regex": ".*", | ||
"taint_target": [ | ||
"ArgumentsMatchingTypes", | ||
[ | ||
"SensitiveClass" | ||
] | ||
], | ||
"kinds": ["Shapes"] | ||
} | ||
], | ||
"pulse-taint-sinks": [ | ||
{ "class_names": ["Shapes::ShapeLogger"], "method_names": ["taintSink"], "kinds": ["Shapes"] } | ||
], | ||
"pulse-taint-policies": [ | ||
{ | ||
"short_description": "Taint flow", | ||
"taint_flows": [{"source_kinds": ["Shapes"], "sink_kinds": ["Shapes"]}] | ||
} | ||
] | ||
} |