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

buildkite-agent: secrecy improvements: non-store, non-Nix-source provisioning of secrets #31979

Merged
merged 2 commits into from Nov 25, 2017

Conversation

deepfire
Copy link
Contributor

Motivation for this change
  1. Remove the requirement to store secrets in Nix source:
    • SSH keys
    • Buildkite token
  2. Make sure that the secrets don't hit the Nix store.
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@deepfire deepfire changed the title buildkite-agent: secrecy improvements: non-store, non-Nix provisioning of secrets buildkite-agent: secrecy improvements: non-store, non-Nix-source provisioning of secrets Nov 23, 2017
@deepfire
Copy link
Contributor Author

cc @domenkozar

@domenkozar
Copy link
Member

This is one of efforts for #24288

Copy link
Member

@domenkozar domenkozar left a comment

Choose a reason for hiding this comment

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

@@ -21,9 +16,11 @@ in
enable = mkEnableOption "buildkite-agent";

token = mkOption {
type = types.str;
type = types.either types.str types.path;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should break backwards compatibility here, since the old method was insecure.

We should just allow types.path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -3,16 +3,11 @@
with lib;

let
## isPath :: String -> Bool
isPath = x: !(isAttrs x || isList x || isFunction x || isString x || isInt x || isBool x || isNull x)
Copy link
Member

Choose a reason for hiding this comment

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

Once we use just path, this is redundant (already checked by types.path)

Copy link
Member

Choose a reason for hiding this comment

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

@deepfire needs to be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


echo "${cfg.openssh.publicKey}" > /var/lib/buildkite-agent/.ssh/id_rsa.pub
${pkgs.coreutils}/bin/chmod 600 /var/lib/buildkite-agent/.ssh/id_rsa.pub
cat > "/var/lib/buildkite-agent/buildkite-agent.cfg" <<EOF
Copy link
Member

Choose a reason for hiding this comment

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

Missing a comment why this is done this way, to prevent issues in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


cat > "/var/lib/buildkite-agent/buildkite-agent.cfg" <<EOF
token="${catOrLiteral cfg.token}"
token="$(cat ${toString cfg.tokenPath})"
Copy link
Member

Choose a reason for hiding this comment

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

One big caveat here is that tokenPath needs to be on the machine running this build, so not something NixOS itself managed (but NixOps does).

I think we should clarify this in option descriptions.

@@ -15,12 +15,12 @@ in
services.buildkite-agent = {
enable = mkEnableOption "buildkite-agent";

token = mkOption {
type = types.either types.str types.path;
tokenPath = mkOption {
Copy link
Member

Choose a reason for hiding this comment

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

The rename can only be done on master, for 17.09 we'll have to keep backwards compatibility :(

For master use mkRenamedOptionModule for renaming

…umentation

# Conflicts:
#	nixos/modules/services/continuous-integration/buildkite-agent.nix
@deepfire
Copy link
Contributor Author

@domenkozar, dropped the option renaming from this PR -- full version also submitted to master in #32009

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

sounds good overall but this should also be ported to master or it's going to disappear in the next release

@deepfire
Copy link
Contributor Author

@zimbatm, done!

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

LGTM. @domenkozar and last words? @deepfire please ping me again in a few days if this PR isn't merged

@domenkozar
Copy link
Member

cc @fpletz & @globin

@domenkozar domenkozar merged commit d6069f8 into NixOS:release-17.09 Nov 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants