add_subdirectory(keyword_states)
add_subdirectory(preprocessor_states)
add_subdirectory(output_states)
+add_subdirectory(config_states)
add_executable(snort2lua
snort2lua.cc
--- /dev/null
+
+
+add_library( config_states
+ config_options.cc
+ config_api.h
+ config_api.cc
+)
--- /dev/null
+/*
+** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+ * Copyright (C) 2002-2013 Sourcefire, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation. You may not use, modify or
+ * distribute this program under any other version of the GNU General
+ * Public License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+// config_api.cc author Josh Rosenbaum <jorosenba@cisco.com>
+
+#include "config_states/config_api.h"
+
+
+extern const ConvertMap *autogenerate_decode_rules_map;
+extern const ConvertMap *paf_max_map;
+
+
+const std::vector<const ConvertMap*> config_api =
+{
+ autogenerate_decode_rules_map,
+ paf_max_map,
+};
--- /dev/null
+/*
+** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+ * Copyright (C) 2002-2013 Sourcefire, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation. You may not use, modify or
+ * distribute this program under any other version of the GNU General
+ * Public License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+// config_api.h author Josh Rosenbaum <jorosenba@cisco.com>
+
+#ifndef CONFIG_API_H
+#define CONFIG_API_H
+
+#include <vector>
+#include "../conversion_state.h"
+
+extern const std::vector<const ConvertMap*> config_api;
+
+#endif
--- /dev/null
+/*
+** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+ * Copyright (C) 2002-2013 Sourcefire, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation. You may not use, modify or
+ * distribute this program under any other version of the GNU General
+ * Public License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+// config_options.cc author Josh Rosenbaum <jorosenba@cisco.com>
+
+#include <sstream>
+#include <vector>
+
+#include "conversion_state.h"
+#include "converter.h"
+#include "snort2lua_util.h"
+
+
+
+static inline bool open_table_add_option(Converter* cv,
+ std::string table_name,
+ std::string opt_name,
+ bool val)
+{
+ bool tmpval = cv->open_table(table_name);
+ tmpval = cv->add_option_to_table(opt_name, val) && tmpval;
+ cv->close_table();
+ return tmpval;
+}
+
+/*********************************************
+ ************ config paf_max ****************
+ *********************************************/
+
+namespace {
+
+class PafMax : public ConversionState
+{
+public:
+ PafMax(Converter* cv) : ConversionState(cv) {};
+ virtual ~PafMax() {};
+ virtual bool convert(std::stringstream& data_stream);
+};
+
+} // namespace
+
+
+bool PafMax::convert(std::stringstream& data_stream)
+{
+ converter->open_table("stream_tcp");
+ bool retval = parse_int_option("paf_max", data_stream);
+ converter->close_table();
+ return retval;
+}
+
+/******* A P I ***********/
+
+static ConversionState* paf_max_ctor(Converter* cv)
+{
+ return new PafMax(cv);
+}
+
+static const ConvertMap config_paf_max =
+{
+ "paf_max",
+ paf_max_ctor,
+};
+
+
+const ConvertMap* paf_max_map = &config_paf_max;
+
+
+/*********************************************
+ ******* Autogenerate Decoder Rules *********
+ *********************************************/
+
+static ConversionState* autogenerate_preprocessor_decoder_rules_ctor(Converter* cv)
+{
+ open_table_add_option(cv, "ips", "enable_builtin_rules", true);
+ return nullptr;
+}
+
+static const ConvertMap config_autogenerate_decode_rules =
+{
+ "autogenerate_preprocessor_decoder_rules",
+ autogenerate_preprocessor_decoder_rules_ctor,
+};
+
+const ConvertMap* autogenerate_decode_rules_map = &config_autogenerate_decode_rules;
return converter->add_option_to_table("--" + list_name, tmp );
}
- inline bool pen_table_add_option(std::string table_name, std::string opt_name, std::string val)
+ inline bool open_table_add_option(std::string table_name, std::string opt_name, std::string val)
{
bool tmpval = converter->open_table(table_name);
tmpval = converter->add_option_to_table(opt_name, val) && tmpval;
target_link_libraries( keyword_states
output_states
preprocessor_states
+ config_states
)
\ No newline at end of file
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-// config.cc author Josh Rosenbaum <jorosenba@cisco.com>
+// kws_config.cc author Josh Rosenbaum <jorosenba@cisco.com>
#include <sstream>
#include <vector>
#include "conversion_state.h"
#include "converter.h"
+#include "config_states/config_api.h"
#include "snort2lua_util.h"
bool Config::convert(std::stringstream& data_stream)
{
-#if 0
std::string keyword;
- if(data >> keyword)
+ if(data_stream >> keyword)
{
- const ConvertMap* map = util::find_map(output_api, keyword);
+
+ if(keyword.back() == ':')
+ keyword.pop_back();
+
+ const ConvertMap* map = util::find_map(config_api, keyword);
if (map)
{
converter->set_state(map->ctor(converter));
}
}
- return false;
-#endif
-
return false;
}
std::string keyword;
converter->open_table("suppress");
+ converter->add_deprecated_comment("gen_id", "gid");
+ converter->add_deprecated_comment("sig_id", "sid");
converter->open_table();
while(data_stream >> keyword)
tmpval = parse_string_option("ip", data_stream);
else if(!keyword.compare("gen_id"))
- {
- converter->add_deprecated_comment("gen_id", "gid");
tmpval = parse_int_option("gid", data_stream);
- }
else if (!keyword.compare("sig_id"))
- {
- converter->add_deprecated_comment("sig_id", "sid");
tmpval = parse_int_option("sid", data_stream);
- }
+
+ else
+ tmpval = false;
if (retval)
retval = tmpval;
else if(!keyword.compare("check_session_hijacking"))
converter->add_deprecated_comment("check_session_hijacking");
+ else if(!keyword.compare("bind_to"))
+ {
+ converter->add_deprecated_comment("bind_to", "bindings");
+ if(!(data_stream >> keyword))
+ tmpval = false;
+ }
+
else if(!keyword.compare("dont_reassemble_async"))
{
converter->add_deprecated_comment("dont_reassemble_async", "reassemble_async");
return retval;
}
-#if 0
-
-# bind_to <ip_addr> - IP address for this policy. The default is set
-
- ports <client|server|both> [all|space separated port list]
-]
-#endif
/**************************
******* A P I ***********