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

Backport tests #60

Merged
merged 10 commits into from
Sep 24, 2014
Merged

Backport tests #60

merged 10 commits into from
Sep 24, 2014

Conversation

ben-jones
Copy link
Contributor

@gsathya, this is a pull request to backport 2 tests from the summer version of Centinel. This has already been code reviewed and it works. Will you review/merge it?

@gsathya
Copy link
Contributor

gsathya commented Sep 24, 2014

Does this actually work? There is no utils folder at all

@gsathya
Copy link
Contributor

gsathya commented Sep 24, 2014

(FYI for future - just run the code before creating a pull request)


from centinel.experiment import Experiment


Copy link
Contributor

Choose a reason for hiding this comment

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

extra line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant for there to be 2 lines here. This is part of pep8 and I think it makes it easier to differentiate between portions of the code, i.e. imports and actual code.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good to me, but i'd rather have consistency so either add two lines everywhere or remove these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PEP 8 is 2 lines between imports/constants and first function/code and 2 lines between each function. I am ok with 1 line between functions but I would like 2 lines between the imports and the start of code. This is the same structure as every other file I have written for the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure i like this style -- I just wanted consistency. if this true for every file in centinel then I'm on board.

@gsathya
Copy link
Contributor

gsathya commented Sep 24, 2014

tls.py should be in "primitives" folder not "utils"

@gsathya
Copy link
Contributor

gsathya commented Sep 24, 2014

Does this actually work? There is no utils folder at all

ah i just saw that you re created the utils folder. nvm 👍

@ben-jones
Copy link
Contributor Author

@gsathya, something really weird is going on. I have a utils folder, it has other stuff in it, and it is committed as part of the repo (git status shows nothing for that folder).

I think I have some code left over from an older version of the repo. Did you refactor the utils directory at some point? Do you have a preference for me to use something other than utils?

@ben-jones
Copy link
Contributor Author

@gsathya, I understand now. I have a bunch of folders left after your refactor because I have .pyc and *~ files in them, which I have git set to ignore, so it won't delete those folders. Weird.

@gsathya
Copy link
Contributor

gsathya commented Sep 24, 2014

Did you refactor the utils directory at some point? Do you have a preference for me to use something other than utils?

Yes. See 0d89801

The files in utils should be moved to primitives folder

self.host, self.port = line[0].strip(), int(line[1].strip())
self.fprs = []
for entry in line[2:]:
self.fprs.append(entry.strip().lower())
Copy link
Contributor

Choose a reason for hiding this comment

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

self.tls_fingerprints = [fpr.strip().lower() for fpr in line[2:]]

Copy link
Contributor

Choose a reason for hiding this comment

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

actually make this -
self.tls_fingerprints = set([fpr.strip().lower() for fpr in line[2:]])


logging.info("Getting TLS Certificate from %s on port %s " %
(self.host, self.port))
fpr, cert = tls.get_fingerprint(self.host, self.port)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/fpr/fingerprint

@ben-jones
Copy link
Contributor Author

@gsathya, I have fixed everything requested. merge?

def get_fingerprint(host, port):
cert = ssl.get_server_certificate((host, port))
x509 = M2Crypto.X509.load_cert_string(cert, M2Crypto.X509.FORMAT_PEM)
fpr = x509.get_fingerprint('sha1')
Copy link
Contributor

Choose a reason for hiding this comment

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

s/fpr/fingerprint

cert = ssl.get_server_certificate((host, port))
x509 = M2Crypto.X509.load_cert_string(cert, M2Crypto.X509.FORMAT_PEM)
fpr = x509.get_fingerprint('sha1')
return fpr.lower(), cert
Copy link
Contributor

Choose a reason for hiding this comment

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

s/fpr/fingerprint

Copy link
Contributor

Choose a reason for hiding this comment

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

i thought i added these two comments before, sorry about making you do this again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must have missed it. my b.

@gsathya
Copy link
Contributor

gsathya commented Sep 24, 2014

looks good 👍 feel free to merge it once you change fpr to fingerprint (i would also recommend you try to run it once before though)

ben-jones added a commit that referenced this pull request Sep 24, 2014
@ben-jones ben-jones merged commit 1f1f812 into iclab:master Sep 24, 2014
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.

2 participants