Skip to content

Commit

Permalink
Add static analysis scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse-V committed Sep 28, 2015
1 parent cee91a8 commit 247f70f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 16 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ I provide builds for Debian Wheezy in the [Releases section](https://github.com/
> 2. Download and extract the latest release from the [Releases page](https://github.com/Jesse-V/OnioNS-client/releases).
> 3. **(mkdir build; cd build; cmake ../src; make; sudo make install)**
The rebuild.sh script is available if you are actively developing OnioNS. You will need to install *clang-format-3.6* and *cppcheck* as the script also styles the code and performs a static analysis check.
The rebuild.sh script is available if you are actively developing OnioNS. You will need to install *clang-3.5*, *clang-format-3.5*, and *cppcheck* as the script also styles the code and performs a static analysis check.

You can cleanup your build with **rm -rf build**

Expand All @@ -55,12 +55,14 @@ This replaces the normal Tor binary with a executable that launches the original
The Tor Browser operates as before, but the OnioNS software running in the background allows the Tor Browser to load hidden services under a .tor domain name.

> 1. Open the Tor Browser.
> 2. Type "example.tor" into the Tor Browser.
> 3. In a moment, you should arrive at the project's hidden service.
> 2. Visit "check.torproject.org" or click the link on the homepage as you normally would to check for Tor's status.
> 3. You should be redirected to a page indicating that OnioNS is working correctly. If so, proceed to step 4. Otherwise, OnioNS isn't working properly and you will see the normal Tor Check page with your exit's IP address.
> 4. Type "example.tor" into the Tor Browser, or any other name that you know to be registered.
> 5. In a moment, the Tor Browser should load a hidden service.
### Troubleshooting

If at startup the Tor Browser immediately throws a message saying "Something Went Wrong! Tor is not working in this browser." it most likely means that the OnioNS software was unable to connect to the network. This is a fatal situation, so the software aborts and the Tor Browser throws this message. Since this occurs after Tor starts, the issue is most likely not on your end. Please contact me (see below) for assistance.
If at startup the Tor Browser immediately throws a message saying "Something Went Wrong! Tor is not working in this browser." or if you get a message saying that Tor exited unexpectedly, it most likely means that the OnioNS software was unable to connect to its network. This is a fatal situation, so the software aborts and the Tor Browser throws this message. Since this occurs after Tor starts, the issue is most likely not on your end. Please contact me (see below) for assistance.

If you are unable to load "example.tor", it's possible that either the hidden service is down or that the OnioNS software is not running properly on your end. To test this, visit "onions55e7yam27n.onion". If the site loads, you could try restarting the Tor Browser, which may clear the issue. If the site still does not load, please contact me for further assistance.

Expand All @@ -70,4 +72,4 @@ If you have installed the software and then initialized the Tor Browser (again,

### How to Contribute

Most of all, I need more testers to verify that the software is stable and reliable. If you find an issue, please report it on Github. I also need inspections: of the network using Wireshark or similar tools to verify that there are no leaks, and of the code by examining the code for corner-cases or situations that I may have missed. If are a developer, I gladly accept pull requests.
Most of all, I need more testers to verify that the software is stable and reliable. If you find an issue, please report it on Github. I am working on adding unit tests, which should help address many corner-cases and crashes for unexpected input. If are a developer, I gladly accept pull requests.
39 changes: 39 additions & 0 deletions checkBuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

# This script performs two static analysis checks of src, first using Clang's
# scan-build program and the second using cppcheck. As scan-build integrates
# nicely into the build process, the code is also compiled. However, due to the
# extra analysis, this script can take some time to complete so it's best run
# infrequently, such as before a release.

# Please install clang-3.6 and cppcheck before running this script.

export CCC_CXX=clang++-3.6
export CCC_CC=clang-3.6

mkdir -p build/
cd build
scan-build-3.6 cmake ../src -DCMAKE_CXX_COMPILER=/usr/share/clang/scan-build-3.6/c++-analyzer -DCMAKE_C_COMPILER=/usr/share/clang/scan-build-3.6/ccc-analyzer # -DCMAKE_BUILD_TYPE=Debug

echo "Compiling with Clang static analysis... -------------------------------"
rm -rf /tmp/scan-build-*
if (scan-build-3.6 -maxloop 16 -enable-checker core -enable-checker cplusplus -disable-checker deadcode -enable-checker security -enable-checker unix make -j $(grep -c ^processor /proc/cpuinfo)) then

if [ $(ls /tmp/scan-build-* | wc -l 2> /dev/null) -gt 0 ]; then
echo "Failure: static analysis contains reports."
cd ..
rm -rf build/

else
echo "Additional static analysis... ----------------------------------------------"
cd ..
cppcheck --enable=all --platform=unix64 --inconclusive src/*

echo "Success: compilation and scan-build check successful!"
fi
else
echo "Failure: compilation errors."

cd ..
rm -rf build/
fi
9 changes: 4 additions & 5 deletions rebuild.sh → devBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ gzip --best -c src/assets/manpage | sed "s/<DATE>/$date/g" > src/assets/onions-c

echo "Preparing build... ----------------------------------------------"

export CXX=/usr/bin/clang++
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++-3.6
export CC=/usr/bin/clang-3.6

mkdir -p build/
cd build
cmake ../src # -DCMAKE_BUILD_TYPE=Debug

echo "Compiling... ----------------------------------------------"
if (make -j $(grep -c ^processor /proc/cpuinfo)) then
echo "Static analysis... ----------------------------------------------"
cd ..
cppcheck --enable=all --platform=unix64 --inconclusive src/*
echo "Compilation successful!"
else
rm -f onions-client onions-tbb
cd ..
rm -rf build/
fi

4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ find_package(Boost COMPONENTS system REQUIRED)

#compiler options for Clang and GCC/G++
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-g -O3 --std=c++11 -Wno-c++98-compat-pedantic -pedantic -Weverything -Wno-exit-time-destructors -Wno-weak-vtables -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro -Wno-missing-noreturn -Wno-padded")
set(CMAKE_CXX_FLAGS "-g -O3 -std=c++11 -Wno-c++98-compat-pedantic -pedantic -Weverything -Wno-exit-time-destructors -Wno-weak-vtables -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro -Wno-missing-noreturn -Wno-padded")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-g -O3 --std=c++11 -Wall -Wextra -pedantic -Wdouble-promotion -Wfloat-equal -Wunsafe-loop-optimizations")
set(CMAKE_CXX_FLAGS "-g -O3 -std=c++11 -Wall -Wextra -pedantic -Wdouble-promotion -Wfloat-equal -Wunsafe-loop-optimizations")
endif()

include_directories(${CMAKE_INSTALL_PREFIX}/include/onions-common /usr/include/botan-1.10)
Expand Down
14 changes: 10 additions & 4 deletions src/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Client.hpp"
#include "tcp/IPC.hpp"
#include <onions-common/Common.hpp>
#include <onions-common/containers/MerkleTree.hpp>
#include <onions-common/containers/Cache.hpp>
#include <onions-common/Log.hpp>
#include <onions-common/Config.hpp>
Expand Down Expand Up @@ -74,18 +75,19 @@ bool Client::resolveOnce(std::string& domain)

Cache::add(record);

// todo: we can cache the subtrees to avoid refetching every time
Json::Value subtreeObj = fetchMerkleSubtree(domain);
Log::get().notice(subtreeObj["value"].toStyledString());

// todo: MerkleTree::doesContain(subtreeJSON, record)
// todo: check root
if (!MerkleTree::doesContain(subtreeObj, record))
return false;

SHA384_HASH tmpHash;
SHA384_HASH tmpHash; // todo: replace with actual merkle hash
if (!fetchQuorumRootSignature(tmpHash))
return false;
}

//Log::get().notice("Record was successfully authenticated.");
// Log::get().notice("Record was successfully authenticated.");
domain = Common::getDestination(record, domain);
return true;
}
Expand Down Expand Up @@ -135,6 +137,10 @@ bool Client::fetchQuorumRootSignature(const SHA384_HASH& root)
ED_SIGNATURE sig;
auto result =
Common::verifyRootSignature(response["value"], sig, root, Q_KEY);

// MerkleTree::extractRoot

// todo: MerkleTree::verifyRoot
return result.first;
}
}

0 comments on commit 247f70f

Please sign in to comment.