| 113 | ) |
| 114 | |
| 115 | def record_rules(self, rules_toml_str: str) -> None: |
| 116 | try: |
| 117 | import toml # already a project dependency |
| 118 | data = toml.loads(rules_toml_str) |
| 119 | rules = data.get("rule", []) |
| 120 | self.rules_count = len(rules) |
| 121 | |
| 122 | for sink in data.get("taint_sink", []): |
| 123 | vid = sink.get("vulnerability_id", "") |
| 124 | if vid: |
| 125 | self._rule_detection[vid] = "taint" |
| 126 | |
| 127 | for rule in rules: |
| 128 | rid = rule.get("id", "") |
| 129 | if rid in self._rule_detection: |
| 130 | continue # already tagged via taint sink |
| 131 | has_ast = bool(rule.get("ast_match")) |
| 132 | has_regex = bool(rule.get("pattern")) |
| 133 | if has_regex: |
| 134 | self._rule_detection[rid] = "regex" |
| 135 | elif has_ast: |
| 136 | self._rule_detection[rid] = "ast" |
| 137 | else: |
| 138 | self._rule_detection[rid] = "taint" |
| 139 | except Exception: |
| 140 | pass |
| 141 | |
| 142 | def record_raw_issues(self, raw_issues: List[Any]) -> None: |
| 143 | self.pre_filter_count = len(raw_issues) |