)]}'
{"oslo_policy/policy.py":[{"author":{"_account_id":9796,"name":"ChangBo Guo","email":"glongwave@gmail.com","username":"gcb"},"change_message_id":"b6aeba3f7b1d60bbf07f22ac0aab2da9987afd1e","unresolved":false,"context_lines":[{"line_number":550,"context_line":"                if default.name not in self.rules:"},{"line_number":551,"context_line":"                    self.rules[default.name] \u003d default.check"},{"line_number":552,"context_line":""},{"line_number":553,"context_line":"            if self.conf.oslo_policy.syntax_checks:"},{"line_number":554,"context_line":"                # Detect and log obvious incorrect rule definitions"},{"line_number":555,"context_line":"                self.check_rules()"},{"line_number":556,"context_line":""},{"line_number":557,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"},{"line_number":558,"context_line":"        \"\"\"Look for rule definitions that are obviously incorrect.\"\"\""}],"source_content_type":"text/x-python","patch_set":2,"id":"3f4b6375_5b7e84af","line":555,"range":{"start_line":553,"start_character":0,"end_line":555,"end_character":34},"updated":"2017-10-24 05:41:42.000000000","message":"skipping the syntax checks is not a good solution to decrease delay. we should find a way to avoid redundant check. Maybe use a variable to record when we need check rule .What about the following changes:\n\n[changboguo@localhost oslo.policy]$ git diff\ndiff --git a/oslo_policy/policy.py b/oslo_policy/policy.py\nindex 1736e98..95bafc1 100644\n--- a/oslo_policy/policy.py\n+++ b/oslo_policy/policy.py\n@@ -471,6 +471,7 @@ class Enforcer(object):\n \n         self.policy_file \u003d policy_file or self.conf.oslo_policy.policy_file\n         self.use_conf \u003d use_conf\n+        self._need_check_rule \u003d True\n         self.overwrite \u003d overwrite\n         self._loaded_files \u003d []\n         self._policy_dir_mtimes \u003d {}\n@@ -490,6 +491,7 @@ class Enforcer(object):\n             raise TypeError(_(\u0027Rules must be an instance of dict or Rules, \u0027\n                             \u0027got %s instead\u0027) % type(rules))\n         self.use_conf \u003d use_conf\n+        self._need_check_rule \u003d True\n         if overwrite:\n             self.rules \u003d Rules(rules, self.default_rule)\n         else:\n@@ -551,7 +553,9 @@ class Enforcer(object):\n                     self.rules[default.name] \u003d default.check\n \n             # Detect and log obvious incorrect rule definitions\n-            self.check_rules()\n+            if self._need_check_rule:\n+                self._need_check_rule \u003d False\n+                self.check_rules()\n \n     def check_rules(self, raise_on_violation\u003dFalse):\n         \"\"\"Look for rule definitions that are obviously incorrect.\"\"\"","commit_id":"87d2211e095a57643111be64e4b5631532306cb7"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"397022317b7f19849706b05a2b93e0100e7ff2fd","unresolved":false,"context_lines":[{"line_number":554,"context_line":""},{"line_number":555,"context_line":"            # Detect and log obvious incorrect rule definitions"},{"line_number":556,"context_line":"            if self._need_check_rule:"},{"line_number":557,"context_line":"                self._need_check_rule \u003d False"},{"line_number":558,"context_line":"                self.check_rules()"},{"line_number":559,"context_line":""},{"line_number":560,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":3,"id":"1f485f77_433e072a","line":557,"updated":"2017-11-10 19:10:48.000000000","message":"I\u0027m worried that always setting this value to false here means that we won\u0027t ever recheck the rules on a reload. Do we need this flag to be an instance variable? Can we use a local variable in this method to keep track of whether any work was done (either by loading a file or modifying a default rule) and then test that variable before calling check_rules()?","commit_id":"e7274b61139342d04750d7ffb4ecd217a1fb1070"},{"author":{"_account_id":9312,"name":"Alexandre Levine","email":"alexandrelevine@gmail.com","username":"alevine"},"change_message_id":"20b0f997d6dbe396f4a2d78eaa52c8b81e49b8e7","unresolved":false,"context_lines":[{"line_number":554,"context_line":""},{"line_number":555,"context_line":"            # Detect and log obvious incorrect rule definitions"},{"line_number":556,"context_line":"            if self._need_check_rule:"},{"line_number":557,"context_line":"                self._need_check_rule \u003d False"},{"line_number":558,"context_line":"                self.check_rules()"},{"line_number":559,"context_line":""},{"line_number":560,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":3,"id":"bf8cb3f7_de73ab7f","line":557,"in_reply_to":"1f485f77_0ad7ad25","updated":"2017-12-26 10:24:20.000000000","message":"Why not just move check_rules call to end of set_rules and remove it from here?","commit_id":"e7274b61139342d04750d7ffb4ecd217a1fb1070"},{"author":{"_account_id":9796,"name":"ChangBo Guo","email":"glongwave@gmail.com","username":"gcb"},"change_message_id":"8ab86497d068bd6ae2f323f6df4e0ed2ca2ef8d3","unresolved":false,"context_lines":[{"line_number":554,"context_line":""},{"line_number":555,"context_line":"            # Detect and log obvious incorrect rule definitions"},{"line_number":556,"context_line":"            if self._need_check_rule:"},{"line_number":557,"context_line":"                self._need_check_rule \u003d False"},{"line_number":558,"context_line":"                self.check_rules()"},{"line_number":559,"context_line":""},{"line_number":560,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":3,"id":"1f485f77_0ad7ad25","line":557,"in_reply_to":"1f485f77_433e072a","updated":"2017-11-15 01:55:33.000000000","message":"Any reload will call method set_rules. that\u0027s the only one place that we need check rules.  see line #682","commit_id":"e7274b61139342d04750d7ffb4ecd217a1fb1070"},{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"2661c7a36574b4b5c538917a55e63e2a6e7cc432","unresolved":false,"context_lines":[{"line_number":554,"context_line":""},{"line_number":555,"context_line":"            # Detect and log obvious incorrect rule definitions"},{"line_number":556,"context_line":"            if self._need_check_rule:"},{"line_number":557,"context_line":"                self._need_check_rule \u003d False"},{"line_number":558,"context_line":"                self.check_rules()"},{"line_number":559,"context_line":""},{"line_number":560,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":3,"id":"5f7c97a3_431fb75a","line":557,"in_reply_to":"bf8cb3f7_3e12d70a","updated":"2018-06-19 16:40:44.000000000","message":"Yeah, it would be better to call  it from set_rules since that\u0027s a public method users could potentially use to set policy rules, but then it would get called for every file in a directory, which is the opposite of what this change it trying to do.  Since that\u0027s an existing problem and I suspect most users don\u0027t call set_rules directly I\u0027m inclined to leave it be for now.","commit_id":"e7274b61139342d04750d7ffb4ecd217a1fb1070"},{"author":{"_account_id":9312,"name":"Alexandre Levine","email":"alexandrelevine@gmail.com","username":"alevine"},"change_message_id":"5e7e74da9ef3fde5c732e4430977901fd7462743","unresolved":false,"context_lines":[{"line_number":554,"context_line":""},{"line_number":555,"context_line":"            # Detect and log obvious incorrect rule definitions"},{"line_number":556,"context_line":"            if self._need_check_rule:"},{"line_number":557,"context_line":"                self._need_check_rule \u003d False"},{"line_number":558,"context_line":"                self.check_rules()"},{"line_number":559,"context_line":""},{"line_number":560,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":3,"id":"bf8cb3f7_3e12d70a","line":557,"in_reply_to":"bf8cb3f7_de73ab7f","updated":"2017-12-26 10:28:16.000000000","message":"\u003e Why not just move check_rules call to end of set_rules and remove\n \u003e it from here?\n\nBecause when policies are loaded from directory it can be called multiple times?","commit_id":"e7274b61139342d04750d7ffb4ecd217a1fb1070"},{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"b24563c0cbdde88d4500a9ed83979ff5c309ee38","unresolved":false,"context_lines":[{"line_number":554,"context_line":""},{"line_number":555,"context_line":"            # Detect and log obvious incorrect rule definitions"},{"line_number":556,"context_line":"            if self._need_check_rule:"},{"line_number":557,"context_line":"                self._need_check_rule \u003d False"},{"line_number":558,"context_line":"                self.check_rules()"},{"line_number":559,"context_line":""},{"line_number":560,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":4,"id":"5f7c97a3_a35c2ff0","line":557,"updated":"2018-07-18 19:21:24.000000000","message":"Should we wait to change the flag until after check_rules() returns?","commit_id":"c1279c11274d462729e44b96955881cf1014fd59"},{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"65e7d0039bc8f1d6bb4b44fa6c342b844ba6ff4a","unresolved":false,"context_lines":[{"line_number":554,"context_line":""},{"line_number":555,"context_line":"            # Detect and log obvious incorrect rule definitions"},{"line_number":556,"context_line":"            if self._need_check_rule:"},{"line_number":557,"context_line":"                self._need_check_rule \u003d False"},{"line_number":558,"context_line":"                self.check_rules()"},{"line_number":559,"context_line":""},{"line_number":560,"context_line":"    def check_rules(self, raise_on_violation\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":4,"id":"5f7c97a3_c3bdabd7","line":557,"in_reply_to":"5f7c97a3_a35c2ff0","updated":"2018-07-18 19:24:25.000000000","message":"That seems like a good idea.  I\u0027ll change it.","commit_id":"c1279c11274d462729e44b96955881cf1014fd59"}]}
