Merge branch '2.3' into 2.4
This commit is contained in:
commit
c480a44852
@ -84,6 +84,9 @@ void run(TestConnections& test)
|
||||
// This should NOT go through as a function is used with a masked column.
|
||||
test_one(test, "SELECT LENGTH(a), b FROM masking_auto_firewall", Expect::FAILURE);
|
||||
|
||||
// This should NOT go through as a function is used with a masked column (that happens to be uppercase).
|
||||
test_one(test, "SELECT LENGTH(A), b FROM masking_auto_firewall", Expect::FAILURE);
|
||||
|
||||
// This SHOULD go through as a function is NOT used with a masked column
|
||||
// in a prepared statement.
|
||||
test_one(test, "PREPARE ps1 FROM 'SELECT a, LENGTH(b) FROM masking_auto_firewall'", Expect::SUCCESS);
|
||||
|
@ -430,6 +430,17 @@ bool create_rules_from_root(json_t* pRoot,
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
inline bool is_same_name(const std::string& s, const char* zS)
|
||||
{
|
||||
return strcasecmp(s.c_str(), zS) == 0;
|
||||
}
|
||||
|
||||
inline bool is_same_name(const std::string& lhs, const LEncString& rhs)
|
||||
{
|
||||
return rhs.case_eq(lhs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@ -1063,9 +1074,9 @@ bool MaskingRules::Rule::matches(const ComQueryResponse::ColumnDef& column_def,
|
||||
// Otherwise it would be easy to bypass a table/database rule.
|
||||
|
||||
bool match =
|
||||
(m_column == column_def.org_name())
|
||||
&& (m_table.empty() || table.empty() || (m_table == table))
|
||||
&& (m_database.empty() || database.empty() || (m_database == database));
|
||||
is_same_name(m_column, column_def.org_name())
|
||||
&& (m_table.empty() || table.empty() || is_same_name(m_table, table))
|
||||
&& (m_database.empty() || database.empty() || is_same_name(m_database, database));
|
||||
|
||||
if (match)
|
||||
{
|
||||
@ -1094,9 +1105,9 @@ bool MaskingRules::Rule::matches(const QC_FIELD_INFO& field,
|
||||
// Otherwise it would be easy to bypass a table/database rule.
|
||||
|
||||
bool match =
|
||||
(m_column == zColumn)
|
||||
&& (m_table.empty() || !zTable || (m_table == zTable))
|
||||
&& (m_database.empty() || !zDatabase || (m_database == zDatabase));
|
||||
is_same_name(m_column, zColumn)
|
||||
&& (m_table.empty() || !zTable || is_same_name(m_table, zTable))
|
||||
&& (m_database.empty() || !zDatabase || is_same_name(m_database, zDatabase));
|
||||
|
||||
if (match)
|
||||
{
|
||||
|
@ -294,7 +294,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare for equality.
|
||||
* Compare for equality in a case-sensitive fashion.
|
||||
*
|
||||
* @param s The string to compare with.
|
||||
*
|
||||
@ -306,7 +306,19 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare for equality.
|
||||
* Compare for equality in case-insensitive fashion.
|
||||
*
|
||||
* @param s The string to compare with.
|
||||
*
|
||||
* @return True, if the strings are equal.
|
||||
*/
|
||||
bool case_eq(const LEncString& s) const
|
||||
{
|
||||
return m_length == s.m_length ? (strncasecmp(m_pString, s.m_pString, m_length) == 0) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare for equality in a case-sensitive fashion
|
||||
*
|
||||
* @param s The string to compare with.
|
||||
*
|
||||
@ -320,7 +332,21 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare for equality.
|
||||
* Compare for equality in a case-insensitive fashion.
|
||||
*
|
||||
* @param s The string to compare with.
|
||||
*
|
||||
* @return True, if the strings are equal.
|
||||
*/
|
||||
bool case_eq(const char* zString) const
|
||||
{
|
||||
size_t length = strlen(zString);
|
||||
|
||||
return m_length == length ? (strncasecmp(m_pString, zString, m_length) == 0) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare for equality in a case-sensitive fashion
|
||||
*
|
||||
* @param s The string to compare with.
|
||||
*
|
||||
@ -331,6 +357,18 @@ public:
|
||||
return m_length == s.length() ? (memcmp(m_pString, s.data(), m_length) == 0) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare for equality in a case-insensitive fashion
|
||||
*
|
||||
* @param s The string to compare with.
|
||||
*
|
||||
* @return True, if the strings are equal.
|
||||
*/
|
||||
bool case_eq(const std::string& s) const
|
||||
{
|
||||
return m_length == s.length() ? (strncasecmp(m_pString, s.data(), m_length) == 0) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a @c LEncString to the equivalent @c std::string.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user