-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pr: Let parser detector detect other categories of operations.
- Loading branch information
Showing
4 changed files
with
73 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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,69 @@ | ||
// 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); | ||
}); | ||
} | ||
} // namespace vast | ||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains 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 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