使用正則不允許對整表進行操作

mhabbyo發表於2017-02-06
-- 禁止應用檢視錶結構
delete from mysql_query_rules where rule_id=10006;
INSERT INTO mysql_query_rules (rule_id, active,username,schemaname, match_pattern, error_msg,destination_hostgroup, apply) 
VALUES (10006,1,'yrzif_test2','yrzif_test2','^desc\s*\S*','desc is not allowed',2,1);
LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;




-- 禁止應用對information_schema進行查詢
delete from mysql_query_rules where rule_id=10007;
INSERT INTO mysql_query_rules (rule_id, active,username,schemaname, match_pattern, error_msg,destination_hostgroup, apply) 
VALUES (10007,1,'yrzif_test2','yrzif_test2','\s*\S*information_schema\s*\S*','query on information_schema is not allowed',2,1);
LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;




-- 禁止對整表進行不加條件的查詢
delete from mysql_query_rules where rule_id=10001;
INSERT INTO mysql_query_rules (rule_id, active,username,schemaname, match_pattern, error_msg,destination_hostgroup, apply) 
VALUES (10001,1,'yrzif_test2','yrzif_test2','^SELECT\s*\*\s*from\s*fi_user_bak$','Query not allowed',2,1);
LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;




-- 禁止對整表進行不加條件的刪除
delete from mysql_query_rules where rule_id=1002;
INSERT INTO mysql_query_rules (rule_id, active, username,schemaname,match_pattern, error_msg, apply) VALUES (1002,1,'yrzif_test2','yrzif_test2','^DELETE\s*from\s*fi_user_bak$','Query not allowed',1);
LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;




-- 禁止對整表進行不加條件的更新
delete  from mysql_query_rules where rule_id=1003;
delete  from mysql_query_rules where rule_id=1004;
delete  from mysql_query_rules where rule_id=1005;
  
INSERT INTO mysql_query_rules (rule_id, active,username,schemaname, match_digest, flagOUT, apply) VALUES (1003,1,'yrzif_test2','yrzif_test2','^update\s*fi_user_bak', 100, 0);
INSERT INTO mysql_query_rules (rule_id, active,username,schemaname, flagIN, match_digest, destination_hostgroup, apply) VALUES (1004,1,'yrzif_test2','yrzif_test2', 100, 'WHERE', 9, 1);
INSERT INTO mysql_query_rules (rule_id, active,username,schemaname, flagIN, error_msg, apply) VALUES (1005,1, 'yrzif_test2','yrzif_test2',100, 'Query not allowed', 1);
LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29291882/viewspace-2133103/,如需轉載,請註明出處,否則將追究法律責任。

相關文章