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

[ER-459] Add crypto2 to the Erlang load path in FIPS mode #1065

Merged
merged 9 commits into from
Feb 3, 2017

Conversation

rmoshier
Copy link
Contributor

@rmoshier rmoshier commented Jan 26, 2017

This templatizes vm.args to include the crypot2 module at the front of the load path if FIPS mode is enabled. This means that after adding fips true to chef-server.rb and reconfiguring, the Erlang app will be using the crypto2 module to access the OpenSSL FIPS module.

We include the erlang-crypto2 module in all omnibus distributions, but users chose to activate it at runtime.

  • Manual testing to make sure this works
  • Update the other Erlang modules to use a similar pattern

stevendanna
stevendanna previously approved these changes Jan 27, 2017
Copy link
Contributor

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

Nice start on this! Left a few (hopefully minor) comments. Let me know if any of them are bigger changes than seem reasonable.

specs:
license_scout (0.1.2)
ffi-yajl (~> 2.2)
mixlib-shellout (~> 2.2)

GIT
remote: git://github.com/chef/omnibus-software.git
revision: 9f7c4536e484ab68fcbae96e527a3fbaf961bb15
revision: d55178fb6d2afbafee17b7e95ed0d1bad4736e22
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these changes will go away if you rebase on master.


# TODO get Jay to convert this to Apache 2
license "Reserved"
license_file "LICENSE"
Copy link
Contributor

Choose a reason for hiding this comment

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

The LICENSE file looks like a 3-clause BSD license, so I think we are fine here, just need to change "Reserved" to BSD-3

license_file "LICENSE"

dependency "erlang"
dependency "rebar"
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be rebar 2. Does this compile with rebar3? If so, it might be good to make a rebar3 software definition (we can pull their prebuilt binary and copy it into embedded/bin) so we don't have to deal with both rebar 2 and rebar 3 when figuring out build issues in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

It compiled successfully with rebar 2 in my tests. So I figured I would try that instead of trying to bring in rebar 3.

I thought that chef-server was using rebar 2? Thats the default version of the rebar definition (and there is no rebar3 binary)

Copy link
Contributor

Choose a reason for hiding this comment

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

