wp_rel_nofollow()
does this for you. It is already called on pre_comment_content
, so comments should be covered. For sidebars and footers, this depends on the widgets and other code you use there, but it should be possible to call that function there too.