从源码构建需 LLVM/Clang 14.0.x,且自行编译 LLVM 时必须开启 RTTI;分析结果默认写入当前目录的 output.db;warning 可能只是分析器信息不足或能力不够,不等于确有错误。
ikos
NASA-SW-VnV更新放缓基于抽象解释理论的 C/C++ 静态分析器,能在编译前发现运行时错误和未定义行为,适合安全关键代码的验证。
Static analyzer for C/C++ based on the theory of Abstract Interpretation.
brew install nasa-sw-vnv/core/ikos
ikos loop.cREADME 未说明显存或 GPU 要求;安装方式为 Linux/macOS 上的 Homebrew,Windows 建议用 WSL。
NASA 开源的 C/C++ 静态分析器,用抽象解释证明运行时错误不存在
基于抽象解释理论的 C/C++ 静态分析器,能在编译前发现运行时错误和未定义行为,适合安全关键代码的验证。
核心能力
- 基于 LLVM 前端把 C/C++ 编译为 bitcode 再分析
- 用抽象解释与不动点迭代做过程间数值分析
- 把检查结果分为 safe、error、unreachable、warning 四类
- 生成 output.db 结果库,可用 ikos-report 或 ikos-view 查看
- 提供 ikos-scan 分析整个项目
容易踩的坑
- v3.5Public release 3.5最新正式版2024-12-31 · 2024-12-31 23:41 UTC
Release date
December 2024
Summary
This release addresses forward portability issues that manifest with newer versions of Python and will manifest with newer versions of LLVM.
List of changes
analyzer
- Remove use of deprecated python module pipes (#292).
frontend
- Replace calls to deprecated function
getAlignment(#304).
Overall changes
- Version bump (#310).
Metrics
3 issues were closed as part of IKOS 3.5.
The net balance including all files (e.g., code, docs) is that IKOS 3.5 is exactly the same number of lines as the previous version.
We had submissions from 1 new author who had never submitted patches to IKOS before.
Full Changelog: https://github.com/NASA-SW-VnV/ikos/compare/v3.4...v3.5
- v3.4Public release 3.42024-10-01 · 2024-10-01 05:25 UTC
查看更新说明
Release date
September 2024
Summary
This release addresses bugs related to missing includes, it fixes an error in the CI infrastructure, and addresses a false positive that may arise when
snprintfis used.List of changes
analyzer
- analyzer: Allow snprintf(NULL, 0, ...) (#221).
- analyzer: Add missing include (#273).
Overall changes
- Fix CI job for Mac due to image upgrade (#276).
- Version bump (#287).
Metrics
4 issues were closed as part of IKOS 3.4.
The net balance including all files (e.g., code, docs) is that IKOS 3.4 is 30 lines bigger than the previous version.
We had submissions from 1 new author who had never submitted patches to IKOS before.
Full Changelog: https://github.com/NASA-SW-VnV/ikos/compare/v3.3...v3.4
- v3.3Public release version 3.32024-04-01 · 2024-04-01 05:21 UTC
查看更新说明
Release date
March 2024
Summary
This is a maintenance release that addresses bugs related to Python dependencies, the order of passes in the LLVM frontend, and missing imports.
List of changes
analyzer
- Introduce compatibility with pygments >= 2.12 (#264).
Frontend
- Change order of passes (#205).
Core
- Add missing imports (#263).
Overall changes
- Version bump (#266).
Metrics
4 issues were closed as part of IKOS 3.3.
The net balance including all files (e.g., code, docs) is that IKOS 3.3 is 4 lines bigger than the previous version.
We had submissions from 1 new author who had never submitted patches to IKOS before.
Full Changelog: https://github.com/NASA-SW-VnV/ikos/compare/v3.2...v3.3
- v3.2Public Release 3.22023-12-28 · 2023-12-28 18:35 UTC
查看更新说明
Release date
December 2023
Summary
This is a maintenance release that addresses bugs related to Python packaging, LLVM 14, IPv6 handling and multi OS support. Other changes focus on the documentation, the software engineering process and leveraging features offered by Github.
There are two notable changes:
- We've dropped support for Python 2.
- We've added CI jobs via Github actions, which should ensure that IKOS keeps working on supported platforms.
List of changes
Analyzer changes
- Fixed hang of IKOS server due to not listening on IPv6 (#158).
- Fixed exception on Windows when IKOS is executed from a different drive (#165).
- Fix incorrect argument
-sectionin call tollvm-objdumpby @lojikil (#199). - Fixed installation issues related to Python (#243, #242, #233, #193, #185).
- Fixed error parsing the output of
llvm-objdumpin LLVM 14 (#203). - Typo fixes (#227).
AR Changes
- Add missing include directives by @gitrj95 (#201).
Overall changes
- Added documentation to the troubleshooting guide regarding a bug in old versions of APRON (#78).
- Added documentation to the troubleshooting guide regarding lack of support for multi-threaded code (#124).
- Fix the unaligned pointer analysis check parameter in the README.md file by @asensi in (#222).
- Set up Continuous Integration to build for Mac and Linux (#223).
- Fixed over-reaching gitignore rules (#217).
- Created Github releases for all IKOS versions, and attached the release notes to them (#219).
- Bump Copyright years (#246, #249).
- Version bump (#255).
- Improved issue / milestone / release handling process (not reflected as a separate issue).
- Fixed homebrew formula (https://github.com/NASA-SW-VnV/homebrew-core/issues/9).
Metrics
23 issues were closed as part of IKOS 3.2.
The net balance including all files (e.g., code, docs) is that IKOS 3.2 is 437 lines smaller than the previous version.
We had submissions from 4 new authors who had never submitted patches to IKOS before.
Full Changelog: https://github.com/NASA-SW-VnV/ikos/compare/v3.1...v3.2
- v3.1public release version 3.12022-12-05 · 2022-12-05 01:26 UTC
查看更新说明
IKOS version 3.1 release notes
Release date
December 2022
List of changes
LLVM frontend changes
- Upgrade LLVM from 9.0.x to 14.0.x
Analyzer changes
- Add option to trace the invariant during analysis.
- Fix issue detecting uses of uninitialized dynamically-allocated memory.
- Allow analysis of programs without debug information.
- Support producing reports in SARIF format.
- Support producing reports in JUnit format.
- Allow running
ikos-scanwithout an HTTP server, outputting JSON. - Update use of deprecated Python function
isAlive. - Small refactoring changes.
Overall changes
- Update installation instructions for Ubuntu 20.04.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
IKOS
IKOS (Inference Kernel for Open Static Analyzers) is a static analyzer for C/C++ based on the theory of Abstract Interpretation.
Introduction
IKOS started as a C++ library designed to facilitate the development of sound static analyzers based on Abstract Interpretation. Specialization of a static analyzer for an application or family of applications is critical for achieving both precision and scalability. Developing such an analyzer is arduous and requires significant expertise in Abstract Interpretation.
IKOS provides a generic and efficient implementation of state-of-the-art Abstract Interpretation data structures and algorithms, such as control-flow graphs, fixpoint iterators, numerical abstract domains, etc. IKOS is independent of a particular programming language.
IKOS also provides a C and C++ static analyzer based on LLVM. It implements scalable analyses for detecting and proving the absence of runtime errors in C and C++ programs.
License
IKOS has been released under the NASA Open Source Agreement version 1.3, see LICENSE.pdf
Contact
Release notes
See Releases.
Troubleshooting
Installation
To install IKOS on Linux or macOS, we recommend to use Homebrew.
First, install Homebrew by following these instructions.
Then, simply run:
$ brew install nasa-sw-vnv/core/ikos
For Windows, consider using Windows Subsystem for Linux.
How to run IKOS
Suppose we want to analyze the following C program in a file, called loop.c:
1: #include <stdio.h>
2: int a[10];
3: int main(int argc, char *argv[]) {
4: size_t i = 0;
5: for (;i < 10; i++) {
6: a[i] = i;
7: }
8: a[i] = i;
9: printf("%i", a[i]);
10: }
To analyze this program with IKOS, simply run:
$ ikos loop.c
You shall see the following output. IKOS reports two occurrences of buffer overflow at line 8 and 9.
[*] Compiling loop.c
[*] Running ikos preprocessor
[*] Running ikos analyzer
[*] Translating LLVM bitcode to AR
[*] Running liveness analysis
[*] Running widening hint analysis
[*] Running interprocedural value analysis
[*] Analyzing entry point 'main'
[*] Checking properties for entry point 'main'
# Time stats:
clang : 0.037 sec
ikos-analyzer: 0.023 sec
ikos-pp : 0.007 sec
# Summary:
Total number of checks : 7
Total number of unreachable checks : 0
Total number of safe checks : 5
Total number of definite unsafe checks: 2
Total number of warnings : 0
The program is definitely UNSAFE
# Results
loop.c: In function 'main':
loop.c:8:10: error: buffer overflow, trying to access index 10 of global variable 'a' of 10 elements
a[i] = i;
^
loop.c: In function 'main':
loop.c:9:18: error: buffer overflow, trying to access index 10 of global variable 'a' of 10 elements
printf("%i", a[i]);
^
The ikos command takes a source file (.c, .cpp) or a LLVM bitcode file (.bc) as input, analyzes it to find runtime errors (also called undefined behaviors), creates a result database output.db in the current working directory and prints a report.
In the report, each line has one of the following status:
- safe: the statement is proven safe;
- error: the statement always results into an error (or is unreachable);
- unreachable: the statement is never executed;
- warning may mean three things:
- the statement results into an error for some executions, or
- the static analyzer did not have enough information to conclude (check dependent on an external input, for instance), or
- the static analyzer was not powerful enough to prove the absence of errors;
By default, ikos shows warnings and errors directly in your terminal, like a compiler would do.
If the analysis report is too big, you shall use:
ikos-report output.dbto examine the report in your terminalikos-view output.dbto examine the report in a web interface
Further information:
- Analyze a whole project with ikos-scan
- Examine a report with ikos-view
- Analysis Options
- Report Options
- APRON Support
- Analysis Assumptions
- Analyze an embedded software requiring a cross-compiler
- Model library functions to reduce warnings
Build from source
Below are instructions to build IKOS from source. This is only for advanced users that want to either package IKOS for an operating system or to experiment with the codebase. Otherwise, please follow the instructions above.
Dependencies
To build and run the analyzer, you will need the following dependencies:
- A C++ compiler that supports C++14 (gcc >= 4.9.2 or clang >= 3.4)
- CMake >= 3.4.3
- GMP >= 4.3.1
- Boost >= 1.55
- Python >= 3.3
- SQLite >= 3.6.20
- TBB >= 2
- LLVM and Clang 14.0.x
- (Optional) APRON >= 0.9.10
Most of them can be installed using your package manager.
Note: If you build LLVM from source, you need to enable run-time type information (RTTI).
Build and Install
Now that you have all the dependencies on your system, you can build and install IKOS.
As you open the IKOS distribution, you shall see the following directory structure:
.
├── CMakeLists.txt
├── LICENSE.pdf
├── README.md
├── RELEASE_NOTES.md
├── TROUBLESHOOTING.md
├── analyzer
├── ar
├── cmake
├── core
├── doc
├── frontend
├── script
└── test
IKOS uses the CMake build system. You will need to specify an installation directory that will contain all the binaries, libraries and headers after installation. If you do not specify this directory, CMake will install everything under install in the root directory of the distribution. In the following steps, we will install IKOS under /path/to/ikos-install-directory.
Here are the steps to build and install IKOS:
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/path/to/ikos-install-directory ..
$ make
$ make install
Then, add IKOS in your PATH (consider adding this in your .bashrc):
$ PATH="/path/to/ikos-install-directory/bin:$PATH"
Tests
To build and run the tests, simply type:
$ make check
Contributors
See CONTRIBUTORS.md
Publications
-
Sung Kook Kim, Arnaud J. Venet, Aditya V. Thakur. Deterministic Parallel Fixpoint Computation. In Principles of Programming Languages (POPL 2020), New Orleans, Louisiana (PDF).
-
Guillaume Brat, Jorge Navas, Nija Shi and Arnaud Venet. IKOS: a Framework for Static Analysis based on Abstract Interpretation. In Proceedings of the International Conference on Software Engineering and Formal Methods (SEFM 2014), Grenoble, France (PDF).
-
Arnaud Venet. The Gauge Domain: Scalable Analysis of Linear Inequality Invariants. In Proceedings of Computer Aided Verification (CAV 2012), Berkeley, California, USA 2012. Lecture Notes in Computer Science, pages 139-154, volume 7358, Springer 2012 (PDF).
Coding Standards
Overview of the source code
See doc/OVERVIEW.md