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

util: rewrite test/prepend_testcerts_openssl.sh, update testdata #421

Merged
merged 7 commits into from
Mar 17, 2020

Conversation

cpu
Copy link
Member

@cpu cpu commented Mar 17, 2020

The old version of test/prepend_testcerts_openssl.sh needed to be run from a specific directory, didn't pass shellcheck, and would unconditionally prepend the OpenSSL text output to all certs in the testdata dir (even if they already had it).

The version in 04c9d99 should be safer and suitable to be integrated with CI. It also supports taking a glob as the first argument and only prepending certs that need it and have a filename that matches the glob. I kept it in BASH rather than rewriting it in Go since we're shelling out to openssl and I find that's fiddly work in Go and the overall complexity of the script is low.

b250164 contains the results of running the script against the full testdata directory. Many testcerts were missing OpenSSL text output and this commit fixes them across the board.

06f8b73 is the one exception where openssl fails to parse the certificate. For now I've added a note about this to the .pem file such that the prepend_testcerts_openssl.sh script no longer emits a warning. I haven't done any investigation work into the testcert/testcase and why it fails to parse.

db871ab updates CI to run the test/prepend_testcerts_openssl.sh script for each branch's build and exit with an error code if there are diffs. This will make sure we don't introduce any new test certs after b250164 that forget to include some text before the PEM contents.

cpu added 3 commits March 17, 2020 12:03
The old version needed to be run from a specific directory, didn't pass
`shellcheck`, and would unconditionally prepend the OpenSSL text output
to all certs in the testdata dir (even if they already had it).

This version should be safer and suitable to be integrated with CI in
a later step. It also supports taking a glob as the first argument and
only prepending certs that need it and have a filename that matches
the glob.
This test file does not parse successfully with OpenSSL 1.1.1d on my dev
machine. Adding a small text note about this before the PEM content
avoids the `v2/test/prepend_testcerts_openssl.sh` script emitting
a warning.
@cpu cpu requested review from zakird and sleevi March 17, 2020 16:12
@cpu cpu self-assigned this Mar 17, 2020
cpu added 3 commits March 17, 2020 12:18
This updates CI to run the `test/prepend_testcerts_openssl.sh` script
and fail if there are any diffs to the `testdata/` directory. This would
indicate there was a `.pem` file that didn't have text prepended to it.
…lint into cpu-improve-openssl-prepend-script
Copy link
Contributor

@sleevi sleevi left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

@cpu
Copy link
Member Author

cpu commented Mar 17, 2020

Since this is test-only I'm going to go ahead and merge it. Thanks!

@cpu cpu merged commit 94d7dde into zmap:master Mar 17, 2020
@cpu cpu deleted the cpu-improve-openssl-prepend-script branch March 17, 2020 17:28
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