腾讯云静态分析
- TCA, Tencent Cloud Code Analysis code-named: CodeDog
- https://cloud.tencent.com/product/tcap
- https://github.com/Tencent/CodeAnalysis
- https://github.com/Tencent/CodeAnalysis/blob/main/README_ZH.md
Dart Analyzer
- Flutter针对Android Studio和VS Code开发的插件,使用Android Studio或者VS Code进行开发,不需要配置就可以看到Dart Analyzer工具提供的静态分析结果
- Dart Analyzer工具会使用默认的analysis_options.yaml文件中的内容执行代码静态分析
typescript
- https://jkchao.github.io/typescript-book-chinese/compiler/scanner.html#%E8%A7%A3%E6%9E%90%E5%99%A8%E5%AF%B9%E6%89%AB%E6%8F%8F%E5%99%A8%E7%9A%84%E4%BD%BF%E7%94%A8
tools
- https://www.softwaresecured.com/
- https://www.veracode.com/products/binary-static-analysis-sast
- https://embold.io/
- https://deepscan.io/
- https://www.codacy.com/
- https://www.sonarsource.com/products/sonarqube/
- https://deepsource.com/
基于 AST 的代码处理工具工作流程
Parsing(解析)
这个过程由编译器实现,会经过词法分析和语法分析两个过程,生成 AST
Traversing(遍历)
深度优先遍历 AST ,访问树上各个节点的信息
Transforming(修改)
在遍历的过程中可对节点信息进行修改/转化,生成新的 AST
Printing(输出)
将转化后新的 AST 输出成新的代码块
编译器 Parser
- Parser 的 API 可以帮助我们完成代码的词法分析与语法分析,并返回对应的 AST 对象
- JS Parser: esprima、 acorn、 espree、@babel/parser。
- TS Parser:typescript (https://github.com/microsoft/TypeScript/)