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

chore: update docs for verifier version #1825

Merged
merged 16 commits into from
Mar 21, 2023
Merged

Conversation

asraa
Copy link
Collaborator

@asraa asraa commented Mar 14, 2023

See script slsa-framework/slsa-verifier#530 for SHA verification

Signed-off-by: Asra Ali <asraa@google.com>
@asraa asraa enabled auto-merge (squash) March 14, 2023 20:33
@asraa
Copy link
Collaborator Author

asraa commented Mar 16, 2023

Why is it complaining about --branch when that's changed in this PR?

verifier hash verification has passed
Usage:
  slsa-verifier [flags]
  slsa-verifier [command]

Available Commands:
  completion         Generate the autocompletion script for the specified shell
  help               Help about any command
  verify-artifact    Verifies SLSA provenance on artifact blobs given as arguments (assuming same provenance)
  verify-image       Verifies SLSA provenance on a container image
  verify-npm-package Verifies SLSA provenance for an npm package tarball [experimental]
  version            Prints the version

Flags:
  -h, --help   help for slsa-verifier

Use "slsa-verifier [command] --help" for more information about a command.

unknown flag: --branch

@ianlewis
Copy link
Member

Why is it complaining about --branch when that's changed in this PR?

It looks like generate-builder is checking out the source code from refs/tags/v1.2.2.

And we run various actions and scripts from that checkout.

run: ./__BUILDER_CHECKOUT_DIR__/.github/actions/generate-builder/generate-builder.sh

I'm actually not sure what the right thing to do is here but it feels wrong to me that we are running actions and scripts from the checkout. We should just be using the source code from the checkout to build the builder (I think?).

@asraa
Copy link
Collaborator Author

asraa commented Mar 17, 2023

It looks like generate-builder is checking out the source code from refs/tags/v1.2.2.

Hmm I assumed that this would checkout the source code from the action reference like here

uses: slsa-framework/slsa-github-generator/.github/actions/generate-builder@main

But yes, it appears that its pulling v1.2.2 for the action -- when in realtime, we are usually using detect-env.

and then pull the builder from v1.2.2 -- this is the one that downloads from the release and uses slsa verifier.

I think we should split generate-builders inputs into source-repository, source-ref, and builder-repository, builder-ref.

Otherwise, we have no way of updating this TBH.

I think in production those inputs will likely be the same, but for testing, we can't separate this out correctly.

@asraa
Copy link
Collaborator Author

asraa commented Mar 17, 2023

Updated to include an optional builder-ref. Otherwise, this test was not really acting as a presubmit. It was always checking out v1.2.2's source.

asraa added 3 commits March 17, 2023 10:54
Signed-off-by: Asra Ali <asraa@google.com>
…a-github-generator repo

Signed-off-by: Asra Ali <asraa@google.com>
Signed-off-by: Asra Ali <asraa@google.com>
@asraa
Copy link
Collaborator Author

asraa commented Mar 17, 2023

Blocked by #1836

asraa added a commit that referenced this pull request Mar 20, 2023
This fixes the behavior of detect-workflow-js for PRs against
slsa-github-generator, where the ref should not be the refs/pulls/ but
rather the head_sha of the PR.

Adds a test.

This wasn't detected before, and then in PR
#1825 I had
to add an explicit `git checkout` when compiling the builder from source
at the particular builder-ref, which comes from the detect-workflow
action. See this run:
https://github.com/slsa-framework/slsa-github-generator/actions/runs/4449301907/jobs/7813310086

Before this, secure-builder-checkout was OK checkout out at a PR ref - I
think it was checkout out the merge PR.

---------

Signed-off-by: Asra Ali <asraa@google.com>
@asraa asraa disabled auto-merge March 20, 2023 18:59
asraa added 3 commits March 20, 2023 14:14
…changed action

Signed-off-by: Asra Ali <asraa@google.com>
Signed-off-by: Asra Ali <asraa@google.com>
Signed-off-by: Asra Ali <asraa@google.com>

COMPILE_BUILDER: "${{ inputs.compile-builder }}"
BUILDER_REF: "${{ inputs.ref }}"
BUILDER_REF: "${{ inputs.builder-ref || inputs.ref }}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment why we need the ||. By default we take the builder-ref but if empty we take the ref, why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is only relevant for tests - where the builder-ref may be different than the source-ref.

When testing this, we need to use a builder-ref that already exists, while the source-ref indicates what source code reference to use for the generate-builder.sh code.

When we are not testing, it is OK to use the generate-builder.sh code for that builder we want to checkout - they will be the same.

In pre-submit, we have no way of testing the current generate-builder.sh at main with no compile. Because we don't have a release at main.

Signed-off-by: Asra Ali <asraa@google.com>
@asraa asraa requested a review from laurentsimon March 21, 2023 17:06
Signed-off-by: Asra Ali <asraa@google.com>
asraa added 2 commits March 21, 2023 12:23
Signed-off-by: Asra Ali <asraa@google.com>
@asraa asraa merged commit 18af045 into slsa-framework:main Mar 21, 2023
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.

3 participants