-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EAR taint checker: traverse callers when connecting the sources and s…
…inks (#319)
- Loading branch information
1 parent
99e3a7f
commit c0094bf
Showing
7 changed files
with
167 additions
and
52 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
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
42 changes: 42 additions & 0 deletions
42
internal/pkg/levee/testdata/src/levee_analysistest/ear/tests/call/callee-src-sink.go
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,42 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package call | ||
|
||
import ( | ||
"levee_analysistest/example/core" | ||
) | ||
|
||
func sinkf2(i interface{}) { | ||
core.Sink(i) // want "a source has reached a sink" | ||
} | ||
|
||
func createSource2() interface{} { | ||
return &core.Source{} | ||
} | ||
|
||
func identity(arg interface{}) interface{} { | ||
return arg | ||
} | ||
|
||
// Test the case where: | ||
// (1) the sink function doesn't embed the source function; and | ||
// (2) the source function doesn't embed the sink function. | ||
func TestSrcSinkInDifferentCallees() { | ||
// The source is created in a callee. | ||
s := createSource2() | ||
i := identity(s) | ||
// The sink is within another callee. | ||
sinkf2(i) | ||
} |
39 changes: 39 additions & 0 deletions
39
internal/pkg/levee/testdata/src/levee_analysistest/ear/tests/call/callee-src.go
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,39 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package call | ||
|
||
import ( | ||
"levee_analysistest/example/core" | ||
) | ||
|
||
func sinkf1(i interface{}) { | ||
core.Sink(i) // want "a source has reached a sink" | ||
} | ||
|
||
func f1(s string) { | ||
sinkf1(s) | ||
} | ||
|
||
func createData() string { | ||
src := &core.Source{} | ||
return src.Data | ||
} | ||
|
||
// Test the case where the source is introduced in callees. | ||
func TestSrcInCallees() { | ||
s := createData() | ||
core.Sink(s) // want "a source has reached a sink" | ||
f1(s) | ||
} |
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