Skip to content

V3/remove this throw call transaction h #3104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: build.sh
run: ./build.sh
- name: configure ${{ matrix.configure.label }}
run: ./configure ${{ matrix.configure.opt }}
run: ./configure ${{ matrix.configure.opt }} --enable-assertions=yes
- uses: ammaraskar/gcc-problem-matcher@master
- name: make
run: make -j `nproc`
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- name: build.sh
run: ./build.sh
- name: configure ${{ matrix.configure.label }}
run: ./configure ${{ matrix.configure.opt }}
run: ./configure ${{ matrix.configure.opt }} --enable-assertions=yes
- uses: ammaraskar/gcc-problem-matcher@master
- name: make
run: make -j `sysctl -n hw.logicalcpu`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ CFLAGS to disable the compilation optimization parameters:
```shell
$ export CFLAGS="-g -O0"
$ ./build.sh
$ ./configure
$ ./configure --enable-assertions=yes
$ make
$ sudo make install
```
Expand Down
27 changes: 27 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,19 @@ MSC_GIT_VERSION=msc_version_git
AC_SUBST([MSC_GIT_VERSION])



AC_ARG_ENABLE(assertions,
[AS_HELP_STRING([--enable-assertions],[Turn on assertions feature: undefine NDEBUG])],

[case "${enableval}" in
yes) assertions=true ;;
no) assertions=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-asserions) ;;
esac],

[assertions=false]
)

AC_ARG_ENABLE(debug-logs,
[AS_HELP_STRING([--disable-debug-logs],[Turn off the SecDebugLog feature])],

Expand Down Expand Up @@ -355,6 +368,12 @@ if test "$aflFuzzer" == "true"; then
GLOBAL_CPPFLAGS="$GLOBAL_CPPFLAGS $FUZZ_CPPCFLAGS"
$buildExamples = false
fi

if test "$assertions" == "false"; then
ASSERTIONS_CPPCFLAGS="-DNDEBUG"
GLOBAL_CPPFLAGS="$GLOBAL_CPPFLAGS $ASSERTIONS_CPPCFLAGS"
fi

AC_SUBST(GLOBAL_LDADD)
AC_SUBST(GLOBAL_CPPFLAGS)

Expand Down Expand Up @@ -589,6 +608,14 @@ if test $buildTestUtilities = true; then
else
echo " + Test Utilities ....disabled"
fi


if test $assertions = true; then
echo " + Assertions ....enabled"
else
echo " + Assertions ....disabled"
fi

if test $debugLogs = true; then
echo " + SecDebugLog ....enabled"
else
Expand Down
10 changes: 4 additions & 6 deletions headers/modsecurity/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#ifdef __cplusplus
#include <cassert>
#include <ctime>
#include <fstream>
#include <iomanip>
Expand Down Expand Up @@ -307,11 +308,8 @@ class TransactionSecMarkerManagement {
}

std::shared_ptr<std::string> getCurrentMarker() const {
if (m_marker) {
return m_marker;
} else {
throw;
}
assert((m_marker != nullptr) && "You might have forgotten to call and evaluate isInsideAMarker() before calling getCurrentMarker().");
return m_marker;
}

void removeMarker() {
Expand All @@ -323,7 +321,7 @@ class TransactionSecMarkerManagement {
}

private:
std::shared_ptr<std::string> m_marker;
std::shared_ptr<std::string> m_marker = nullptr;
};

/** @ingroup ModSecurity_CPP_API */
Expand Down
5 changes: 2 additions & 3 deletions src/rule_with_actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <stdio.h>

#include <cassert>
#include <algorithm>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -121,10 +122,8 @@ RuleWithActions::RuleWithActions(
m_actionsRuntimePos.push_back(a);
}
} else {
assert(false && "The handling of RunTimeBeforeMatchAttemptKind has not been implemented yet.");
delete a;
std::cout << "General failure, action: " << a->m_name;
std::cout << " has an unknown type." << std::endl;
throw;
}
}
delete actions;
Expand Down
4 changes: 1 addition & 3 deletions test/cppcheck_suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ noConstructor:src/variables/variable.h:152
danglingTempReference:src/modsecurity.cc:206
knownConditionTrueFalse:src/operators/validate_url_encoding.cc:77
knownConditionTrueFalse:src/operators/verify_svnr.cc:87
rethrowNoCurrentException:headers/modsecurity/transaction.h:313
rethrowNoCurrentException:src/rule_with_actions.cc:127
ctunullpointer:src/rule_with_actions.cc:244
ctunullpointer:src/rule_with_actions.cc:243
ctunullpointer:src/rule_with_operator.cc:135
ctunullpointer:src/rule_with_operator.cc:95
passedByValue:test/common/modsecurity_test.cc:49
Expand Down