-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathParserCategoryDetector.cpp
More file actions
88 lines (82 loc) · 2.96 KB
/
ParserCategoryDetector.cpp
File metadata and controls
88 lines (82 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (c) 2024, Trail of Bits, Inc.
#ifdef VAST_ENABLE_SARIF
#include "SarifPasses.hpp"
#include "vast/Dialect/Parser/Ops.hpp"
#include "vast/Frontend/Sarif.hpp"
namespace vast {
void ParserCategoryDetector::runOnOperation() {
getOperation().walk([&](pr::Source op) {
gap::sarif::result result{
.ruleId{ "pr-source" },
.ruleIndex = 0,
.kind = gap::sarif::kind::kInformational,
.level = gap::sarif::level::kNote,
.message{
.text{ { "Parser source detected" } },
},
.locations{},
};
if (auto loc = cc::sarif::mk_location(op.getLoc());
loc.physicalLocation.has_value())
{
result.locations.push_back(std::move(loc));
}
results.push_back(result);
});
getOperation().walk([&](pr::Sink op) {
gap::sarif::result result{
.ruleId{ "pr-sink" },
.ruleIndex = 0,
.kind = gap::sarif::kind::kInformational,
.level = gap::sarif::level::kNote,
.message{
.text{ { "Parser sink detected" } },
},
.locations{},
};
if (auto loc = cc::sarif::mk_location(op.getLoc());
loc.physicalLocation.has_value())
{
result.locations.push_back(std::move(loc));
}
results.push_back(result);
});
getOperation().walk([&](pr::Parse op) {
gap::sarif::result result{
.ruleId{ "pr-parse" },
.ruleIndex = 0,
.kind = gap::sarif::kind::kInformational,
.level = gap::sarif::level::kNote,
.message{
.text{ { "Parsing operation detected" } },
},
.locations{},
};
if (auto loc = cc::sarif::mk_location(op.getLoc());
loc.physicalLocation.has_value())
{
result.locations.push_back(std::move(loc));
}
results.push_back(result);
});
getOperation().walk([&](pr::MaybeParse op) {
gap::sarif::result result{
.ruleId{ "pr-maybeparse" },
.ruleIndex = 0,
.kind = gap::sarif::kind::kInformational,
.level = gap::sarif::level::kNote,
.message{
.text{ { "Potential parsing operation detected" } },
},
.locations{},
};
if (auto loc = cc::sarif::mk_location(op.getLoc());
loc.physicalLocation.has_value())
{
result.locations.push_back(std::move(loc));
}
results.push_back(result);
});
}
} // namespace vast
#endif