Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
98ebf1d
[feat] Add core features for error-guided search
misonijnik Mar 7, 2023
b06940f
[feat] Use `escapingFunctions`
misonijnik Apr 11, 2023
0d349e4
[fix] Remove reached targets for taregeted forests with any histories
misonijnik Apr 11, 2023
4bda1c8
[feat] Add `NullCheckAfterDerefException` checker
misonijnik Mar 8, 2023
e41fa70
[refactor] Add `reportStateOnTargetError`
misonijnik Mar 9, 2023
6e3731b
[fix] Add recognizing "arm" as a 32-bit architecture
misonijnik Mar 9, 2023
3158ed5
Remove QF_AUFBV choosing for queries with constant arrays.
S1eGa Mar 7, 2023
b893d16
[fix] Fix `WarnAllExternals` option
misonijnik Mar 14, 2023
73b3438
[fix] Fix `NullCheckAfterDeref` checker
misonijnik Mar 15, 2023
dae5e9d
[fix] `prepareSymbolicValue`
misonijnik Apr 11, 2023
d46a8e6
[fix] Handle `smt tactic failed` solver failure
misonijnik Mar 17, 2023
23ce012
[fix] Fix segfault
misonijnik Mar 17, 2023
1766867
[fix] Small fixes
misonijnik Mar 18, 2023
ab30140
[chore] Update .gitignore
misonijnik Mar 24, 2023
879c396
[feat] Add mocks
misonijnik Apr 11, 2023
2badbfc
[chore] Add headers for nlohmann::json and nonstd::optional
Apr 20, 2023
bde2f46
[feat] Add parser for .sarif files and python scripts for work with .…
Apr 20, 2023
ad98d20
[feat] Add UnorderedTargetsSet and rewrite TargetForest using it
Apr 20, 2023
93424fc
[feat] Add creation of TargetForest from SarifReport
Apr 20, 2023
e86ea6f
[feat] Add confidence rate system and result's reports
Apr 20, 2023
d7f2b26
[feat] Add `Industry` tests
misonijnik Apr 16, 2023
0059a8f
[ci] Add z3 solver as required for `Industry` tests
misonijnik Apr 16, 2023
741a265
[fix] `ConcretizingSolver`
misonijnik Apr 25, 2023
d7e2933
[fix] Assignment
misonijnik Apr 25, 2023
5bf6ea1
Add null deref error for infer and cppcheck
Apr 24, 2023
78f3665
Add support of all our errors for infer/cppcheck/clang, remove unused…
Apr 24, 2023
33f5371
Add opportunity to provide additional metadata in threadFlowLocation
Apr 24, 2023
9b08d20
Remove unused subtract_confidences_from in TargetForest, fix problem …
Apr 24, 2023
ba728c2
Remake divideConfidenceBy
Apr 24, 2023
15febda
Add first version for traversability check under the flag
Apr 24, 2023
77087f8
Fix problem, when output True Positive for one trace several times
Apr 24, 2023
ebf829a
Change condition for useAterFree triggers
Apr 24, 2023
5bf3aab
Fix searcher and target forest
Apr 24, 2023
aae28dc
Add additional supported ruleId for Infer and NullPointerException
Apr 24, 2023
c4b15d9
Add resolving entry function using codeFlowGraph and filtering locati…
Apr 24, 2023
2f72e26
Move optional.hpp and json.hpp to submodules
Apr 25, 2023
4881b4e
[ci] Update build.yml
misonijnik Apr 25, 2023
409e70c
[fix] Error parsing
misonijnik Apr 25, 2023
a2eaa63
[fix] `TargetedSearcher` optimization
misonijnik Apr 26, 2023
653d675
[fix] Actually skip trace, if can't resolve entry function
Apr 27, 2023
af8c218
[refactor] Put things in order
misonijnik Apr 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
"Latest klee-uclibc",
"Asserts enabled",
"No TCMalloc, optimised runtime",
]
]
include:
- name: "LLVM 13"
env:
Expand Down Expand Up @@ -148,6 +148,8 @@ jobs:
steps:
- name: Checkout KLEE source code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build KLEE
env: ${{ matrix.env }}
run: scripts/build/build.sh klee --docker --create-final-image
Expand All @@ -167,6 +169,8 @@ jobs:
run: brew install bash
- name: Checkout KLEE source code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build KLEE
run: scripts/build/build.sh klee --debug --install-system-deps
- name: Run tests
Expand All @@ -177,6 +181,8 @@ jobs:
steps:
- name: Checkout KLEE Code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build Docker image
run: docker build .

