Skip to content

Commit 356904a

Browse files
committed
csgrep --imp-level=1: filter out important defects
Related: https://issues.redhat.com/browse/OSH-289 Closes: #143
1 parent 77561f5 commit 356904a

File tree

5 files changed

+14474
-1
lines changed

5 files changed

+14474
-1
lines changed

src/csgrep.cc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,23 @@ class ToolPredicate: public IPredicate {
215215
}
216216
};
217217

218+
class ImpLevelFilter: public AbstractFilter {
219+
private:
220+
const int minLevel_;
221+
222+
public:
223+
ImpLevelFilter(AbstractWriter *agent, const int minLevel):
224+
AbstractFilter(agent),
225+
minLevel_(minLevel)
226+
{
227+
}
228+
229+
protected:
230+
bool matchDef(const Defect &def) override {
231+
return minLevel_ <= def.imp;
232+
}
233+
};
234+
218235
class KeyEventPredicate: public IPredicate {
219236
private:
220237
const RE re_;
@@ -526,7 +543,7 @@ bool chainFilters(
526543
return false;
527544
}
528545

529-
return true;
546+
return chainDecoratorIntArg<ImpLevelFilter>(pEng, vm, "imp-level");
530547
}
531548

532549
int main(int argc, char *argv[])
@@ -552,6 +569,7 @@ int main(int argc, char *argv[])
552569
("tool", po::value<string>(), "defect matches if it was detected by tool that matches the given regex")
553570
("annot", po::value<string>(), "defect matches if its annotation matches the given regex")
554571
("src-annot", po::value<string>(), "defect matches if an annotation in the _source_ file matches the given regex")
572+
("imp-level", po::value<int>(), "defect matches if the importance level is greater or equal than the given number")
555573

556574
("drop-scan-props", "do not propagate scan properties")
557575
("embed-context,U", po::value<int>(), "embed a number of lines of context from the source file for the key event")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--mode=json --imp-level=1

0 commit comments

Comments
 (0)