def test_raise_semgrep_error_from_json_unknown_error(): test_rule_id = "test_rule_id" rule_yaml_text = io.StringIO(f""" rules: - id: {test_rule_id} pattern: $X == $X severity: INFO languages: [python] message: blah """) rule_dict = yaml.load(rule_yaml_text).get("rules")[0] rule: Rule = Rule.from_json(rule_dict) core_runner = CoreRunner( allow_exec=False, output_settings=OutputSettings(OutputFormat.TEXT), jobs=1, timeout=0, max_memory=0, timeout_threshold=0, report_time=False, ) patterns: List[Pattern] = list(core_runner._flatten_rule_patterns([rule])) output_json: Dict[str, Any] = { "error": "unknown exception", "message": "End_of_file", } with pytest.raises(SemgrepError) as excinfo: core_runner._raise_semgrep_error_from_json(output_json, patterns, rule) assert test_rule_id in str(excinfo.value)
def test_raise_semgrep_error_from_json_unknown_error(): test_rule_id = "test_rule_id" rule_yaml_text = io.StringIO(f""" rules: - id: {test_rule_id} pattern: $X == $X severity: INFO languages: [python] message: blah """) rule_dict = yaml.load(rule_yaml_text).get("rules")[0] rule: Rule = Rule.from_json(rule_dict) core_runner = CoreRunner( jobs=1, timeout=0, max_memory=0, timeout_threshold=0, optimizations="all", ) output_json: Dict[str, Any] = { "error": "unknown exception", "message": "End_of_file", } with pytest.raises(SemgrepError) as excinfo: core_runner._raise_semgrep_error_from_json(output_json, rule) assert test_rule_id in str(excinfo.value)