Skip to content

Commit 9bf74c7

Browse files
committed
Merge branch 'f-Taint' into development
2 parents b8d2145 + d87a126 commit 9bf74c7

148 files changed

Lines changed: 7999 additions & 791 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
[submodule "external/WALi-OpenNWA"]
1010
path = external/WALi-OpenNWA
1111
url = https://github.com/pdschubert/WALi-OpenNWA.git
12+
[submodule "external/json-schema-validator"]
13+
path = external/json-schema-validator
14+
url = https://github.com/pboettch/json-schema-validator.git

config/TaintConfigSchema.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
R"(
2+
{
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"title": "Taint Configuration",
5+
"description": "A Taint Configuration",
6+
"type": "object",
7+
"properties": {
8+
"name": {
9+
"type": "string",
10+
"description": "Name of this taint configuration"
11+
},
12+
"version": {
13+
"type": "number",
14+
"description": "Version of this taint configuration"
15+
},
16+
"functions": {
17+
"type": "array",
18+
"properties": {
19+
"name": {
20+
"type": "string"
21+
},
22+
"ret": {
23+
"enum": ["source", "sink", "sanitizer"]
24+
},
25+
"params": {
26+
"properties": {
27+
"source": {
28+
"type": "array",
29+
"properties": {
30+
"type": ["number", "string"]
31+
}
32+
},
33+
"sink": {
34+
"type": "array",
35+
"properties": {
36+
"type": ["number", "string"]
37+
}
38+
},
39+
"sanitizer": {
40+
"type": "array",
41+
"properties": {
42+
"type": ["number", "string"]
43+
}
44+
}
45+
}
46+
}
47+
},
48+
"required": ["name", "params"]
49+
},
50+
"variables": {
51+
"type": "array",
52+
"properties": {
53+
"scope": {
54+
"type": "string"
55+
},
56+
"name": {
57+
"type": "string"
58+
},
59+
"line": {
60+
"type": "number"
61+
},
62+
"cat": {
63+
"enum": ["source", "sink", "sanitizer"]
64+
}
65+
},
66+
"required": ["scope", "name", "cat"]
67+
}
68+
}
69+
}
70+
)"_json

external/json

Submodule json updated 81 files

external/json-schema-validator

Submodule json-schema-validator added at 27fc1d0

include/phasar/PhasarLLVM/AnalysisStrategy/WholeProgramAnalysis.h

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class WholeProgramAnalysis {
4444
std::unique_ptr<PointerAnalysisTy> PointerInfo;
4545
std::unique_ptr<CallGraphAnalysisTy> CallGraph;
4646
std::set<std::string> EntryPoints;
47-
std::unique_ptr<ConfigurationTy> Config;
47+
ConfigurationTy *Config = nullptr;
48+
bool OwnsConfig = false;
4849
std::string ConfigPath;
4950
ProblemDescription ProblemDesc;
5051
Solver DataFlowSolver;
@@ -91,10 +92,9 @@ class WholeProgramAnalysis {
9192
IRDB, CallGraphAnalysisType::OTF, EntryPoints,
9293
this->TypeHierarchy.get(), this->PointerInfo.get())
9394
: std::unique_ptr<CallGraphAnalysisTy>(CallGraph)),
94-
EntryPoints(EntryPoints),
95-
Config(std::unique_ptr<ConfigurationTy>(Config)), ConfigPath(""),
96-
ProblemDesc(&IRDB, TypeHierarchy, CallGraph, PointerInfo, *Config,
97-
EntryPoints),
95+
EntryPoints(EntryPoints), Config(Config), OwnsConfig(false),
96+
ConfigPath(""), ProblemDesc(&IRDB, TypeHierarchy, CallGraph,
97+
PointerInfo, *Config, EntryPoints),
9898
DataFlowSolver(ProblemDesc) {}
9999

100100
template <typename T = ProblemDescription,
@@ -117,12 +117,23 @@ class WholeProgramAnalysis {
117117
IRDB, CallGraphAnalysisType::OTF, EntryPoints,
118118
this->TypeHierarchy.get(), this->PointerInfo.get())
119119
: std::unique_ptr<CallGraphAnalysisTy>(CallGraph)),
120-
EntryPoints(EntryPoints),
121-
Config(std::make_unique<ConfigurationTy>(ConfigPath)),
122-
ConfigPath(ConfigPath), ProblemDesc(&IRDB, TypeHierarchy, CallGraph,
123-
PointerInfo, *Config, EntryPoints),
120+
EntryPoints(EntryPoints), Config(new ConfigurationTy(ConfigPath)),
121+
OwnsConfig(true), ConfigPath(ConfigPath),
122+
ProblemDesc(&IRDB, TypeHierarchy, CallGraph, PointerInfo, *Config,
123+
EntryPoints),
124124
DataFlowSolver(ProblemDesc) {}
125125

