Skip to content

Commit

Permalink
Merge branch 'secure-software-engineering:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianbs96 authored Mar 12, 2024
2 parents 27c4c49 + d5bd11d commit 71d7059
Show file tree
Hide file tree
Showing 171 changed files with 4,861 additions and 4,745 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Checks: '-*,
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
-misc-use-anonymous-namespace,
readability-*,
-readability-function-cognitive-complexity,
-readability-else-after*,
Expand Down
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ Dockerfile @janniclas
/.docker/ @janniclas

/include/phasar/Utils/Logger.h @MMory
/include/phasar/Utils/AnalysisPrinterBase.h @sritejakv
/include/phasar/Utils/DefaultAnalysisPrinter.h @sritejakv
/include/phasar/Utils/NullAnalysisPrinter.h @sritejakv
/include/phasar/Utils/OnTheFlyAnalysisPrinter.h @sritejakv
/include/phasar/PhasarLLVM/Utils/SourceMgrPrinter.h @sritejakv
/lib/PhasarLLVM/Utils/SourceMgrPrinter.cpp @sritejakv
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
- build: Debug
flags: -DPHASAR_BUILD_DYNLIB=ON -DPHASAR_ENABLE_SANITIZERS=ON
- build: Release
flags: -DPHASAR_ENABLE_DYNAMIC_LOG=OFF
flags: -DPHASAR_ENABLE_DYNAMIC_LOG=OFF -DPHASAR_DEBUG_LIBDEPS=ON -DBUILD_SHARED_LIBS=ON

continue-on-error: false
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
Expand Down Expand Up @@ -64,7 +64,6 @@ jobs:
cmake .. \
-DCMAKE_BUILD_TYPE=${{ matrix.build }} \
-DBUILD_SWIFT_TESTS=ON \
-DPHASAR_DEBUG_LIBDEPS=ON \
-DPHASAR_USE_Z3=ON \
${{ matrix.flags }} \
-G Ninja
Expand Down
7 changes: 6 additions & 1 deletion BreakingChanges.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Breaking Changes

## Development HEAD
## development HEAD

- Removed IfdsFieldSensTaintAnalysis as it relies on LLVM's deprecated typed-pointers.

## v2403

- Versioning scheme has been changed from `<month><year>` to `<year><month>`
- Default build mode is no longer `SHARED` but `STATIC`. To build in shared mode, use the cmake option `BUILD_SHARED_LIBS` which we don't recommend anymore. Consider using `PHASAR_BUILD_DYNLIB` instead to build one big libphasar.so.
- Build type `DebugSan` has been removed in favor of a new CMake option `PHASAR_ENABLE_SANITIZERS` that not only works in `Debug` mode.

