Merge lp://staging/~mskalka/charm-helpers/apache-servertokens into lp://staging/charm-helpers

Proposed by Michael Skalka
Status: Merged
Merged at revision: 719
Proposed branch: lp://staging/~mskalka/charm-helpers/apache-servertokens
Merge into: lp://staging/charm-helpers
Diff against target: 136 lines (+31/-24)
7 files modified
charmhelpers/contrib/hardening/apache/checks/config.py (+4/-3)
charmhelpers/contrib/hardening/apache/templates/99-hardening.conf (+19/-0)
charmhelpers/contrib/hardening/apache/templates/hardening.conf (+0/-18)
charmhelpers/contrib/hardening/defaults/apache.yaml (+2/-1)
charmhelpers/contrib/hardening/defaults/apache.yaml.schema (+1/-0)
tests/contrib/hardening/apache/checks/test_config.py (+3/-1)
tests/contrib/hardening/test_templating.py (+2/-1)
To merge this branch: bzr merge lp://staging/~mskalka/charm-helpers/apache-servertokens
Reviewer Review Type Date Requested Status
Ante Karamatić (community) Approve
Edward Hope-Morley Approve
Review via email: mp+319860@code.staging.launchpad.net

Description of the change

Adds the ServerToken directive to Apache's hardening.conf, defaulting to 'Prod' and renames hardening.conf to 99-hardening.conf so that it overrides existing settings in conf-enabled.

To post a comment you must log in.
Revision history for this message
Edward Hope-Morley (hopem) wrote :

Hi Michael, thank you for submitting a patch to charm-helpers. In general your patch looks find although I do have once comment below with regards to changing the template filename.

review: Needs Information
Revision history for this message
Edward Hope-Morley (hopem) :
review: Approve
Revision history for this message
Edward Hope-Morley (hopem) wrote :

I'm getting some unit test errors. Please fix these errors and run make test.

======================================================================
ERROR: test_ApacheConfContext (tests.contrib.hardening.apache.checks.test_config.ApacheConfigTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/.venv/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
    return func(*args, **keywargs)
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/tests/contrib/hardening/apache/checks/test_config.py", line 75, in test_ApacheConfContext
    self.assertEqual(ctxt(), {'allowed_http_methods': set(['GOGETEM']),
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/charmhelpers/contrib/hardening/apache/checks/config.py", line 98, in __call__
    ctxt['servertokens'] = settings['hardening']['servertokens']
KeyError: 'servertokens'

======================================================================
ERROR: test_apache_conf_and_check (tests.contrib.hardening.test_templating.TemplatingTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/.venv/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
    return func(*args, **keywargs)
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/tests/contrib/hardening/test_templating.py", line 255, in test_apache_conf_and_check
    self.render(renderers)
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/tests/contrib/hardening/test_templating.py", line 74, in render
    template.comply(p)
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/charmhelpers/contrib/hardening/audits/file.py", line 393, in comply
    render_and_write(self.template_dir, path, self.context())
  File "/mnt/trusty/home/user1/bzr/charmstore/charm-helpers/charmhelpers/contrib/hardening/apache/checks/config.py", line 98, in __call__
    ctxt['servertokens'] = settings['hardening']['servertokens']
KeyError: 'servertokens'

review: Needs Fixing
721. By Michael Skalka

fixed unittest errors as per MP comments

Revision history for this message
Michael Skalka (mskalka) wrote :

> I'm getting some unit test errors. Please fix these errors and run make test.

Edward,

Thank you for the review, apologies for skipping the unittests, I should know better at this point. Fix is pushed up.

Michael

Revision history for this message
Joseph Borg (joeborg) wrote :

Hey Michael,

Just a heads up, you don't need to add

ctxt['servertokens'] = settings['hardening']['servertokens']

because you have the line

settings = utils.get_settings('apache')
ctxt = settings['hardening']

above it.

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Thanks lgtm.

review: Approve
Revision history for this message
Ante Karamatić (ivoks) wrote :

LGTM also, but please note Joseph's comment about ctxt; it's redundant.

Revision history for this message
Ante Karamatić (ivoks) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches