Skip to content

Commit 118ae3d

Browse files
committed
Updating to address configure issues with RHEL / CentOS 7
2 parents df24e2b + ec973dc commit 118ae3d

32 files changed

+369
-151
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [master]
9+
schedule:
10+
- cron: '0 4 * * 4'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
# Override automatic language detection by changing the below list
21+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
22+
language: ['cpp']
23+
# Learn more...
24+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v2
29+
with:
30+
# We must fetch at least the immediate parents so that if this is
31+
# a pull request then we can checkout the head.
32+
fetch-depth: 2
33+
34+
# If this run was triggered by a pull request event, then checkout
35+
# the head of the pull request instead of the merge commit.
36+
- run: git checkout HEAD^2
37+
if: ${{ github.event_name == 'pull_request' }}
38+
39+
# Initializes the CodeQL tools for scanning.
40+
- name: Initialize CodeQL
41+
uses: github/codeql-action/init@v1
42+
with:
43+
languages: ${{ matrix.language }}
44+
45+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
46+
# If this step fails, then you should remove it and run the build manually (see below)
47+
#- name: Autobuild
48+
# uses: github/codeql-action/autobuild@v1
49+
50+
# ℹ️ Command-line programs to run using the OS shell.
51+
# 📚 https://git.io/JvXDl
52+
53+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
54+
# and modify them (or add more) to build your code if your project
55+
# uses a compiled language
56+
57+
- name: Install libmicrohttpd dependency
58+
run: |
59+
curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-0.9.59.tar.gz -o libmicrohttpd-0.9.59.tar.gz ;
60+
tar -xzf libmicrohttpd-0.9.59.tar.gz ;
61+
cd libmicrohttpd-0.9.59 ;
62+
./configure --disable-examples ;
63+
make ;
64+
sudo make install ;
65+
66+
- name: Manual steps to build the library
67+
run: |
68+
./bootstrap ;
69+
./configure --enable-same-directory-build;
70+
make ;
71+
72+
- name: Perform CodeQL Analysis
73+
uses: github/codeql-action/analyze@v1

.travis.yml