Expand Down
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,23 @@ option(PHASAR_ENABLE_CLANG_TIDY_DURING_BUILD "Run clang-tidy during build (defau

option(PHASAR_BUILD_DOC "Build documentation" OFF)

option(PHASAR_DEBUG_LIBDEPS "Debug internal library dependencies (private linkage)" OFF)

#option(BUILD_SHARED_LIBS "Build shared libraries (default is ON)" ON)
option(PHASAR_BUILD_DYNLIB "Build one fat shared library. Requires BUILD_SHARED_LIBS to be turned OFF (default is OFF)" OFF)

if(PHASAR_BUILD_DYNLIB AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "PHASAR_BUILD_DYNLIB is incompatible with BUILD_SHARED_LIBS")
endif()

option(PHASAR_DEBUG_LIBDEPS "Debug internal library dependencies (private linkage)" OFF)
if (PHASAR_DEBUG_LIBDEPS)
if (NOT BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
message("PHASAR_DEBUG_LIBDEPS only works for shared libraries, so set BUILD_SHARED_LIBS=ON")
endif()
if (PHASAR_ENABLE_SANITIZERS)
message(FATAL_ERROR "PHASAR_DEBUG_LIBDEPS is incompatible with ASAN (see https://clang.llvm.org/docs/AddressSanitizer.html#usage)")
endif()
endif ()

option(PHASAR_ENABLE_PIC "Build Position-Independed Code" ON)
if (PHASAR_ENABLE_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -542,7 +550,7 @@ configure_package_config_file(

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/phasarConfigVersion.cmake
VERSION 1.0.0
VERSION 2403
COMPATIBILITY SameMajorVersion
)

Expand Down
2 changes: 1 addition & 1 deletion Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(PHASAR_VERSION 1.0.0)
set(PHASAR_VERSION 2403)

@PACKAGE_INIT@
set_and_check(PHASAR_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:22.04
ARG LLVM_INSTALL_DIR="/usr/local/llvm-14"
LABEL Name=phasar Version=1.0.0
LABEL Name=phasar Version=2403

RUN apt -y update && apt install bash sudo -y

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![C++ Standard](https://img.shields.io/badge/C++_Standard-C%2B%2B17-blue.svg?style=flat&logo=c%2B%2B)](https://isocpp.org/)
[![GitHub license](https://img.shields.io/badge/license-MIT-blueviolet.svg)](https://raw.githubusercontent.com/secure-software-engineering/phasar/master/LICENSE.txt)

Version 0323
Version 2403

## Secure Software Engineering Group

Expand Down
6 changes: 2 additions & 4 deletions cmake/phasar_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,11 @@ function(add_phasar_library name)
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
endif(LLVM_COMMON_DEPENDS)

target_link_libraries(${name} PUBLIC ${PHASAR_LIB_LINKS} phasar_interface ${PHASAR_LIB_LINK_PUBLIC})
if(PHASAR_DEBUG_LIBDEPS)
target_link_libraries(${name} PRIVATE ${PHASAR_LIB_LINKS})
else()
target_link_libraries(${name} PUBLIC ${PHASAR_LIB_LINKS})
target_link_libraries(${name} PRIVATE -Wl,-z,defs)
endif()

target_link_libraries(${name} PUBLIC phasar_interface ${PHASAR_LIB_LINK_PUBLIC})
target_link_libraries(${name} PRIVATE ${PHASAR_LIB_LINK_PRIVATE})

phasar_link_llvm(${name} ${PHASAR_LIB_LLVM_LINK_COMPONENTS})
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
#cmakedefine PAMM_FULL

#cmakedefine DYNAMIC_LOG
#cmakedefine BUILD_PHASAR_CLANG

#endif /* PHASAR_CONFIG_CONFIG_H */
6 changes: 3 additions & 3 deletions githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
local="$(git rev-parse --abbrev-ref HEAD)"

if [ "$local" = "master" ] ; then
version="#define PHASAR_VERSION v"
version="${version}$(date +"%m%y")"
echo "${version}" > include/phasar/Config/Version.h
version="#define PHASAR_VERSION v"
version="${version}$(date +"%y%m")"
echo "${version}" > include/phasar/Config/Version.h
fi
5 changes: 4 additions & 1 deletion include/phasar.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
#include "phasar/DB.h"
#include "phasar/DataFlow.h"
#include "phasar/Domain.h"
#include "phasar/PhasarClang.h"
#include "phasar/PhasarLLVM.h"
#include "phasar/PhasarPass.h"
#include "phasar/Pointer.h"
#include "phasar/TypeHierarchy.h"
#include "phasar/Utils.h"

#ifdef BUILD_PHASAR_CLANG
#include "phasar/PhasarClang.h"
#endif

#endif // PHASAR_H
2 changes: 1 addition & 1 deletion include/phasar/Config/Version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef PHASAR_CONFIG_VERSION_H
#define PHASAR_CONFIG_VERSION_H

#define PHASAR_VERSION v0323
#define PHASAR_VERSION v2403

#endif
172 changes: 17 additions & 155 deletions include/phasar/Controller/AnalysisController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,159 +13,27 @@
#include "phasar/AnalysisStrategy/Strategies.h"
#include "phasar/Controller/AnalysisControllerEmitterOptions.h"
#include "phasar/DataFlow/IfdsIde/IFDSIDESolverConfig.h"
#include "phasar/DataFlow/IfdsIde/Solver/IDESolver.h"
#include "phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h"
#include "phasar/DataFlow/IfdsIde/SolverResults.h"
#include "phasar/DataFlow/Mono/Solver/InterMonoSolver.h"
#include "phasar/DataFlow/Mono/Solver/IntraMonoSolver.h"
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h"
#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h"
#include "phasar/PhasarLLVM/HelperAnalyses.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h"
#include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h"
#include "phasar/PhasarLLVM/TaintConfig/LLVMTaintConfig.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h"
#include "phasar/Utils/EnumFlags.h"
#include "phasar/Utils/IO.h"
#include "phasar/Utils/Soundness.h"

#include <set>
#include <string>
#include <vector>

#include <filesystem>
namespace psr {

class AnalysisController {
private:
HelperAnalyses &HA;
std::vector<DataFlowAnalysisType> DataFlowAnalyses;
std::vector<std::string> AnalysisConfigs;
std::vector<std::string> EntryPoints;
[[maybe_unused]] AnalysisStrategy Strategy;
AnalysisControllerEmitterOptions EmitterOptions =
AnalysisControllerEmitterOptions::None;
std::string ProjectID;
std::filesystem::path ResultDirectory;
IFDSIDESolverConfig SolverConfig;

///
/// \brief The maximum length of the CallStrings used in the InterMonoSolver
///
static const unsigned K = 3;

void executeDemandDriven();

void executeIncremental();

void executeModuleWise();

void executeVariational();

void executeWholeProgram();

void emitRequestedHelperAnalysisResults();

void executeIFDSUninitVar();
void executeIFDSConst();
void executeIFDSTaint();
void executeIFDSType();
void executeIFDSSolverTest();
void executeIFDSFieldSensTaint();
void executeIDEXTaint();
void executeIDEOpenSSLTS();
void executeIDECSTDIOTS();
void executeIDELinearConst();
void executeIDESolverTest();
void executeIDEIIA();
void executeIntraMonoFullConstant();
void executeIntraMonoSolverTest();
void executeInterMonoSolverTest();
void executeInterMonoTaint();

template <typename SolverTy, typename ProblemTy, typename... ArgTys>
void executeMonoAnalysis(ArgTys &&...Args) {
auto Problem =
createAnalysisProblem<ProblemTy>(HA, std::forward<ArgTys>(Args)...);
SolverTy Solver(Problem);
Solver.solve();
emitRequestedDataFlowResults(Solver);
}

template <typename ProblemTy, typename... ArgTys>
void executeIntraMonoAnalysis(ArgTys &&...Args) {
executeMonoAnalysis<IntraMonoSolver_P<ProblemTy>, ProblemTy>(
std::forward<ArgTys>(Args)...);
}

template <typename ProblemTy, typename... ArgTys>
void executeInterMonoAnalysis(ArgTys &&...Args) {
executeMonoAnalysis<InterMonoSolver_P<ProblemTy, 3>, ProblemTy>(
std::forward<ArgTys>(Args)...);
}

template <typename SolverTy, typename ProblemTy, typename... ArgTys>
void executeIfdsIdeAnalysis(ArgTys &&...Args) {
auto Problem =
createAnalysisProblem<ProblemTy>(HA, std::forward<ArgTys>(Args)...);
SolverTy Solver(Problem, &HA.getICFG());
Solver.solve();
emitRequestedDataFlowResults(Solver);
}

template <typename ProblemTy, typename... ArgTys>
void executeIFDSAnalysis(ArgTys &&...Args) {
executeIfdsIdeAnalysis<IFDSSolver_P<ProblemTy>, ProblemTy>(
std::forward<ArgTys>(Args)...);
}

template <typename ProblemTy, typename... ArgTys>
void executeIDEAnalysis(ArgTys &&...Args) {
executeIfdsIdeAnalysis<IDESolver_P<ProblemTy>, ProblemTy>(
std::forward<ArgTys>(Args)...);
}

LLVMTaintConfig makeTaintConfig();

template <typename T> void emitRequestedDataFlowResults(T &Solver) {
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitTextReport) {
if (!ResultDirectory.empty()) {
if (auto OFS =
openFileStream(ResultDirectory.string() + "/psr-report.txt")) {
Solver.emitTextReport(*OFS);
}
} else {
Solver.emitTextReport(llvm::outs());
}
}
if (EmitterOptions &
AnalysisControllerEmitterOptions::EmitGraphicalReport) {
if (!ResultDirectory.empty()) {
if (auto OFS =
openFileStream(ResultDirectory.string() + "/psr-report.html")) {
Solver.emitGraphicalReport(*OFS);
}
} else {
Solver.emitGraphicalReport(llvm::outs());
}
}
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitRawResults) {
if (!ResultDirectory.empty()) {
if (auto OFS = openFileStream(ResultDirectory.string() +
"/psr-raw-results.txt")) {
Solver.dumpResults(*OFS);
}
} else {
Solver.dumpResults(llvm::outs());
}
}
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitESGAsDot) {
llvm::outs()
<< "Front-end support for 'EmitESGAsDot' to be implemented\n";
}
}

public:
struct ControllerData {
HelperAnalyses *HA{};
std::vector<DataFlowAnalysisType> DataFlowAnalyses;
std::vector<std::string> AnalysisConfigs;
std::vector<std::string> EntryPoints;
[[maybe_unused]] AnalysisStrategy Strategy;
AnalysisControllerEmitterOptions EmitterOptions =
AnalysisControllerEmitterOptions::None;
std::string ProjectID;
std::filesystem::path ResultDirectory;
IFDSIDESolverConfig SolverConfig{};
};

explicit AnalysisController(
HelperAnalyses &HA, std::vector<DataFlowAnalysisType> DataFlowAnalyses,
std::vector<std::string> AnalysisConfigs,
Expand All @@ -175,21 +43,15 @@ class AnalysisController {
std::string ProjectID = "default-phasar-project",
std::string OutDirectory = "");

~AnalysisController() = default;

AnalysisController(const AnalysisController &) = delete;
AnalysisController(AnalysisController &&) = delete;
AnalysisController &operator=(const AnalysisController &) = delete;
AnalysisController &operator=(const AnalysisController &&) = delete;

void executeAs(AnalysisStrategy Strategy);

static constexpr bool
needsToEmitPTA(AnalysisControllerEmitterOptions EmitterOptions) {
return (EmitterOptions & AnalysisControllerEmitterOptions::EmitPTAAsDot) ||
(EmitterOptions & AnalysisControllerEmitterOptions::EmitPTAAsJson) ||
(EmitterOptions & AnalysisControllerEmitterOptions::EmitPTAAsText);
}

private:
ControllerData Data;
};

} // namespace psr
Expand Down
Loading

0 comments on commit 71d7059

Please sign in to comment.