)]}'
{"oslo_policy/shell.py":[{"author":{"_account_id":2472,"name":"Doug Hellmann","email":"dhellmann@redhat.com","username":"doug-hellmann"},"change_message_id":"a8986a918f093f60be5d2ba92c4cbcdcd8532992","unresolved":false,"context_lines":[{"line_number":32,"context_line":"        if isinstance(self.conf, configparser.ConfigParser):"},{"line_number":33,"context_line":"            return Config(self.conf._sections[attr])"},{"line_number":34,"context_line":"        # It\u0027s accessing an object in a section"},{"line_number":35,"context_line":"        return self.conf[attr]"},{"line_number":36,"context_line":""},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"class FakeEnforcer(object):"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_a747491b","line":35,"updated":"2018-11-08 18:39:34.000000000","message":"This class seems to re-implement the getattr behavior that\u0027s already in the ConfigParser class. What am I missing about why this wrapper is needed?","commit_id":"ba9aa28c903880ea3c0ee9e8777650342a67a4bc"},{"author":{"_account_id":10873,"name":"Juan Antonio Osorio Robles","email":"jaosorior@redhat.com","username":"ejuaoso"},"change_message_id":"bdae8e20a390a008ec9c59a877b98a2671db2440","unresolved":false,"context_lines":[{"line_number":32,"context_line":"        if isinstance(self.conf, configparser.ConfigParser):"},{"line_number":33,"context_line":"            return Config(self.conf._sections[attr])"},{"line_number":34,"context_line":"        # It\u0027s accessing an object in a section"},{"line_number":35,"context_line":"        return self.conf[attr]"},{"line_number":36,"context_line":""},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"class FakeEnforcer(object):"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_c59cb3bf","line":35,"in_reply_to":"3f79a3b5_a747491b","updated":"2018-11-09 09:11:09.000000000","message":"That didn\u0027t seem to be the case. The ConfigParser class can fetch itsems in a dict-like manner, but not as attributes. If I wouldn\u0027t use this, I would get:\n\nConfigParser instance has no attribute \u0027oslo_policy\u0027","commit_id":"ba9aa28c903880ea3c0ee9e8777650342a67a4bc"},{"author":{"_account_id":14250,"name":"Grzegorz Grasza","email":"xek@redhat.com","username":"xek"},"change_message_id":"4824b75d2ac1296febfc150a99df7e25266cce7b","unresolved":false,"context_lines":[{"line_number":61,"context_line":"    return dict(items)"},{"line_number":62,"context_line":""},{"line_number":63,"context_line":""},{"line_number":64,"context_line":"def tool(conf):"},{"line_number":65,"context_line":"    policy_file \u003d open(conf.policy, \"rb\", 0)"},{"line_number":66,"context_line":"    access_file \u003d open(conf.access, \"rb\", 0)"},{"line_number":67,"context_line":"    target_file \u003d open(conf.target, \"rb\", 0) if conf.target else None"}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_56046c11","line":64,"updated":"2018-12-14 12:33:45.000000000","message":"I wouldn\u0027t change it to passing the whole conf object, because it is easier to reason about the function if you can clearly see what arguments it takes. It is also easier to import and call it on the command line, reuse it, and write unit tests.\n\nMy previous comment in the previous patch follows the same logic - it is easier to pass file names as arguments, then to create file objects beforehand or create the conf object in case you would like to reuse this function elsewhere, or call it while debugging.","commit_id":"2941f51c9bcca393c20979575c94a05f640642a3"},{"author":{"_account_id":14250,"name":"Grzegorz Grasza","email":"xek@redhat.com","username":"xek"},"change_message_id":"4824b75d2ac1296febfc150a99df7e25266cce7b","unresolved":false,"context_lines":[{"line_number":64,"context_line":"def tool(conf):"},{"line_number":65,"context_line":"    policy_file \u003d open(conf.policy, \"rb\", 0)"},{"line_number":66,"context_line":"    access_file \u003d open(conf.access, \"rb\", 0)"},{"line_number":67,"context_line":"    target_file \u003d open(conf.target, \"rb\", 0) if conf.target else None"},{"line_number":68,"context_line":"    apply_rule \u003d conf.rule"},{"line_number":69,"context_line":"    is_admin \u003d conf.is_admin.lower() \u003d\u003d \"true\""},{"line_number":70,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_d6ccfc96","line":67,"updated":"2018-12-14 12:33:45.000000000","message":"The way you wrote it, the files could stay open after the function finishes (probably up to a garbage collection event), and if someone reuses it in a loop without realizing it, they will end up with many open file descriptors.\n\nThe best way to mitigate that is to use the \"with\" statement. I would also only use it with a minimal scope, that is, only open a file before reading it and close it the moment you don\u0027t need it. (So the only thing indented under the \"with\" is the .read() call.)\n\nThese are just general rules which may not directly apply here, but I think it\u0027s good to employ them everywhere you can, just to get yourself and others used to good practices.","commit_id":"2941f51c9bcca393c20979575c94a05f640642a3"},{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"db024a5699d65a592873f538a65121b291d2947c","unresolved":false,"context_lines":[{"line_number":25,"context_line":"class FakeEnforcer(object):"},{"line_number":26,"context_line":"    def __init__(self, rules, config):"},{"line_number":27,"context_line":"        self.rules \u003d rules"},{"line_number":28,"context_line":"        self.conf \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"        if config:"},{"line_number":31,"context_line":"            self.conf \u003d cfg.ConfigOpts()"},{"line_number":32,"context_line":"            self.conf([\"--config-file\u003d{}\".format(config)])"},{"line_number":33,"context_line":"            self.conf()"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""},{"line_number":36,"context_line":"def _try_rule(key, rule, target, access_data, o):"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_e460f1a1","line":33,"range":{"start_line":28,"start_character":8,"end_line":33,"end_character":23},"updated":"2018-12-20 16:56:55.000000000","message":"What is the purpose of this? There are no opts registered on this config object so it\u0027s not going to have any useful data in it (or rather, the data will be there but it won\u0027t be exposed).\n\nFor that matter, I\u0027m not sure how this enforcer is supposed to work. There\u0027s no enforce() method on this class, which seems like a necessary piece of the API.","commit_id":"1e3636f894538914947f3d517593571bc24d429a"},{"author":{"_account_id":27954,"name":"Moisés Guimarães de Medeiros","email":"guimaraes@pm.me","username":"moguimar"},"change_message_id":"38c149d40699362bf728064efc931888170da2e7","unresolved":false,"context_lines":[{"line_number":25,"context_line":"class FakeEnforcer(object):"},{"line_number":26,"context_line":"    def __init__(self, rules, config):"},{"line_number":27,"context_line":"        self.rules \u003d rules"},{"line_number":28,"context_line":"        self.conf \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"        if config:"},{"line_number":31,"context_line":"            self.conf \u003d cfg.ConfigOpts()"},{"line_number":32,"context_line":"            self.conf([\"--config-file\u003d{}\".format(config)])"},{"line_number":33,"context_line":"            self.conf()"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""},{"line_number":36,"context_line":"def _try_rule(key, rule, target, access_data, o):"}],"source_content_type":"text/x-python","patch_set":7,"id":"ffd0ebdf_5c3f02d6","line":33,"range":{"start_line":28,"start_character":8,"end_line":33,"end_character":23},"in_reply_to":"3f79a3b5_e460f1a1","updated":"2019-01-03 12:55:38.000000000","message":"Juan Osorio, could you answer Ben\u0027s question here?","commit_id":"1e3636f894538914947f3d517593571bc24d429a"},{"author":{"_account_id":10873,"name":"Juan Antonio Osorio Robles","email":"jaosorior@redhat.com","username":"ejuaoso"},"change_message_id":"318cecc03d1cba5ff64277c77478c7121c2767df","unresolved":false,"context_lines":[{"line_number":25,"context_line":"class FakeEnforcer(object):"},{"line_number":26,"context_line":"    def __init__(self, rules, config):"},{"line_number":27,"context_line":"        self.rules \u003d rules"},{"line_number":28,"context_line":"        self.conf \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"        if config:"},{"line_number":31,"context_line":"            self.conf \u003d cfg.ConfigOpts()"},{"line_number":32,"context_line":"            self.conf([\"--config-file\u003d{}\".format(config)])"},{"line_number":33,"context_line":"            self.conf()"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""},{"line_number":36,"context_line":"def _try_rule(key, rule, target, access_data, o):"}],"source_content_type":"text/x-python","patch_set":7,"id":"ffd0ebdf_d13f42d4","line":33,"range":{"start_line":28,"start_character":8,"end_line":33,"end_character":23},"in_reply_to":"ffd0ebdf_5c3f02d6","updated":"2019-01-04 14:43:09.000000000","message":"We\u0027re not using the enforce method here in this command. However, to test stuff like the http check, or the opa check I was working on, this is needed.\n\nWe I initially used another class (other than oslo_config, because in the one I had initially used you don\u0027t need to register any config options... so you could use it to test any custom checks. Seems this won\u0027t be possible with oslo.cfg","commit_id":"1e3636f894538914947f3d517593571bc24d429a"},{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"88255783bb9f8744e3d73479ef6de1e3e64cdc82","unresolved":false,"context_lines":[{"line_number":26,"context_line":"class FakeEnforcer(object):"},{"line_number":27,"context_line":"    def __init__(self, rules, config):"},{"line_number":28,"context_line":"        self.rules \u003d rules"},{"line_number":29,"context_line":"        self.conf \u003d None"},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"        if config:"},{"line_number":32,"context_line":"            self.conf \u003d cfg.ConfigOpts()"}],"source_content_type":"text/x-python","patch_set":9,"id":"bfdaf3ff_f47a10ef","line":29,"updated":"2019-01-17 16:24:31.000000000","message":"Okay, so this isn\u0027t needed for any current checks but it will be in the future. Fair enough.","commit_id":"aea236c2c62b995e645113b93c2428f580f18e5d"},{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"a5c1ee3d842c723421f2d50668800966240947cb","unresolved":false,"context_lines":[{"line_number":30,"context_line":"        if config:"},{"line_number":31,"context_line":"            self.conf \u003d cfg.ConfigOpts()"},{"line_number":32,"context_line":"            self.conf([\"--config-file\u003d{}\".format(config)])"},{"line_number":33,"context_line":"            self.conf()"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""},{"line_number":36,"context_line":"def _try_rule(key, rule, target, access_data, o):"}],"source_content_type":"text/x-python","patch_set":10,"id":"9fdfeff1_00c9fd76","line":33,"updated":"2019-01-21 15:27:09.000000000","message":"I don\u0027t think you want to call the conf object twice. I would need to look for sure, but I\u0027m pretty sure that undoes whatever the original call did.","commit_id":"072f38cfcc36c2e4996c63e01707180aab2b7708"},{"author":{"_account_id":6928,"name":"Ben Nemec","email":"openstack@nemebean.com","username":"bnemec"},"change_message_id":"a5c1ee3d842c723421f2d50668800966240947cb","unresolved":false,"context_lines":[{"line_number":131,"context_line":""},{"line_number":132,"context_line":"    conf()"},{"line_number":133,"context_line":""},{"line_number":134,"context_line":"    tool(conf.policy_file, conf.access_file, conf.apply_rule, conf.is_admin,"},{"line_number":135,"context_line":"         conf.target_file, conf.enforcer_config)"},{"line_number":136,"context_line":""},{"line_number":137,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"9fdfeff1_80b5edf0","line":134,"updated":"2019-01-21 15:27:09.000000000","message":"This needs to be fixed. These were all renamed.","commit_id":"072f38cfcc36c2e4996c63e01707180aab2b7708"}]}
