"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/utils/js_identifier_ctx.h" between
snort3-3.1.29.0.tar.gz and snort3-3.1.30.0.tar.gz

About: Snort 3 is a network intrusion prevention and detection system (IDS/IPS) combining the benefits of signature, protocol and anomaly-based inspection.

js_identifier_ctx.h  (snort3-3.1.29.0):js_identifier_ctx.h  (snort3-3.1.30.0)
skipping to change at line 42 skipping to change at line 42
FUNCTION, // function declaration FUNCTION, // function declaration
BLOCK, // block of code and object declaration BLOCK, // block of code and object declaration
PROG_SCOPE_TYPE_MAX PROG_SCOPE_TYPE_MAX
}; };
class JSIdentifierCtxBase class JSIdentifierCtxBase
{ {
public: public:
virtual ~JSIdentifierCtxBase() = default; virtual ~JSIdentifierCtxBase() = default;
virtual const char* substitute(const char* identifier) = 0; virtual const char* substitute(const char* identifier, bool is_property) = 0 ;
virtual void add_alias(const char* alias, const std::string&& value) = 0; virtual void add_alias(const char* alias, const std::string&& value) = 0;
virtual const char* alias_lookup(const char* alias) const = 0; virtual const char* alias_lookup(const char* alias) const = 0;
virtual bool is_ignored(const char* identifier) const = 0; virtual bool is_ignored(const char* identifier) const = 0;
virtual bool scope_push(JSProgramScopeType) = 0; virtual bool scope_push(JSProgramScopeType) = 0;
virtual bool scope_pop(JSProgramScopeType) = 0; virtual bool scope_pop(JSProgramScopeType) = 0;
virtual void reset() = 0; virtual void reset() = 0;
virtual size_t size() const = 0; virtual size_t size() const = 0;
}; };
class JSIdentifierCtx : public JSIdentifierCtxBase class JSIdentifierCtx : public JSIdentifierCtxBase
{ {
public: public:
JSIdentifierCtx(int32_t depth, uint32_t max_scope_depth, JSIdentifierCtx(int32_t depth, uint32_t max_scope_depth,
const std::unordered_set<std::string>& ignore_list); const std::unordered_set<std::string>& ignored_ids_list,
const std::unordered_set<std::string>& ignored_props_list);
virtual const char* substitute(const char* identifier) override; virtual const char* substitute(const char* identifier, bool is_property) ove rride;
virtual void add_alias(const char* alias, const std::string&& value) overrid e; virtual void add_alias(const char* alias, const std::string&& value) overrid e;
virtual const char* alias_lookup(const char* alias) const override; virtual const char* alias_lookup(const char* alias) const override;
virtual bool is_ignored(const char* identifier) const override; virtual bool is_ignored(const char* identifier) const override;
virtual bool scope_push(JSProgramScopeType) override; virtual bool scope_push(JSProgramScopeType) override;
virtual bool scope_pop(JSProgramScopeType) override; virtual bool scope_pop(JSProgramScopeType) override;
virtual void reset() override; virtual void reset() override;
// approximated to 500 unique mappings insertions // approximated to 500 unique mappings insertions
// approximated to 3 program scopes in the list // approximated to 3 program scopes in the list
virtual size_t size() const override virtual size_t size() const override
{ return (sizeof(JSIdentifierCtx) + (sizeof(std::string) * 2 * 500) + { return (sizeof(JSIdentifierCtx) + (sizeof(std::string) * 2 * 500) +
(sizeof(ProgramScope) * 3)); } (sizeof(ProgramScope) * 3)); }
private: private:
struct NormId
{
const char* id_name = nullptr;
const char* prop_name = nullptr;
uint8_t type = 0;
};
using Alias = std::vector<std::string>; using Alias = std::vector<std::string>;
using AliasRef = std::list<Alias*>; using AliasRef = std::list<Alias*>;
using AliasMap = std::unordered_map<std::string, Alias>; using AliasMap = std::unordered_map<std::string, Alias>;
using NameMap = std::unordered_map<std::string, const char*>; using NameMap = std::unordered_map<std::string, NormId>;
class ProgramScope class ProgramScope
{ {
public: public:
ProgramScope(JSProgramScopeType t) : t(t) ProgramScope(JSProgramScopeType t) : t(t)
{} {}
~ProgramScope() ~ProgramScope()
{ for (auto a : to_remove) a->pop_back(); } { for (auto a : to_remove) a->pop_back(); }
skipping to change at line 103 skipping to change at line 112
{ to_remove.push_back(&a); } { to_remove.push_back(&a); }
JSProgramScopeType type() const JSProgramScopeType type() const
{ return t; } { return t; }
private: private:
JSProgramScopeType t; JSProgramScopeType t;
AliasRef to_remove{}; AliasRef to_remove{};
}; };
inline const char* substitute(unsigned char c); inline const char* substitute(unsigned char c, bool is_property);
inline bool is_substituted(const NormId& id, bool is_property);
inline const char* acquire_norm_name(NormId& id);
inline void init_ignored_names();
// do not swap next two lines, the destructor frees them in the reverse orde r // do not swap next two lines, the destructor frees them in the reverse orde r
AliasMap aliases; AliasMap aliases;
std::list<ProgramScope> scopes; std::list<ProgramScope> scopes;
const char* id_fast[256]; NormId id_fast[256];
NameMap id_names; NameMap id_names;
const std::unordered_set<std::string>& ignore_list; const std::unordered_set<std::string>& ignored_ids_list;
const std::unordered_set<std::string>& ignored_props_list;
const char* norm_name; const char* norm_name;
const char* norm_name_end; const char* norm_name_end;
uint32_t max_scope_depth; uint32_t max_scope_depth;
// advanced program scope access for testing // advanced program scope access for testing
#if defined(CATCH_TEST_BUILD) || defined(BENCHMARK_TEST) #if defined(CATCH_TEST_BUILD) || defined(BENCHMARK_TEST)
public: public:
// compare scope list with the passed pattern // compare scope list with the passed pattern
bool scope_check(const std::list<JSProgramScopeType>& compare) const; bool scope_check(const std::list<JSProgramScopeType>& compare) const;
 End of changes. 8 change blocks. 
7 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)