Lines changed: 65 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,79 +9,82 @@ env:
99
- DEBUG="debug" COVERAGE="coverage"
1010
- DEBUG="nodebug" COVERAGE="nocoverage"
1111
- LINKING="static"
12-
before_cache:
13-
- |-
14-
case $TRAVIS_OS_NAME in
15-
windows)
16-
# https://unix.stackexchange.com/a/137322/107554
17-
$msys2 pacman --sync --clean --noconfirm
18-
;;
19-
esac
20-
cache:
21-
directories:
22-
- $HOME/AppData/Local/Temp/chocolatey
23-
- /C/tools/msys64
2412
before_install:
2513
- eval "${MATRIX_EVAL}"
26-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/lib"; fi
27-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export PATH=$PATH:/usr/local/lib; fi
28-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib; fi
29-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib; fi
30-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then export buildshell=''; fi
14+
# Installing iwyu manually because clang and iwyu paths won't match on Ubuntu otherwise.
15+
- if [ "$IWYU" = "iwyu" ]; then
16+
CLANG_VERSION=`clang --version | grep version | cut -f3 -d' ' | cut -f1 -d'-'` ;
17+
CLANG_PKG_VERSION=`echo $CLANG_VERSION | cut -f1,2 -d'.'`
18+
CLANG_PREFIX_PATH="/usr/local/clang-${CLANG_VERSION}/lib/clang/${CLANG_VERSION}" ;
19+
CLANG_BIN_PATH="/usr/local/clang-${CLANG_VERSION}/bin" ;
20+
git clone https://github.com/include-what-you-use/include-what-you-use.git ;
21+
cd include-what-you-use ;
22+
echo "$CLANG_PKG_VERSION" | grep '\.[0-9]$' ;
23+
if [ $? -eq 0 ]; then
24+
git checkout clang_${CLANG_PKG_VERSION} ;
25+
else
26+
git checkout clang_${CLANG_PKG_VERSION}.0 ;
27+
fi;
28+
cd .. ;
29+
mkdir build_iwyu ;
30+
cd build_iwyu ;
31+
cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=$CLANG_PREFIX_PATH -DCMAKE_C_COMPILER=$CLANG_BIN_PATH/clang -DCMAKE_CXX_COMPILER=$CLANG_BIN_PATH/clang++ ../include-what-you-use ;
32+
make ;
33+
sudo make install ;
34+
cd .. ;
35+
fi
36+
- export LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/lib"
37+
- export PATH=$PATH:/usr/local/lib
38+
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
39+
- export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib
3140
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install info install-info; fi
3241
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo pip install codecov; fi
3342
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo pip install gcovr; fi
3443
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install cppcheck; fi
3544
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export CFLAGS='-mtune=generic'; fi
36-
- |-
37-
case $TRAVIS_OS_NAME in
38-
windows)
39-
[[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
40-
choco uninstall -y mingw
41-
choco upgrade --no-progress -y msys2
42-
export msys2='cmd //C RefreshEnv.cmd '
43-
export msys2+='& set MSYS=winsymlinks:nativestrict '
44-
export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
45-
export buildshell="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
46-
export msys2+=" -msys2 -c "\"\$@"\" --"
47-
$msys2 pacman --sync --noconfirm --disable-download-timeout --needed mingw-w64-x86_64-toolchain
48-
$msys2 pacman -Syu --noconfirm --disable-download-timeout autoconf libtool automake make autoconf-archive pkg-config mingw-w64-x86_64-libsystre mingw-w64-x86_64-doxygen mingw-w64-x86_64-gnutls mingw-w64-x86_64-graphviz mingw-w64-x86_64-curl
49-
export PATH=/C/tools/msys64/mingw64/bin:$PATH
50-
export MAKE=mingw32-make # so that Autotools can find it
51-
;;
52-
esac
45+
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export IPV6_TESTS_ENABLED="true"; fi
5346
- curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-0.9.59.tar.gz -o libmicrohttpd-0.9.59.tar.gz
5447
- tar -xzf libmicrohttpd-0.9.59.tar.gz
5548
- cd libmicrohttpd-0.9.59
56-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then $buildshell ./configure --disable-examples; else $buildshell ./configure --disable-examples --enable-poll=no; fi;
57-
- $buildshell make
58-
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then sudo make install; else $buildshell make install; fi
49+
- ./configure --disable-examples
50+
- make
51+
- sudo make install
5952
- cd ..
6053
- if [ "$BUILD_TYPE" = "asan" ]; then export CFLAGS='-fsanitize=address'; export CXXLAGS='-fsanitize=address'; export LDFLAGS='-fsanitize=address'; fi
6154
- if [ "$BUILD_TYPE" = "msan" ]; then export CFLAGS='-fsanitize=memory'; export CXXLAGS='-fsanitize=memory'; export LDFLAGS='-fsanitize=memory'; fi
6255
- if [ "$BUILD_TYPE" = "lsan" ]; then export CFLAGS='-fsanitize=leak'; export CXXLAGS='-fsanitize=leak'; export LDFLAGS='-fsanitize=leak'; fi
6356
- if [ "$BUILD_TYPE" = "tsan" ]; then export CFLAGS='-fsanitize=thread'; export CXXLAGS='-fsanitize=thread'; export LDFLAGS='-fsanitize=thread'; fi
6457
- if [ "$BUILD_TYPE" = "ubsan" ]; then export export CFLAGS='-fsanitize=undefined'; export CXXLAGS='-fsanitize=undefined'; export LDFLAGS='-fsanitize=undefined'; fi
6558
install:
66-
- $buildshell ./bootstrap
59+
- ./bootstrap
6760
- mkdir build
6861
- cd build
69-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export MANIFEST_TOOL='no'; fi
70-
- if [ "$LINKING" = "static" ]; then
71-
$buildshell ../configure --enable-static --disable-fastopen;
62+
- |
63+
if [ "$LINKING" = "static" ]; then
64+
../configure --enable-static --disable-fastopen;
7265
elif [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ]; then
73-
$buildshell ../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
66+
../configure --enable-debug --enable-coverage --disable-shared --disable-fastopen;
7467
elif [ "$DEBUG" = "debug" ]; then
75-
$buildshell ../configure --enable-debug --disable-shared --disable-fastopen;
68+
../configure --enable-debug --disable-shared --disable-fastopen;
7669
elif [ "$VALGRIND" = "valgrind" ]; then
77-
$buildshell ../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck;
70+
../configure --enable-debug --disable-fastopen --disable-valgrind-helgrind --disable-valgrind-drd --disable-valgrind-sgcheck;
71+
elif [ "$IWYU" = "iwyu" ]; then
72+
../configure --disable-examples;
7873
else
79-
$buildshell ../configure --disable-fastopen;
74+
../configure --disable-fastopen;
75+
fi
76+
# Make or run iwyu. If running iwyu, check for the result code to be 2 (IWYU always returns an error code, if it is 2, no corrections are necessary).
77+
- |
78+
if [ "$IWYU" = "iwyu" ]; then
79+
make -k CXX='/usr/local/bin/include-what-you-use -Xiwyu --mapping_file=${top_builddir}/../custom_iwyu.imp' CXXFLAGS="-isystem ${CLANG_PREFIX_PATH}/include -std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT $CXXFLAGS" ;
80+
if [ $? -ne 2 ]; then
81+
return 1;
82+
fi
83+
else
84+
make;
8085
fi
81-
- $buildshell make
8286
script:
83-
- $buildshell make check
84-
- $buildshell cat test/test-suite.log
87+
- if [ "$IWYU" != "iwyu" ]; then make check; cat test/test-suite.log; fi
8588
- if [ "$VALGRIND" = "valgrind" ]; then make check-valgrind; fi;
8689
- if [ "$VALGRIND" = "valgrind" ]; then cat test/test-suite-memcheck.log; fi;
8790
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ../src/; cppcheck --error-exitcode=1 .; cd ../build; fi
@@ -103,8 +106,6 @@ script:
103106
./benchmark_threads 8080 &
104107
sleep 5 && ab -n 10000000 -c 100 localhost:8080/plaintext
105108
fi
106-
after_script:
107-
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then taskkill //F //PID $(ps -Wla | tr -s ' ' | grep gpg | cut -f2 -d' ') ; fi
108109
after_success:
109110
- if [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then bash <(curl -s https://codecov.io/bash); fi
110111
matrix:
@@ -341,3 +342,17 @@ matrix:
341342
- clang-9
342343
env:
343344
- MATRIX_EVAL="CC=clang-9 && CXX=clang++-9"
345+
- os: linux
346+
compiler: clang
347+
addons:
348+
apt:
349+
sources:
350+
- llvm-toolchain-xenial-7
351+
- ubuntu-toolchain-r-test
352+
packages:
353+
- iwyu
354+
- cmake
355+
- llvm-dev
356+
- libclang-dev
357+
env:
358+
- MATRIX_EVAL="IWYU=iwyu"

ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Sat Nov 21 07:20:00 2020 -0800
2+
Added support on build for CodeQL security checks.
3+
Moved builds to travis.com
4+
Added IWYU checks as part of build and cleaned-up accordingly.
5+
Introduced dual-stack support.
6+
Added OS specific tips, and cleaned up some compiler warnings.
7+
Updates to readme and documentation.
8+
Slight performances improvement by allowing to skip a copy in
9+
string_response constructor.
10+
Moved windows builds to AppVeyor.
11+
Made the library compatible with libmicrohttpd v0.9.71 and above.
12+
113
Sat Jun 6 10:21:05 2020 -0800
214
Prevent use of regex in http_endpoint outside of registration which could
315
allow DOS attacks.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Copyright (C) 2011-2019 Sebastiano Merlino.
1010

1111
# The libhttpserver reference manual
1212

13-
[![Build Status](https://travis-ci.org/etr/libhttpserver.png?branch=master)](https://travis-ci.org/etr/libhttpserver)
13+
[![Build Status](https://api.travis-ci.com/etr/libhttpserver.svg?branch=master)](https://travis-ci.com/etr/libhttpserver)
1414
[![Build status](https://ci.appveyor.com/api/projects/status/ktoy6ewkrf0q1hw6/branch/master?svg=true)](https://ci.appveyor.com/project/etr/libhttpserver/branch/master)
1515
[![codecov](https://codecov.io/gh/etr/libhttpserver/branch/master/graph/badge.svg)](https://codecov.io/gh/etr/libhttpserver)
1616
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5fa4bdc3815b4c10977f3badefedecd6)](https://www.codacy.com/app/etr/libhttpserver?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=etr/libhttpserver&amp;utm_campaign=Badge_Grade)
@@ -188,6 +188,7 @@ For example, if your connection limit is “1”, a browser may open a first con
188188
* _.bind_socket(**int** socket_fd):_ Listen socket to use. Pass a listen socket for the daemon to use (systemd-style). If this option is used, the daemon will not open its own listen socket(s). The argument passed must be of type "int" and refer to an existing socket that has been bound to a port and is listening.
189189
* _.max_thread_stack_size(**int** stack_size):_ Maximum stack size for threads created by the library. Not specifying this option or using a value of zero means using the system default (which is likely to differ based on your platform). Default is `0 (system default)`.
190190
* _.use_ipv6() and .no_ipv6():_ Enable or disable the IPv6 protocol support (by default, libhttpserver will just support IPv4). If you specify this and the local platform does not support it, starting up the server will throw an exception. `off` by default.
191+
* _.use_dual_stack() and .no_dual_stack():_ Enable or disable the support for both IPv6 and IPv4 protocols at the same time (by default, libhttpserver will just support IPv4). If you specify this and the local platform does not support it, starting up the server will throw an exception. Note that this will mean that IPv4 addresses are returned in the IPv6-mapped format (the ’structsockaddrin6’ format will be used for IPv4 and IPv6). `off` by default.
191192
* _.pedantic() and .no_pedantic():_ Enables pedantic checks about the protocol (as opposed to as tolerant as possible). Specifically, at the moment, this flag causes the library to reject HTTP 1.1 connections without a `Host` header. This is required by the standard, but of course in violation of the “be as liberal as possible in what you accept” norm. It is recommended to turn this **off** if you are testing clients against the library, and **on** in production. `off` by default.
192193
* _.debug() and .no_debug():_ Enables debug messages from the library. `off` by default.
193194
* _.regex_checking() and .no_regex_checking():_ Enables pattern matching for endpoints. Read more [here](#registering-resources). `on` by default.

appveyor.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
platform: x64
22

3-
branches:
4-
except:
5-
- /.*travis.*/
6-
skip_commits:
7-
message: /travis/
8-
files:
9-
- .travis.yml
10-
113
environment:
124
matrix:
135
- compiler: msys2
146
MINGW_CHOST: x86_64-w64-mingw32
157
MSYS2_ARCH: x86_64
8+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
169
init:
1710
- 'echo Building libhttpserver %version% for Windows'
1811
- 'echo System architecture: %PLATFORM%'
1912
- 'echo Repo build branch is: %APPVEYOR_REPO_BRANCH%'
2013
- 'echo Build folder is: %APPVEYOR_BUILD_FOLDER%'
2114
- 'echo Repo build commit is: %APPVEYOR_REPO_COMMIT%'
2215
- 'echo Cygwin root is: %CYG_ROOT%'
16+
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
2317
install:
24-
- 'if "%compiler%"=="msys2" C:\msys64\msys2_shell.cmd -defterm -no-start -msys2 -c "pacman --noconfirm --force -S --needed mingw-w64-$MSYS2_ARCH-{libtool,make,pkg-config,libsystre,doxygen,gnutls,graphviz,curl}"'
18+
- 'if "%compiler%"=="msys2" C:\msys64\msys2_shell.cmd -defterm -no-start -msys2 -c "pacman --noconfirm -S --needed mingw-w64-$MSYS2_ARCH-{libtool,make,pkg-config,libsystre,doxygen,gnutls,graphviz,curl}"'
2519
- 'if "%compiler%"=="msys2" C:\msys64\msys2_shell.cmd -defterm -no-start -mingw64 -full-path -here -c "cd $APPVEYOR_BUILD_FOLDER && curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-0.9.59.tar.gz -o libmicrohttpd-0.9.59.tar.gz"'
2620
- 'if "%compiler%"=="msys2" C:\msys64\msys2_shell.cmd -defterm -no-start -mingw64 -full-path -here -c "cd $APPVEYOR_BUILD_FOLDER && tar -xzf libmicrohttpd-0.9.59.tar.gz"'
2721
- 'if "%compiler%"=="msys2" C:\msys64\msys2_shell.cmd -defterm -no-start -mingw64 -full-path -here -c "cd $APPVEYOR_BUILD_FOLDER/libmicrohttpd-0.9.59 && ./configure --disable-examples --enable-poll=no --prefix /C/msys64 && make && make install"'

custom_iwyu.imp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{ include: ["\"microhttpd.h\"", "private", "<microhttpd.h>", "public"] },
3+
{ include: ["<ext/alloc_traits.h>", "private", "<memory>", "public"] },
4+
5+
{ symbol: ["std::exception", "private", "<exception>", "public"]},
6+
{ symbol: ["std::shared_ptr", "private", "<memory>", "public"]},
7+
{ symbol: ["std::uint16_t", "private", "<cstdint>", "public"]},
8+
{ symbol: ["std::uint64_t", "private", "<cstdint>", "public"]},
9+
{ symbol: ["std::istringstream", "private", "<sstream>", "public"]},
10+
{ symbol: ["std::stringstream", "private", "<sstream>", "public"]},
11+
{ symbol: ["std::ifstream", "private", "<fstream>", "public"]},
12+
13+
{ symbol: ["uint16_t", "private", "<stdint.h>", "public"]},
14+
{ symbol: ["uint64_t", "private", "<stdint.h>", "public"]},
15+
16+
{ symbol: ["MHD_Connection", "private", "<microhttpd.h>", "public"]},
17+
]

src/basic_auth_fail_response.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
#include "httpserver/basic_auth_fail_response.hpp"
22+
#include <microhttpd.h>
23+
24+
struct MHD_Connection;
25+
struct MHD_Response;
2226

2327
using namespace std;
2428

src/deferred_response.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
*/
2020

2121
#include "httpserver/deferred_response.hpp"
22+
#include <microhttpd.h>
23+
24+
struct MHD_Response;
2225

2326
using namespace std;
2427

src/details/http_endpoint.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
USA
1919
*/
2020

21+
#include <ctype.h>
22+
#include <map>
23+
#include <memory>
24+
#include <regex>
25+
#include <sstream>
2126
#include <stdexcept>
27+
#include <string>
28+
#include <utility>
29+
#include <vector>
2230

2331
#include "httpserver/details/http_endpoint.hpp"
24-
2532
#include "httpserver/http_utils.hpp"
26-
#include "httpserver/string_utilities.hpp"
2733

2834
using namespace std;
2935

src/digest_auth_fail_response.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
#include "httpserver/digest_auth_fail_response.hpp"
22+
#include <microhttpd.h>
23+
24+
struct MHD_Connection;
25+
struct MHD_Response;
2226

2327
using namespace std;
2428

0 commit comments

Comments
 (0)