@tyler-ball Chef Server uses rebar3 everywhere. We moved to rebar3 during the beta so we vendored rebar3 into each app at the time of conversion. We have a long-standing TODO to get to a single version now that it is stable. (You'll see src/oc_erchef/rebar3, src/bookshelf/rebar3, etc).

build do
env = with_standard_compiler_flags(with_embedded_path)

env['USE_SYSTEM_GECODE'] = "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these environment variables necessary for erlang-crypto2? I don't seem them referenced in Jay's repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no idea - I can try removing them and seeing if it still compiles. I just copied the erchef definition and left in whatever was there

@@ -59,6 +59,12 @@
notifies :restart, 'runit_service[opscode-erchef]' unless backend_secondary?
end

template "/opt/opscode/embedded/service/opscode-erchef/vm.args" do
source "oc_erchef.vm.args.erb"
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we'll eventually want to do this for the other erlang apps as well so we'll likely want this to be a more generic template that we can pass the app name into.

Copy link
Contributor

Choose a reason for hiding this comment

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

But the other vm.args I looked at was pretty different. I'll see if I can make some common template parts I will. If they are all different, I'll leave them as separate templates.

@@ -59,6 +59,12 @@
notifies :restart, 'runit_service[opscode-erchef]' unless backend_secondary?
end

template "/opt/opscode/embedded/service/opscode-erchef/vm.args" do
Copy link
Contributor

Choose a reason for hiding this comment

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

For sys.config we write the template into /var/opt/opscode/opscode-erchef and then symlink that into /opt/opscode/embedded/service/opscode-erchef/. Perhaps we should do the same here for symmetry?

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw that. I didn't know the reasoning behind symlinking instead of just writing the file. If you think thats the right thing to do, then I'll do that!

Copy link
Contributor

Choose a reason for hiding this comment

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

@tyler-ball I am honestly unsure on the original intent of these symlinks. I think we've been carting them around for a while. @marcparadise Do you know?

@stevendanna stevendanna dismissed their stale review January 27, 2017 00:36

I meant to comment not approve.

@rmoshier rmoshier changed the title Er 454/crypto2 Er 459/crypto2 Jan 30, 2017
@tyler-ball tyler-ball changed the title Er 459/crypto2 [ER-459] Add crypto2 to the Erlang load path in FIPS mode Jan 30, 2017
@tyler-ball
Copy link
Contributor

I need to test this some more and see if there are any tests I can add/update, but I would love to start getting eyes on this. /cc @chef/chef-server-maintainers

Copy link
Contributor

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for fighting through this one. I like the approach y'all landed on.

I've left a few comments but the only ones I think is blocking is to clean up all of the rebar.config's and the re-ordering of the project file.

I think that eventually we could unify those templates but don't want that to block this moving forward.

@@ -97,6 +97,7 @@
dependency "private-chef-upgrades"
dependency "private-chef-cookbooks"
dependency "chef-ha-plugin-config"
dependency "erlang-crypto2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this further up. My guess is this code will not be changing often after we have it stable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done, moved into the global commented block

@@ -25,7 +25,7 @@

build do
env = with_standard_compiler_flags(with_embedded_path)
profile_name = fips_mode? ? "fips" : "default"
profile_name = "default"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not important right now, but we can probably remove the profile_name stuff completely and just assume "default" which is what rebar3 will build by...default.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assumed it would do that but wanted to introduce as few changes as possible. I'll go ahead and remove this though since it does default by... default 😁

@@ -101,11 +101,6 @@
]},
{erl_opts, [export_all]}
]},
{fips, [
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do similar cleanups in other erlang apps?

Copy link
Contributor

Choose a reason for hiding this comment

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

:doh: Incoming!

owner OmnibusHelper.new(node).ownership['owner']
group OmnibusHelper.new(node).ownership['group']
mode "644"
notifies :restart, 'runit_service[oc_bifrost]' unless backend_secondary?
Copy link
Contributor

@stevendanna stevendanna Feb 1, 2017

Choose a reason for hiding this comment

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

Note to other reviewers: The differences in the restart strategies across the various apps match the already existing differences from the sys.config files for these apps. My guess is that this can be sorted out so they are all the same, but I don't think it should be a blocker for this.

@tyler-ball
Copy link
Contributor

@stevendanna Updated per your comments!

@tyler-ball
Copy link
Contributor

Pedant tests passed with a local build

Copy link
Member

@marcparadise marcparadise left a comment

Choose a reason for hiding this comment

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

This looks a lot more manageable.

Since we're moving the vm.args files [back] into templates, let's also remove them from their original locations in $project/config/vm.args, and the overlay references in $project/rebar.config

#

name "erlang-crypto2"
default_version "er-459/update-crypto"
Copy link
Member

Choose a reason for hiding this comment

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

Reminder to change this once the branch lands

skip_transitive_dependency_licensing true

dependency "erlang"
dependency "rebar"
Copy link
Member

Choose a reason for hiding this comment

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

This will pull in rebar2 which we're trying to eradicate. It's not great, but our current practice is to include the rebar3 binary within 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.

I'm fine with updating to rebar3. How is that binary included in chef-server right now? I don't see an omnibus software dependency on it. I definitely want to build this using whatever other rebar tools we use.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that it is just copied into the 4 Erlang applications. I'm going to use the .../src/bookshelf/rebar3 instance to build this application.

@tyler-ball
Copy link
Contributor

@marcparadise I had to restore the vm.args for the oc_bifrost application. Without this file present in the root of the release, the bin/oc_bifrost start command loads vm.args and sys.config from releases/12.12.0-blah/. Those files are defaulted / empty so they are missing necessary config values to run.

Restoring vm.args to the root of the release dir causes the bin/oc_bifrost start to load vm.args and sys.config from the root dir. This sys.config has the correct configurations needed and the applicaiton starts.

It looks like the bin/oc_bifrost command is generated by rebar (or relx) so I could not change that. Instead I opted to restore the vm.args file that I had deleted.

* Build the erlang-crypto2 app as a separate omnibus definition using the same
Erlang libraries used to build all other Erlang apps. Copy the `ebin` and `priv`
folders from the build into a custom location inside the omnibus package.
* If `fips true` is set and the server reconfigured, we update the `vm.args`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

s/server reconfigured/server is reconfigured

…g FIPS module does not support TLS

Signed-off-by: tyler-ball <[email protected]>
…ave a rebar 2 binary in the final package

Signed-off-by: tyler-ball <[email protected]>
They fail because the missing vm.args file causes the oc_bifrost
application to load vm.args and sys.config from the releases folder.
These files have default / empty values and the oc_bifrost application
then fails to start.

Signed-off-by: tyler-ball <[email protected]>
@tyler-ball tyler-ball merged commit e5b2c91 into master Feb 3, 2017
@tyler-ball tyler-ball deleted the er-454/crypto2 branch February 3, 2017 17:57
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.

4 participants