Added sandboxing to CommentDetailDisplayHook

Review Request #5709 — Created April 13, 2014 and submitted

Information

Review Board
master

Reviewers

Added sandboxing to CommentDetailDisplayHook

Added unit tests to test suite at reviewboard/extensions/tests.py

Unit testing - tested both render_review_comment_detail and render_email_comment_detail with and without sandboxing

Description From Last Updated

Please replace the space at the end of this line with a period (so it says "CommentDetailDisplayHook.render_review_comment_detail")

daviddavid

Same comment here with space vs. period

daviddavid

This is duplicated twice. I'd suggest getting rid of your new try calls, and just replacing the except NotImplementedError belowe …

daviddavid

Because of the way that hooks attach themselves to their extension (and the fact that you don't use the hook …

daviddavid

Because of the way that hooks attach themselves to their extension (and the fact that you don't use the hook …

daviddavid

I'd like to make a few changes to this string. First, there are a lot of colons, which interrupt the …

daviddavid

You still need to add a space after "with". Otherwise the string will concatenate to be "Error when running CommentDetailDisplayHook …

daviddavid
ED
ED
david
  1. 
      
  2. Show all issues

    Please replace the space at the end of this line with a period (so it says "CommentDetailDisplayHook.render_review_comment_detail")

  3. Show all issues

    Same comment here with space vs. period

  4. 
      
ED
david
  1. The code looks good, but the patch no longer applies cleanly. Can you rebase this onto the latest release-2.0.x and update?

  2. 
      
ED
david
  1. 
      
  2. reviewboard/extensions/templatetags/rb_extensions.py (Diff revision 5)
     
     
     
     
     
     
     
    Show all issues

    This is duplicated twice. I'd suggest getting rid of your new try calls, and just replacing the except NotImplementedError belowe with this more-generic implementation.

    1. I was thinking about that, but it's a different function that is called (render_review_comment_detail vs. render_email_comment_detail, so what I'm loggin is slightly different. How should I handle that?

    2. Maybe include the render_mode in the logged string? That way when debugging we can still tell which function got called.

  3. reviewboard/extensions/tests.py (Diff revision 5)
     
     
    Show all issues

    Because of the way that hooks attach themselves to their extension (and the fact that you don't use the hook variable anywhere), you can remove the variable assignment and just have this line be CommentDetailDisplayTestHook(extension=self.extension).

    This will make static checkers like pyflakes happier.

  4. reviewboard/extensions/tests.py (Diff revision 5)
     
     
    Show all issues

    Because of the way that hooks attach themselves to their extension (and the fact that you don't use the hook variable anywhere), you can remove the variable assignment and just have this line be CommentDetailDisplayTestHook(extension=self.extension).

    This will make static checkers like pyflakes happier.

  5. 
      
ED
david
  1. 
      
  2. reviewboard/extensions/templatetags/rb_extensions.py (Diff revision 6)
     
     
     
     
     
    Show all issues

    I'd like to make a few changes to this string. First, there are a lot of colons, which interrupt the readability of the sentence. Second, the first line has to end with a space so it won't concatenate to "withrender". Last, I'd like you to rewrap it to keep the strings as compact as possible.

    logging.error('Error when running CommentDetailDisplayHook with '
                  'render mode "%s" in extension %s: %s',
                  render_mode, extension.metadata['Name'], e,
                  exc_info=1)
    
  3. 
      
ED
david
  1. 
      
  2. Show all issues

    You still need to add a space after "with". Otherwise the string will concatenate to be "Error when running CommentDetailDisplayHook withrender mode ..."

  3. 
      
ED
david
  1. Ship It!

  2. 
      
ED
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.0.x (f6f860f)