Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement simple CA range checking #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rcritten
Copy link
Collaborator

Checking the CS.cfg ranges requires visibility for the whole
cluster so only report those values.

We can check that the data stored in LDAP doesn't overlap and
that the nextRange value is defined.

#76

@rcritten
Copy link
Collaborator Author

@frasertweedale can you take a look?

@rcritten rcritten force-pushed the carange branch 2 times, most recently from 8ed261d to 6e849a6 Compare September 30, 2019 21:52
Copy link
Contributor

@frasertweedale frasertweedale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rcritten the general approach seems fine, as is most of the code. But there are some mistakes and omissions (I do not blame you for this, it is confusing!) If you agree, I can take over the ticket for the next sprint and make the necessary fixes and additions? It is good for me to get more familiar with Health Check.

yield Result(self, constants.CRITICAL,
key='nextRange',
dn='ou=certificateRepository,ou=ca,o=ipaca',
msg='multiple {key} values in {dn}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to also handle the len(entries) == 0 case, so perhaps the error message should mention the number of entries (and that only one entry was expected).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The no entries case is handled on line 67. The message for multiple can be improved, I'll push an update.

msg='multiple {key} values in {dn}')
return
else:
nextrange = int(entries[0].single_value.get('nextRange', 0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certificate repository (and KRA keyRepository) uses hex encoding. Even though they may look decimal-ish :)

attrlist = ['beginRange', 'endRange', 'host']
try:
entries = self.conn.get_entries(
DN('ou=requests,ou=ranges,o=ipaca'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here we are comparing request ranges against the certificateRepository nextRange. We need to output and compare range entries and nextRange values separate for each of:

  • CA certificateRepository
  • CA requests
  • CA replicas
  • KRA keyRepository
  • KRA requests
  • KRA replicas

It's a pain, I know. I suppose the best way is a superclass with all the logic, and a subclass for each managed range that just plugs in a few parameters (what are the CS.cfg params, repository object DN, range object base DN, whether the numbers are decimal or hex).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I didn't get that part from the docs.

keys = [('dbs.beginSerialNumber', True),
('dbs.endSerialNumber', True),
('dbs.nextBeginSerialNumber', False),
('dbs.nextEndSerialNumber', False)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah, same comment here, this looks fine for serials, but we need to do similar thing for all the other managed ranges.

@rcritten
Copy link
Collaborator Author

rcritten commented Oct 2, 2019

Sure, you can take it over. I'll push the one minor update for the multiple keys message.

Checking the CS.cfg ranges requires visibility for the whole
cluster so only report those values.

We can check that the data stored in LDAP doesn't overlap and
that the nextRange value is defined.

freeipa#76
@rcritten
Copy link
Collaborator Author

rcritten commented Oct 2, 2019

I pushed a fix for multiple ranges and added a test case for it.

@rcritten rcritten added the wip Work in progress - do not merge even if CI passes label Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Work in progress - do not merge even if CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants