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

Add support for client authentication, some minor refactoring #179

Merged
merged 42 commits into from Mar 20, 2019

Conversation

konklone
Copy link
Collaborator

@konklone konklone commented Oct 23, 2018

I'm opening this to more easily track @echudow's work on adding client cert authentication to pshtt.

There is some additional refactoring work in here, and possibly some logical changes. Let's use this PR to hash out the changes that would make pshtt usable for DHS, GSA, and DoD, without creating unintended regressions from existing reporting.

See also 18F/domain-scan#286.

@echudow
Copy link
Collaborator

echudow commented Oct 23, 2018

Because of the client cert issue, there could be some times when the initial request fails (and so it would not seem to be valid) even though it actually is valid so I changed one part where the initial request does not complete to assume that it is still valid and just couldn't complete the TLS handshake for other reasons, and then look at the sslyze results later to see if the HTTPS isn't valid.

@echudow
Copy link
Collaborator

echudow commented Oct 23, 2018

I also refactored some of the redirect code and I think fixed a bug there where it would report a redirect when there were no redirects.

@echudow
Copy link
Collaborator

echudow commented Oct 23, 2018

I also changed most of the log output to include the URL for easier troubleshooting based on the logs.

@echudow
Copy link
Collaborator

echudow commented Oct 24, 2018

@konklone Following up on the discussion from the other thread, are the results from my version actually harsher than the earlier pshtt version? If so, which field? It sounds like we're focusing on the Valid HTTPS field, but in the original version that field would only be true if the first request successfully completed, but the Python requests module I'm pretty sure throws an exception instead if the server cert is self-signed or has a bad chain (including missing Intermediate CA certs which is another issue), so the earlier version of pshtt should flag those as not valid. If there's an exception, then pshtt tries again without cert validation but the pshtt logic did not mark those as valid https in that case. Is this an issue in the original pshtt too or is there a different issue that I'm not seeing?

@konklone
Copy link
Collaborator Author

@echudow My question about whether this was harsher on untrusted certs was a genuine question. :) I'm not sure, and have to go back and look at what the current outputs are.

@echudow
Copy link
Collaborator

echudow commented Oct 24, 2018

@konklone Ok, let me know what you find out and then I'll work through any issues so hopefully we can all use the same code in the end.

@jsf9k
Copy link
Member

jsf9k commented Nov 13, 2018

@echudow and @konklone
Sorry for letting this fall through the cracks. Somehow I missed it. I'm looking at it now.

@jsf9k
Copy link
Member

jsf9k commented Nov 13, 2018

@echudow can you give me write permissions to your fork? I want to merge the upstream changes into your branch, but I can't commit there. The result of the merge is here. There were no conflicts.

The alternative is for me to create a pull request to your branch.

@echudow
Copy link
Collaborator

echudow commented Nov 13, 2018

Ok, I just gave you and Eric access to my forks of pshtt and domain-scan.

Note that changing the logic from:
if domain.https.live == False and domain.httpswww.live == False:
to:
if not domain.https.live and not domain.httpswww.live:
changes the result when both domain.https.live and
domain.httpswww.live are both None.  This is because None != False but
not None is True.

I think that in the edge case where domain.https.live == None and
domain.httpswww.live == None it makes more sense to return "N/A" anyway.
@jsf9k
Copy link
Member

jsf9k commented Nov 30, 2018

Reviewing the code, I don't see any problems with these changes. I could easily be missing something, but I think the only differences from the old code will be the new fields and sometimes the values of "liveness" and "is HTTPS valid". Still, I need to do a full pshtt scan and compare with the old results. I'm on vacation next week, but I can do that after I get back.

In the meantime, I added some reviewers in hope of getting more eyes on this pull request. If folks want to test, I can also provide a few URLs that require client certificates:

@jsf9k jsf9k requested review from jsf9k, IanLee1521, h-m-f-t and a team November 30, 2018 18:20
@jsf9k jsf9k self-assigned this Nov 30, 2018
@IanLee1521
Copy link
Collaborator

I don't have much experience with testing / using client cert sites, but this functionally looks fine to me. Do we have a verification that there aren't any regressions?

@echudow
Copy link
Collaborator

echudow commented Dec 18, 2018

Just fixed a bug that I introduced that prevented following some http redirects. I'm sure that would have caused some issues with some incorrect data. Has anyone compared the output to previous runs to see if there are any other bugs or regressions? Hopefully it just adds some data instead of some earlier errors.

@IanLee1521
Copy link
Collaborator

@jsf9k / @echudow -- Do you feel like this is ready to be merged? Looks like travis passed the PR build but hung on the branch build (sure...), I'm OK ignoring the coveralls drop which is the only real "fail" right now, though alternatively, is their more testing we could add for this to get the test coverage up?

Also, note that you are in a much better position than I am to confirm that this is working as expected and doesn't cause regressions.

If you're happy with it though, I can do the actual code review part for what I can comment on.

@jsf9k
Copy link
Member

jsf9k commented Mar 15, 2019

@IanLee1521 and @echudow, this PR will break the BOD 18-01 scanning. This is because it treats some fields that were boolean as a union of a boolean and a string.

This does give us more information than we had before, but I think it's important for the data fields to have a set type - particularly for the JSON output. What if we by default assign fields a type of None and only set them to True or False if we actually know the result? That will still break the BOD 18-01 scanning, and I will have to adjust it accordingly, but I think it's cleaner than using strings and booleans in the same field.

I can probably find some time to work on that whis weekend if you guys agree.

Thanks to @IanLee1521 for bumping this PR. We need to get this approved and merged since it's practically old enough to vote at this point. 👴

@echudow
Copy link
Collaborator

echudow commented Mar 15, 2019

Thanks guys for looking at this again. Leaving fields as None should work for us. Before, pshtt would automatically turn almost all the fields that are None to False, but with the changes I made there are cases where there are partial scans and only some of the data is known and others are unknown. Leaving them as None to indicate that they are unknown works for me and then we can convert those to "Unknown" when we put it up on our dashboard.

@jsf9k
Copy link
Member

jsf9k commented Mar 18, 2019

This pull request introduces 1 alert when merging 52b9c7b into 97c51ac - view on LGTM.com

new alerts:

  • 1 for Unnecessary pass

Comment posted by LGTM.com

The block where the "Unknown" results were being set is tricky because
of the continue statements.  This time I was careful to remove only
the statements that set fields from None to "Unknown" and leave the
continue statements.
@jsf9k
Copy link
Member

jsf9k commented Mar 18, 2019

This pull request introduces 1 alert when merging fbc318a into 97c51ac - view on LGTM.com

new alerts:

  • 1 for Unnecessary pass

Comment posted by LGTM.com

@jsf9k
Copy link
Member

jsf9k commented Mar 18, 2019

This pull request fixes 2 alerts when merging f20eca4 into 97c51ac - view on LGTM.com

fixed alerts:

  • 2 for Unnecessary pass

Comment posted by LGTM.com

Copy link
Member

@jsf9k jsf9k left a comment

Choose a reason for hiding this comment

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

Based on the results from doing a full test run with the new code, I think this PR is finally ready to be merged.

@jsf9k jsf9k merged commit cd5d0c9 into cisagov:develop Mar 20, 2019
jsf9k added a commit to cisagov/orchestrator that referenced this pull request Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants