-
Notifications
You must be signed in to change notification settings - Fork 146
Swift Taint Tests #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
janniclas
wants to merge
24
commits into
development
Choose a base branch
from
f-swift_code_style
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+732
−175
Draft
Swift Taint Tests #592
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f41460c
updated codestyle of swift tests
janniclas 3397f94
added swift taint analysis tests
janniclas e068ca5
added todos in ifds taint analysis to support swift
janniclas 9fefb37
updated taint unit tests for swift
janniclas ec95a84
updated swift taint tests to correctly generate ir which contains an …
janniclas 298061f
removed old todo
janniclas 9b0c422
using the getElementPtr workaround in taint analysis flow function
janniclas e0bbc70
summary function for Swift's String.append method
janniclas cadc004
experimenting with subscript method
janniclas 7df29d0
Merge branch 'f-swift_code_style' into f-taintUpdate
janniclas f4b8c9a
handling insertvalue instructions in IFDSTaintAnalysis
janniclas 83d763a
Merge branch 'f-taintUpdate' into f-swift_code_style
janniclas eedd758
merged development
janniclas cfbfe70
cmake Swift improvement
janniclas 1974ba9
swift cmake improvement
janniclas 494b053
updated swift codegen in cmake file so we do not compile the files wi…
janniclas 41918e6
macos build fixes
janniclas b5d9bef
extended phasar macos install instructions
janniclas 1e6c03d
Merge branch 'development' into f-swift_code_style
janniclas c709281
updated LDFLAGS and CPPFLAGS for mac users in cmake
janniclas 510e5f1
Merge branch 'development' into f-swift_code_style
fabianbs96 beecb60
Merge branch 'development' into f-swift_code_style
fabianbs96 23cd91f
Merge branch 'development' into f-swift_code_style
fabianbs96 948173a
Merge branch 'development' into f-swift_code_style
fabianbs96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -203,6 +203,10 @@ auto IFDSTaintAnalysis::getNormalFlowFunction(n_t Curr, | |
return transferFlow<d_t>(Cast, Cast->getOperand(0)); | ||
} | ||
|
||
if (const auto *Insert = llvm::dyn_cast<llvm::InsertValueInst>(Curr)) { | ||
return generateFlow(Insert, Insert->getInsertedValueOperand()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also generate insert from |
||
} | ||
|
||
// Otherwise we do not care and leave everything as it is | ||
return Identity<d_t>::getInstance(); | ||
} | ||
|
@@ -261,7 +265,6 @@ auto IFDSTaintAnalysis::getSummaryFlowFunction([[maybe_unused]] n_t CallSite, | |
// result should be tainted | ||
if (DestFun->getName().equals("$sSS1poiyS2S_SStFZ")) { | ||
const auto *CS = llvm::cast<llvm::CallBase>(CallSite); | ||
|
||
return generateFlowIf<d_t>(CallSite, [CS](d_t Source) { | ||
return ((Source == CS->getArgOperand(1)) || | ||
(Source == CS->getArgOperand(3))); | ||
|
This file contains hidden or 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 +1,2 @@ | ||
add_subdirectory(linear_constant) | ||
add_subdirectory(taint_analysis) |
This file contains hidden or 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,9 +1,15 @@ | ||
file(GLOB lca_files *.swift) | ||
|
||
set(SWIFT_COMPILE_IR_FLAGS -emit-ir -suppress-warnings -g -parse-as-library -Onone -Xfrontend -disable-llvm-optzns -Xfrontend -disable-swift-specific-llvm-optzns) | ||
set(SWIFT_COMPILE_IR_FLAGS -emit-ir -suppress-warnings -g -parse-as-library -Onone) | ||
|
||
foreach(TEST_SRC ${lca_files}) | ||
get_filename_component(TEST_SRC_FILE ${TEST_SRC} NAME_WE) | ||
add_executable(${TEST_SRC_FILE}.ll ${TEST_SRC}) | ||
target_compile_options(${TEST_SRC_FILE}.ll PRIVATE ${SWIFT_COMPILE_IR_FLAGS}) | ||
set(TEST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SRC_FILE}.ll") | ||
add_custom_command( | ||
OUTPUT ${TEST_OUTPUT} | ||
COMMAND swiftc ${SWIFT_COMPILE_IR_FLAGS} -o ${TEST_OUTPUT} ${TEST_SRC} | ||
DEPENDS ${TEST_SRC} | ||
) | ||
add_custom_target(${TEST_SRC_FILE} DEPENDS ${TEST_OUTPUT}) | ||
add_dependencies(PhasarUnitTests ${TEST_SRC_FILE}) | ||
endforeach(TEST_SRC) |
This file contains hidden or 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,6 +1,6 @@ | ||
@main | ||
struct MyMain { | ||
static func main() { | ||
var i = CommandLine.arguments.count | ||
var i = CommandLine.arguments.count | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,10 +1,9 @@ | ||
|
||
@main | ||
struct MyMain { | ||
static func main() { | ||
var a = 0 | ||
for i in 0...9 { | ||
a += i | ||
} | ||
var a = 0 | ||
for i in 0...9 { | ||
a += i | ||
} | ||
} | ||
} |
This file contains hidden or 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,7 @@ | ||
var y = 42 | ||
@main | ||
struct MyMain { | ||
static func main() { | ||
y += 1 | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -3,8 +3,8 @@ var g = 10 | |
@main | ||
struct MyMain { | ||
static func main() { | ||
var i = g | ||
i -= 20 | ||
g = i | ||
var i = g | ||
i -= 20 | ||
g = i | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a comment to describe why we exclude pmr on apple.
Btw, are the feature-test macros
__cpp_lib_memory_resource
and__cpp_lib_polymorphic_allocator
defined on apple?