|
14 | 14 | #include <util/message.h>
|
15 | 15 | #include <map>
|
16 | 16 | #include <string>
|
| 17 | +#include <vector> |
17 | 18 | #include <memory>
|
18 | 19 | #include <boost/optional.hpp>
|
19 | 20 |
|
@@ -196,9 +197,9 @@ class taint_sink_rulet : public taint_rulet
|
196 | 197 | class taint_rulest
|
197 | 198 | {
|
198 | 199 | private:
|
199 |
| - std::map<irep_idt, taint_propagation_rulet> propagation_rules; |
200 |
| - std::map<irep_idt, taint_sanitizer_rulet> sanitizer_rules; |
201 |
| - std::map<irep_idt, taint_sink_rulet> sink_rules; |
| 200 | + std::multimap<irep_idt, taint_propagation_rulet> propagation_rules; |
| 201 | + std::multimap<irep_idt, taint_sanitizer_rulet> sanitizer_rules; |
| 202 | + std::multimap<irep_idt, taint_sink_rulet> sink_rules; |
202 | 203 |
|
203 | 204 | taint_rulest() { }
|
204 | 205 |
|
@@ -233,41 +234,49 @@ class taint_rulest
|
233 | 234 | || sink_rules.find(fn_name) != sink_rules.end();
|
234 | 235 | }
|
235 | 236 |
|
236 |
| - boost::optional<const taint_propagation_rulet &> find_propagation_rule( |
237 |
| - const irep_idt &fn_name) const |
| 237 | + std::vector<std::reference_wrapper<const taint_propagation_rulet>> |
| 238 | + find_propagation_rule(const irep_idt &fn_name) const |
238 | 239 | {
|
239 | 240 | // We currently match directly on the name
|
240 | 241 | // TODO: Search for any methods derived on base classes of the class name
|
241 | 242 | // used in the call
|
242 |
| - // class_hierarchyt::idst parents = class_hierarchy.get_parents_trans(class_id); |
243 |
| - auto it = propagation_rules.find(fn_name); |
244 |
| - if(it == propagation_rules.end()) |
245 |
| - return boost::none; |
246 |
| - return it->second; |
| 243 | + std::vector<std::reference_wrapper<const taint_propagation_rulet>> |
| 244 | + matching_rules; |
| 245 | + auto range = propagation_rules.equal_range(fn_name); |
| 246 | + for(auto it = range.first; it != range.second; ++it) |
| 247 | + matching_rules.push_back( |
| 248 | + std::reference_wrapper<const taint_propagation_rulet>(it->second)); |
| 249 | + return matching_rules; |
247 | 250 | }
|
248 | 251 |
|
249 |
| - boost::optional<const taint_sanitizer_rulet &> find_sanitizer_rule(const irep_idt &fn_name) const |
| 252 | + std::vector<std::reference_wrapper<const taint_sanitizer_rulet>> |
| 253 | + find_sanitizer_rule(const irep_idt &fn_name) const |
250 | 254 | {
|
251 | 255 | // We currently match directly on the name
|
252 | 256 | // TODO: Search for any methods derived on base classes of the class name
|
253 | 257 | // used in the call
|
254 |
| - // class_hierarchyt::idst parents = class_hierarchy.get_parents_trans(class_id); |
255 |
| - auto it = sanitizer_rules.find(fn_name); |
256 |
| - if(it == sanitizer_rules.end()) |
257 |
| - return boost::none; |
258 |
| - return it->second; |
| 258 | + std::vector<std::reference_wrapper<const taint_sanitizer_rulet>> |
| 259 | + matching_rules; |
| 260 | + auto range = sanitizer_rules.equal_range(fn_name); |
| 261 | + for(auto it = range.first; it != range.second; ++it) |
| 262 | + matching_rules.push_back( |
| 263 | + std::reference_wrapper<const taint_sanitizer_rulet>(it->second)); |
| 264 | + return matching_rules; |
259 | 265 | }
|
260 | 266 |
|
261 |
| - boost::optional<const taint_sink_rulet &> find_sink_rule(const irep_idt &fn_name) const |
| 267 | + std::vector<std::reference_wrapper<const taint_sink_rulet>> |
| 268 | + find_sink_rule(const irep_idt &fn_name) const |
262 | 269 | {
|
263 | 270 | // We currently match directly on the name
|
264 | 271 | // TODO: Search for any methods derived on base classes of the class name
|
265 | 272 | // used in the call
|
266 | 273 | // class_hierarchyt::idst parents = class_hierarchy.get_parents_trans(class_id);
|
267 |
| - auto it = sink_rules.find(fn_name); |
268 |
| - if(it == sink_rules.end()) |
269 |
| - return boost::none; |
270 |
| - return it->second; |
| 274 | + std::vector<std::reference_wrapper<const taint_sink_rulet>> matching_rules; |
| 275 | + auto range = sink_rules.equal_range(fn_name); |
| 276 | + for(auto it = range.first; it != range.second; ++it) |
| 277 | + matching_rules.push_back( |
| 278 | + std::reference_wrapper<const taint_sink_rulet>(it->second)); |
| 279 | + return matching_rules; |
271 | 280 | }
|
272 | 281 |
|
273 | 282 |
|
|
0 commit comments