Expand All @@ -189,6 +195,8 @@ jobs:
steps:
- name: Checkout KLEE source code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build KLEE
run: scripts/build/build.sh klee --docker --create-final-image
- name: Run tests
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ autoconf/aclocal.m4
autoconf/autom4te.cache/
autom4te.cache/

.vscode/launch.json
.vscode/settings.json
.vscode/
.cache/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "json"]
path = json
url = https://github.com/nlohmann/json.git
[submodule "optional"]
path = optional
url = https://github.com/martinmoene/optional-lite.git
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ configure_file(${CMAKE_SOURCE_DIR}/include/klee/Config/CompileTimeInfo.h.cmin
################################################################################
include_directories("${CMAKE_BINARY_DIR}/include")
include_directories("${CMAKE_SOURCE_DIR}/include")
include_directories("${CMAKE_SOURCE_DIR}/json/include")
include_directories("${CMAKE_SOURCE_DIR}/optional/include")

################################################################################
# Set default location for targets in the build directory
Expand Down
46 changes: 38 additions & 8 deletions include/klee/Core/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@
#ifndef KLEE_INTERPRETER_H
#define KLEE_INTERPRETER_H

#include "TerminationTypes.h"

#include "klee/Module/SarifReport.h"

#include <map>
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#include <nonstd/optional.hpp>

using nonstd::optional;

struct KTest;

namespace llvm {
class BasicBlock;
class Function;
class LLVMContext;
class Module;
Expand All @@ -27,8 +37,10 @@ class raw_fd_ostream;

namespace klee {
class ExecutionState;
struct SarifReport;
class Interpreter;
class TreeStreamWriter;
class InstructionInfoTable;

class InterpreterHandler {
public:
Expand All @@ -50,25 +62,36 @@ class InterpreterHandler {

class Interpreter {
public:
enum class GuidanceKind {
NoGuidance, // Default symbolic execution
CoverageGuidance, // Use GuidedSearcher and guidedRun to maximize full code
// coverage
ErrorGuidance // Use GuidedSearcher and guidedRun to maximize specified
// targets coverage
};

/// ModuleOptions - Module level options which can be set when
/// registering a module with the interpreter.
struct ModuleOptions {
std::string LibraryDir;
std::string EntryPoint;
std::string OptSuffix;
bool Optimize;
bool Simplify;
bool CheckDivZero;
bool CheckOvershift;
bool WithFPRuntime;
bool WithPOSIXRuntime;

ModuleOptions(const std::string &_LibraryDir,
const std::string &_EntryPoint, const std::string &_OptSuffix,
bool _Optimize, bool _CheckDivZero, bool _CheckOvershift,
bool _WithFPRuntime)
bool _Optimize, bool _Simplify, bool _CheckDivZero,
bool _CheckOvershift, bool _WithFPRuntime,
bool _WithPOSIXRuntime)
: LibraryDir(_LibraryDir), EntryPoint(_EntryPoint),
OptSuffix(_OptSuffix), Optimize(_Optimize),
OptSuffix(_OptSuffix), Optimize(_Optimize), Simplify(_Simplify),
CheckDivZero(_CheckDivZero), CheckOvershift(_CheckOvershift),
WithFPRuntime(_WithFPRuntime) {}
WithFPRuntime(_WithFPRuntime), WithPOSIXRuntime(_WithPOSIXRuntime) {}
};

enum LogType {
Expand All @@ -84,12 +107,16 @@ class Interpreter {
/// symbolic values. This is used to test the correctness of the
/// symbolic execution on concrete programs.
unsigned MakeConcreteSymbolic;
GuidanceKind Guidance;
nonstd::optional<SarifReport> Paths;

InterpreterOptions() : MakeConcreteSymbolic(false) {}
InterpreterOptions(nonstd::optional<SarifReport> Paths)
: MakeConcreteSymbolic(false), Guidance(GuidanceKind::NoGuidance),
Paths(std::move(Paths)) {}
};

protected:
const InterpreterOptions interpreterOpts;
const InterpreterOptions &interpreterOpts;

Interpreter(const InterpreterOptions &_interpreterOpts)
: interpreterOpts(_interpreterOpts) {}
Expand All @@ -112,7 +139,8 @@ class Interpreter {
setModule(std::vector<std::unique_ptr<llvm::Module>> &userModules,
std::vector<std::unique_ptr<llvm::Module>> &libsModules,
const ModuleOptions &opts,
const std::vector<std::string> &mainModuleFunctions) = 0;
const std::vector<std::string> &mainModuleFunctions,
std::unique_ptr<InstructionInfoTable> origInfos) = 0;

// supply a tree stream writer which the interpreter will use
// to record the concrete path (as a stream of '0' and '1' bytes).
Expand Down Expand Up @@ -140,12 +168,14 @@ class Interpreter {

/*** Runtime options ***/

virtual void setHaltExecution(bool value) = 0;
virtual void setHaltExecution(HaltExecution::Reason value) = 0;

virtual void setInhibitForking(bool value) = 0;

virtual void prepareForEarlyExit() = 0;

virtual bool hasTargetForest() const = 0;

/*** State accessor methods ***/

virtual unsigned getPathStreamID(const ExecutionState &state) = 0;
Expand Down
38 changes: 38 additions & 0 deletions include/klee/Core/TargetedExecutionReporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//===-- TargetedExecutionReporter.h ------------------------------*- C++-*-===//
//
// The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef KLEE_TARGETEDEXECUTIONREPORTER_H
#define KLEE_TARGETEDEXECUTIONREPORTER_H

#include "klee/Module/SarifReport.h"

#include <unordered_set>

namespace klee {

namespace confidence {
using ty = double;
static ty MinConfidence = 0.0;
static ty MaxConfidence = 100.0;
static ty Confident = 90.0;
static ty VeryConfident = 99.0;
bool isConfident(ty conf);
bool isVeryConfident(ty conf);
bool isNormal(ty conf);
std::string toString(ty conf);
ty min(ty left, ty right);
}; // namespace confidence

void reportFalsePositive(confidence::ty confidence,
const std::unordered_set<ReachWithError> &errors,
unsigned id, std::string whatToIncrease);

} // namespace klee

#endif
25 changes: 23 additions & 2 deletions include/klee/Core/TerminationTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
TTYPE(ReadOnly, 17U, "read_only.err") \
TTYPE(ReportError, 18U, "report_error.err") \
TTYPE(UndefinedBehavior, 19U, "undefined_behavior.err") \
MARK(PROGERR, 19U) \
TTYPE(InternalOutOfMemory, 20U, "out_of_memory.er") \
MARK(PROGERR, 20U) \
TTYPE(User, 23U, "user.err") \
MARK(USERERR, 23U) \
TTYPE(Execution, 25U, "exec.err") \
Expand All @@ -42,7 +43,8 @@
TTYPE(Replay, 27U, "") \
TTYPE(Merge, 28U, "") \
TTYPE(SilentExit, 29U, "") \
MARK(END, 29U)
TTYPE(Paused, 30U, "") \
MARK(END, 30U)

///@brief Reason an ExecutionState got terminated.
enum class StateTerminationType : std::uint8_t {
Expand All @@ -53,4 +55,23 @@ enum class StateTerminationType : std::uint8_t {
#undef MARK
};

namespace HaltExecution {
enum Reason {
NotHalt = 0,
MaxTests,
MaxInstructions,
MaxSteppedInstructions,
MaxTime,
CovCheck,
NoMoreStates,
ReachedTarget,
ErrorOnWhichShouldExit,
Interrupt,
MaxDepth,
MaxStackFrames,
MaxSolverTime,
Unspecified
};
};

#endif
13 changes: 5 additions & 8 deletions include/klee/Expr/Assignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@ class Assignment {
Assignment(const bindings_ty &_bindings, bool _allowFreeValues = false)
: allowFreeValues(_allowFreeValues), bindings(_bindings) {}
Assignment(const std::vector<const Array *> &objects,
std::vector<SparseStorage<unsigned char>> &values,
const std::vector<SparseStorage<unsigned char>> &values,
bool _allowFreeValues = false)
: allowFreeValues(_allowFreeValues) {
std::vector<SparseStorage<unsigned char>>::iterator valIt = values.begin();
for (std::vector<const Array *>::const_iterator it = objects.begin(),
ie = objects.end();
it != ie; ++it) {
const Array *os = *it;
SparseStorage<unsigned char> &arr = *valIt;
assert(objects.size() == values.size());
for (unsigned i = 0; i < values.size(); ++i) {
const Array *os = objects.at(i);
const SparseStorage<unsigned char> &arr = values.at(i);
bindings.insert(std::make_pair(os, arr));
++valIt;
}
}

Expand Down
9 changes: 7 additions & 2 deletions include/klee/Expr/SourceBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class SourceBuilder {
private:
static ref<SymbolicSource> constantSource;
static ref<SymbolicSource> makeSymbolicSource;
static ref<SymbolicSource> lazyInitializationMakeSymbolicSource;
static ref<SymbolicSource> symbolicAddressSource;
static ref<SymbolicSource> lazyInitializationSymbolicSource;
static ref<SymbolicSource> irreproducibleSource;
static ref<SymbolicSource> symbolicValueSource;

public:
SourceBuilder() = delete;
Expand All @@ -20,7 +23,9 @@ class SourceBuilder {
static ref<SymbolicSource> makeSymbolic();
static ref<SymbolicSource> symbolicAddress();
static ref<SymbolicSource> symbolicSize();
static ref<SymbolicSource> lazyInitializationMakeSymbolic();
static ref<SymbolicSource> lazyInitializationSymbolic();
static ref<SymbolicSource> irreproducible();
static ref<SymbolicSource> symbolicValue();
};

}; // namespace klee
Expand Down
30 changes: 28 additions & 2 deletions include/klee/Expr/SymbolicSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class SymbolicSource {
LazyInitializationSymbolic,
MakeSymbolic,
SymbolicAddress,
SymbolicSize
SymbolicSize,
Irreproducible,
SymbolicValue
};

public:
Expand Down Expand Up @@ -120,7 +122,7 @@ class LazyInitializationSymbolicSource : public SymbolicSource {
public:
Kind getKind() const override { return Kind::LazyInitializationSymbolic; }
virtual std::string getName() const override {
return "lazyInitializationMakeSymbolic";
return "lazyInitializationSymbolic";
}
virtual bool isSymcrete() const override { return false; }

Expand All @@ -129,6 +131,30 @@ class LazyInitializationSymbolicSource : public SymbolicSource {
}
};

class IrreproducibleSource : public SymbolicSource {
public:
Kind getKind() const override { return Kind::Irreproducible; }
virtual std::string getName() const override { return "irreproducible"; }
virtual bool isSymcrete() const override { return false; }

static bool classof(const SymbolicSource *S) {
return S->getKind() == Kind::Irreproducible;
}
static bool classof(const IrreproducibleSource *) { return true; }
};

class SymbolicValueSource : public SymbolicSource {
public:
Kind getKind() const override { return Kind::SymbolicValue; }
virtual std::string getName() const override { return "symbolicValue"; }
virtual bool isSymcrete() const override { return false; }

static bool classof(const SymbolicSource *S) {
return S->getKind() == Kind::SymbolicValue;
}
static bool classof(const SymbolicValueSource *) { return true; }
};

} // namespace klee

#endif /* KLEE_SYMBOLICSOURCE_H */
Loading