forked from pfqgauxfb/code-analysis
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.6 KiB
103 lines
2.6 KiB
"""
|
|
Cppcheck Test Generator
|
|
|
|
一个用于根据 cppcheck 报告生成可运行测试用例的工具包。
|
|
|
|
主要功能:
|
|
- 解析 cppcheck XML 和文本报告
|
|
- 分析代码上下文和项目结构
|
|
- 生成针对性的测试用例
|
|
- 验证测试用例的有效性
|
|
- 智能筛选最有代表性的问题
|
|
|
|
使用示例:
|
|
from cppcheck_test_generator import main
|
|
main.main(['report.xml', '--out', 'tests', '--max', '5'])
|
|
"""
|
|
|
|
__version__ = "1.0.0"
|
|
__author__ = "Cppcheck Test Generator Team"
|
|
|
|
# 导入主要模块
|
|
from .models import CppcheckIssue, IssueLocation, CodeContext
|
|
from .parsers import parse_cppcheck_xml, parse_cppcheck_text, read_code_snippet
|
|
from .analysis import (
|
|
analyze_code_context,
|
|
analyze_issue_relevance,
|
|
analyze_project_structure,
|
|
get_enhanced_issue_analysis,
|
|
extract_issue_context_from_source,
|
|
filter_and_clean_issues,
|
|
write_cleaned_report,
|
|
prioritize_issues,
|
|
analyze_issues_with_context
|
|
)
|
|
from .generation import (
|
|
generate_issue_specific_test_code,
|
|
get_issue_specific_template,
|
|
generate_real_code_based_template,
|
|
generate_default_template,
|
|
get_issue_specific_guidance,
|
|
build_prompt_for_issue,
|
|
generate_test_for_issue,
|
|
smart_select_issues,
|
|
write_issue_output
|
|
)
|
|
from .verification import (
|
|
verify_single_test,
|
|
analyze_vulnerability_type,
|
|
determine_vulnerability_confirmed,
|
|
verify_test_case,
|
|
auto_verify_tests,
|
|
generate_verification_report,
|
|
generate_json_report
|
|
)
|
|
from .main import main
|
|
|
|
# 导出主要类和函数
|
|
__all__ = [
|
|
# 数据模型
|
|
'CppcheckIssue',
|
|
'IssueLocation',
|
|
'CodeContext',
|
|
|
|
# 解析器
|
|
'parse_cppcheck_xml',
|
|
'parse_cppcheck_text',
|
|
'read_code_snippet',
|
|
|
|
# 分析器
|
|
'analyze_code_context',
|
|
'analyze_issue_relevance',
|
|
'analyze_project_structure',
|
|
'get_enhanced_issue_analysis',
|
|
'extract_issue_context_from_source',
|
|
'filter_and_clean_issues',
|
|
'write_cleaned_report',
|
|
'prioritize_issues',
|
|
'analyze_issues_with_context',
|
|
|
|
# 生成器
|
|
'generate_issue_specific_test_code',
|
|
'get_issue_specific_template',
|
|
'generate_real_code_based_template',
|
|
'generate_default_template',
|
|
'get_issue_specific_guidance',
|
|
'build_prompt_for_issue',
|
|
'generate_test_for_issue',
|
|
'smart_select_issues',
|
|
'write_issue_output',
|
|
|
|
# 验证器
|
|
'verify_single_test',
|
|
'analyze_vulnerability_type',
|
|
'determine_vulnerability_confirmed',
|
|
'verify_test_case',
|
|
'auto_verify_tests',
|
|
'generate_verification_report',
|
|
'generate_json_report',
|
|
|
|
# 主程序
|
|
'main'
|
|
]
|