126+
WholeProgramAnalysis(const WholeProgramAnalysis &) = delete;
127+
128+
WholeProgramAnalysis(WholeProgramAnalysis &&) = delete;
129+
130+
~WholeProgramAnalysis() {
131+
if (OwnsConfig) {
132+
delete Config;
133+
Config = nullptr;
134+
}
135+
}
136+
126137
void solve() { DataFlowSolver.solve(); }
127138

128139
void operator()() { solve(); }
@@ -158,8 +169,6 @@ class WholeProgramAnalysis {
158169
CallGraphAnalysisTy *releaseCallGraph() { return CallGraph.release(); }
159170

160171
TypeHierarchyTy *releaseTypeHierarchy() { return TypeHierarchy.release(); }
161-
162-
ConfigurationTy *releaseConfiguration() { return Config.release(); }
163172
};
164173

165174
} // namespace psr

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ class LLVMBasedICFG
268268
[[nodiscard]] std::set<const llvm::Function *>
269269
getCalleesOfCallAt(const llvm::Instruction *N) const override;
270270

271+
void forEachCalleeOfCallAt(
272+
const llvm::Instruction *I,
273+
llvm::function_ref<void(const llvm::Function *)> Callback) const;
274+
271275
/**
272276
* \return all caller statements/nodes of a given method.
273277
*/

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/InitialSeeds.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ template <typename N, typename D, typename L> class InitialSeeds {
2626

2727
InitialSeeds() = default;
2828

29-
template <typename LL = L, typename = typename std::enable_if_t<
30-
std::is_same_v<LL, BinaryDomain>>>
29+
template <typename LL = L,
30+
typename = std::enable_if_t<std::is_same_v<LL, BinaryDomain>>>
3131
InitialSeeds(const std::map<N, std::set<D>> &Seeds) {
3232
for (const auto &[Node, Facts] : Seeds) {
3333
for (const auto &Fact : Facts) {
@@ -38,13 +38,15 @@ template <typename N, typename D, typename L> class InitialSeeds {
3838

3939
InitialSeeds(GeneralizedSeeds Seeds) : Seeds(std::move(Seeds)) {}
4040

41-
template <typename LL = L, typename = typename std::enable_if_t<
42-
std::is_same_v<LL, BinaryDomain>>>
41+
template <typename LL = L,
42+
typename = std::enable_if_t<std::is_same_v<LL, BinaryDomain>>>
4343
void addSeed(N Node, D Fact) {
4444
addSeed(Node, Fact, BinaryDomain::TOP);
4545
}
4646

47-
void addSeed(N Node, D Fact, L Value) { Seeds[Node][Fact] = Value; }
47+
void addSeed(N Node, D Fact, L Value) {
48+
Seeds[Node][Fact] = std::move(Value);
49+
}
4850

4951
[[nodiscard]] size_t countInitialSeeds() const {
5052
size_t NumSeeds = 0;
@@ -55,12 +57,21 @@ template <typename N, typename D, typename L> class InitialSeeds {
5557
}
5658

5759
[[nodiscard]] size_t countInitialSeeds(N Node) const {
60+
auto Search = Seeds.find(Node);
61+
if (Search != Seeds.end()) {
62+
return Search->second.size();
63+
}
64+
return 0;
65+
}
66+
67+
[[nodiscard]] bool containsInitialSeedsFor(N Node) const {
5868
return Seeds.count(Node);
5969
}
6070

6171
[[nodiscard]] bool empty() const { return Seeds.empty(); }
6272

63-
[[nodiscard]] GeneralizedSeeds getSeeds() { return Seeds; }
73+
[[nodiscard]] const GeneralizedSeeds &getSeeds() const & { return Seeds; }
74+
[[nodiscard]] GeneralizedSeeds getSeeds() && { return std::move(Seeds); }
6475

6576
void dump(std::ostream &OS = std::cerr) {
6677

0 commit comments

Comments
 (0)