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 signing to utils script #58

Merged
merged 4 commits into from
Sep 4, 2024

Conversation

alextserepov
Copy link
Contributor

  • Add sign file function
  • Add sign relpath function
  • Add signing to nix build
  • Add signing to provenance

TODO:

  • Get rid of hardcoded certificate name

  - Add sign file function
  - Add sign relpath function
  - Add signing to nix build
  - Add signing to provenance

TODO:

  - Get rid of hardcoded certificate name

Signed-off-by: Aleksandr Tserepov-Savolainen <[email protected]>
@alextserepov alextserepov requested a review from a team September 2, 2024 14:01
@mkaapu
Copy link
Contributor

mkaapu commented Sep 2, 2024

  • Get rid of hardcoded certificate name

There is a parallel build example with configuration map here:
https://github.com/tiiuae/ghaf-jenkins-pipeline/blob/PoC-parallel-eval/parallel-eval.groovy

Correct certificate / target could be configured maybe similarly in Jenkinsfile.

Copy link
Contributor

@mkaapu mkaapu left a comment

Choose a reason for hiding this comment

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

LGTM,
but do we want to implement signing with certificate / target under this PR?

utils.groovy Outdated Show resolved Hide resolved
utils.groovy Outdated
@@ -106,6 +108,12 @@ def provenance(String flakeref, String outdir, String flakeref_trimmed) {
"""
opts = "--recursive --out ${outdir}/provenance.json"
sh "provenance ${flakeref} ${opts}"
// Sign the provenance
path="${outdir}/provenance.json"
cert="INT-lenovo-x1-carbon-gen11-debug-x86-64-linux"
Copy link
Collaborator

Choose a reason for hiding this comment

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

As you wrote, we should not hardcode this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely. This will be replaced with target handling in later versions. For now we have to hardcode. Though, if you prefer it this way, I'm fine implementing target selector within the scope of this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would go with more complete implementation already now, unless there's a good reason not to. I'm not sure how you are planning to do this, but if takes days or more then maybe go with this temporary version first.

Copy link
Collaborator

@henrirosten henrirosten Sep 3, 2024

Choose a reason for hiding this comment

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

This is pending @alextserepov, I guess the main options now are:

  • For this first version, we just sign everything with "INT-lenovo-x1-carbon-gen11-debug-x86-64-linux" (which is what it now does).
  • For now, we introduce a new common certificate e.g. "INT-common" (just an example), and change this PR so that everything would be signed with that new 'common' certificate.
  • We introduce certificates for all targets we are planning to build for the next Ghaf release, and use a separate certificate for each target. At this point, it's still unclear (to me at least) what are the exact targets we are going to build for the Ghaf release, and thus, what would be all the certificates we would have to make available in the Azure certificate storage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed with @alextserepov that we would go with above option (2) initially, see commit 3d85d00.

The new common certificate still needs to be properly setup in Azure certificate storage, so we can't merge this yet.

utils.groovy Outdated Show resolved Hide resolved
utils.groovy Outdated Show resolved Hide resolved
utils.groovy Outdated Show resolved Hide resolved
@alextserepov
Copy link
Contributor Author

  • Get rid of hardcoded certificate name

There is a parallel build example with configuration map here: https://github.com/tiiuae/ghaf-jenkins-pipeline/blob/PoC-parallel-eval/parallel-eval.groovy

Correct certificate / target could be configured maybe similarly in Jenkinsfile.

Thanks! I will look into it.

@alextserepov
Copy link
Contributor Author

LGTM, but do we want to implement signing with certificate / target under this PR?

We surely can. I'm more of a "small change PR" kind of guy, but well, we surely can make this world 10 times better within this PR. ;)

utils.groovy Outdated Show resolved Hide resolved
utils.groovy Outdated Show resolved Hide resolved
This commit makes the following changes:

- `nix_build` only generates signatures for images. It can
  still be called for targets that don't produce images, in which
  case the call to `sign_file` is skipped.
- Remove `sign_relpath`, instead, directly call the `sign_file` from the
  `nix_build` for image outputs.
- Remove unused return value from the `sign_file` function.
- Remove `verify_signature` function which is now unused.
- Use the ci-yubi/sign tool version already available in jenkins PATH.

Signed-off-by: Henri Rosten <[email protected]>
Output an error if signing fails, but don't fail the build. This is
needed to make it possible to run the builds from private test
environments without requiring the signing step to pass.

Signed-off-by: Henri Rosten <[email protected]>
@alextserepov alextserepov merged commit 3282630 into tiiuae:main Sep 4, 2024
1 check passed
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.

5 participants