Skip to content

Commit ea3b1dc

Browse files
authored
Merge pull request #520 from secure-software-engineering/f-FixXTaintEdgeFunctions
F Fix XTaint EdgeFunctions
2 parents f3b1b43 + d58257b commit ea3b1dc

4 files changed

Lines changed: 22 additions & 19 deletions

File tree

include/phasar/Controller/AnalysisController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class AnalysisController {
130130
void executeAnalysis() {
131131
if constexpr (WithConfig) {
132132
std::string AnalysisConfigPath =
133-
(0 < AnalysisConfigs.size()) ? AnalysisConfigs[0] : "";
133+
!AnalysisConfigs.empty() ? AnalysisConfigs[0] : "";
134134
auto Config =
135135
!AnalysisConfigPath.empty()
136136
? TaintConfig(IRDB, parseTaintConfig(AnalysisConfigPath))

lib/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/GenEdgeFunction.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,19 @@ GenEdgeFunction::composeWith(EdgeFunctionPtrType SecondFunction) {
5959

6060
GenEdgeFunction::EdgeFunctionPtrType
6161
GenEdgeFunction::joinWith(EdgeFunctionPtrType OtherFunction) {
62-
if (dynamic_cast<psr::AllBottom<l_t> *>(&*OtherFunction)) {
62+
if (Sani == nullptr) {
63+
// If there is a non-sanitized taint on any path, keep it
6364
return shared_from_this();
6465
}
65-
if (dynamic_cast<psr::AllTop<l_t> *>(&*OtherFunction)) {
66+
67+
if (dynamic_cast<psr::AllBottom<l_t> *>(&*OtherFunction)) {
6668
return OtherFunction;
6769
}
68-
if (&*getAllSanitized() == &*OtherFunction) {
70+
if (dynamic_cast<psr::AllTop<l_t> *>(&*OtherFunction)) {
6971
return shared_from_this();
7072
}
71-
72-
if (Sani == nullptr) {
73-
return OtherFunction;
73+
if (&*getAllSanitized() == &*OtherFunction) {
74+
return shared_from_this();
7475
}
7576

7677
if (auto *Other = dynamic_cast<EdgeFunctionBase *>(&*OtherFunction)) {
@@ -98,17 +99,17 @@ GenEdgeFunction::joinWith(EdgeFunctionPtrType OtherFunction) {
9899
// sanitizers
99100

100101
if (Res.isNotSanitized()) {
101-
return makeEF<GenEdgeFunction>(BBO, nullptr);
102+
return getGenEdgeFunction(BBO);
102103
}
103104

104105
return makeEF<JoinConstEdgeFunction>(BBO, OtherJoin->getFunction(),
105106
Res.getSanitizer());
106107
}
107108
}
108109

109-
if (isEdgeIdentity(&*OtherFunction)) {
110-
return getAllBot();
111-
}
110+
// if (isEdgeIdentity(&*OtherFunction)) {
111+
// return getAllBot();
112+
// }
112113

113114
return makeEF<JoinConstEdgeFunction>(BBO, OtherFunction, Sani);
114115
}

lib/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/JoinConstEdgeFunction.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ JoinConstEdgeFunction::JoinConstEdgeFunction(
2222
const llvm::Instruction *OtherConst)
2323
: EdgeFunctionBase(EFKind::JoinConst, BBO), OtherFn(std::move(OtherFn)),
2424
OtherConst(OtherConst) {
25-
assert(OtherConst);
25+
assert(OtherConst &&
26+
"Join with 'NotSanitized' is always 'NotSanitized' and should "
27+
"therefore not be modeled by a JoinConstEdgeFunction");
2628
}
2729

2830
JoinConstEdgeFunction::l_t JoinConstEdgeFunction::computeTarget(l_t Source) {
@@ -33,10 +35,10 @@ JoinConstEdgeFunction::l_t JoinConstEdgeFunction::computeTarget(l_t Source) {
3335
JoinConstEdgeFunction::EdgeFunctionPtrType
3436
JoinConstEdgeFunction::joinWith(EdgeFunctionPtrType OtherFunction) {
3537
if (dynamic_cast<psr::AllBottom<l_t> *>(&*OtherFunction)) {
36-
return shared_from_this();
38+
return OtherFunction;
3739
}
3840
if (dynamic_cast<psr::AllTop<l_t> *>(&*OtherFunction)) {
39-
return OtherFunction;
41+
return shared_from_this();
4042
}
4143
if (auto *Gen = dynamic_cast<GenEdgeFunction *>(&*OtherFunction)) {
4244
if (Gen->getSanitizer() == nullptr) {
@@ -48,7 +50,7 @@ JoinConstEdgeFunction::joinWith(EdgeFunctionPtrType OtherFunction) {
4850
// we never return Top, Bottom or Sanitized from a join with two sanitizers
4951

5052
if (Res.isNotSanitized()) {
51-
return makeEF<GenEdgeFunction>(BBO, nullptr);
53+
return getGenEdgeFunction(BBO);
5254
}
5355

5456
return makeEF<JoinConstEdgeFunction>(BBO, OtherFn, Res.getSanitizer());

lib/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis/XTaintEdgeFunctionBase.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ EdgeFunctionBase::composeWith(EdgeFunctionPtrType SecondFunction) {
4141
EdgeFunctionBase::EdgeFunctionPtrType
4242
EdgeFunctionBase::joinWith(EdgeFunctionPtrType OtherFunction) {
4343
if (dynamic_cast<psr::AllBottom<l_t> *>(&*OtherFunction)) {
44-
return shared_from_this();
44+
return OtherFunction;
4545
}
4646
if (dynamic_cast<psr::AllTop<l_t> *>(&*OtherFunction)) {
4747
return shared_from_this();
@@ -50,9 +50,9 @@ EdgeFunctionBase::joinWith(EdgeFunctionPtrType OtherFunction) {
5050
return shared_from_this();
5151
}
5252

53-
if (isEdgeIdentity(&*OtherFunction)) {
54-
return getAllBot();
55-
}
53+
// if (isEdgeIdentity(&*OtherFunction)) {
54+
// return getAllBot();
55+
// }
5656

5757
if (auto *Gen = dynamic_cast<GenEdgeFunction *>(&*OtherFunction)) {
5858
if (Gen->getSanitizer() == nullptr) {

0 commit comments

Comments
 (0)