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 Grafeas transport #10

Merged
merged 16 commits into from
May 14, 2020

Conversation

adityasaky
Copy link
Collaborator

@adityasaky adityasaky commented Jan 29, 2020

This PR introduces Grafeas as a transport for the in-toto jenkins plugin.

For a grafeas server located at https://grafeas.example.com/, for some project example_project, the in-toto links generated by the plugin can be sent using the following transport:

grafeas+https://grafeas.example.com/v1beta1/projects/example_project/occurrences?noteName=<note_occurrence_corresponds_to>&resourceUri=<resource_id>

Note, this plugin depends on the changes introduced to the Grafeas server in grafeas/grafeas#391. Any further changes there can affect the plugin and therefore this must only be merged when that PR is merged.

@adityasaky
Copy link
Collaborator Author

I was able to use this transport to dispatch grafeas occurrences to a test grafeas server from a test jenkins instance. However, more clean up is required.

@adityasaky
Copy link
Collaborator Author

in-toto is now officially in Grafeas (grafeas/grafeas#391)! The implementation of in-toto within Grafeas requires some minor modifications to the in-toto document format, and a translator of some sort will need to be built and integrated with the changes proposed in this PR.

@adityasaky adityasaky force-pushed the add-grafeas-transport branch from 06e780f to c95c2f7 Compare April 17, 2020 18:23
@adityasaky
Copy link
Collaborator Author

adityasaky commented Apr 17, 2020

Okay! The conversion is mostly working, bar a couple of pending FIXMEs for resource URIs.

For reference, here's the demo Jenkins pipeline script:

pipeline {
    agent any
    stages {
        stage('Beta') {
            //agent { label 'worker 1' }
            steps {
                // Clone package
                in_toto_wrap(['stepName': 'clone',
                'keyPath': '/keys/bob',
                'transport': 'grafeas+https://<GRAFEAS>/v1beta1/projects/example_project/occurrences?noteName=projects/example_project/notes/clone&resourceUri=demoProjectJekyll']){
                    git 'https://github.com/in-toto/demo-project-jekyll'
                }
                
                // Jekyll build
                in_toto_wrap(['stepName': 'jekyll-build',
                'keyPath': '/keys/carl',
                'transport': 'grafeas+https://<GRAFEAS>/v1beta1/projects/example_project/occurrences?noteName=projects/example_project/notes/jekyllBuild&resourceUri=demoProjectJekyll']){
                    sh label: 'jekyll-build', script: 'jekyll build'
                }

                // HTML Linter
                in_toto_wrap(['stepName': 'html-linter',
                'keyPath': '/keys/carl',
                'transport': 'grafeas+https://<GRAFEAS>/v1beta1/projects/example_project/occurrences?noteName=projects/example_project/notes/htmlLinter&resourceUri=demoProjectJekyll']){
                    sh label: 'html-linter', script: 'htmlproofer _site'
                }

                // Docker build
                in_toto_wrap(['stepName': 'docker-build',
                'keyPath': '/keys/carl',
                'transport': 'grafeas+https://<GRAFEAS>/v1beta1/projects/example_project/occurrences?noteName=projects/example_project/notes/dockerBuild&resourceUri=demoProjectJekyll']){
                    sh label: 'docker-build', script: 'docker build --iidfile docker_container_id -t jekyll-demo .'
                }
            }
        }
    }
}

This relies on in-toto-java with in-toto/in-toto-java#19.

Copy link
Contributor

@SantiagoTorres SantiagoTorres left a comment

Choose a reason for hiding this comment

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

I think there are some minor naming nits, but it's looking good!

Signed-off-by: Aditya Sirish <[email protected]>
@adityasaky adityasaky force-pushed the add-grafeas-transport branch from 1abc99a to 16a505b Compare May 12, 2020 21:17
@SantiagoTorres
Copy link
Contributor

Thank you for your updates! I think there is just one outstanding comment and figure out why the build is failing and we can merge...

@adityasaky
Copy link
Collaborator Author

adityasaky commented May 12, 2020

The build seems to fail here: https://ci.jenkins.io/blue/organizations/jenkins/Plugins%2Fin-toto-plugin/detail/PR-10/12/pipeline#log-146

Which means it's not seeing the changes at in-toto/in-toto-java#19. Investigating...

Signed-off-by: Aditya Sirish <[email protected]>
@adityasaky adityasaky force-pushed the add-grafeas-transport branch 4 times, most recently from e3dbb28 to 95b4923 Compare May 13, 2020 21:24
@adityasaky adityasaky requested a review from SantiagoTorres May 13, 2020 21:25
@adityasaky
Copy link
Collaborator Author

Resolved! It's also worth noting that I was able to successfully reverse the grafeas in-toto format to the regular in-toto serialization, and verify the signature. :)

@adityasaky adityasaky force-pushed the add-grafeas-transport branch from 95b4923 to d00c3af Compare May 14, 2020 15:03
Copy link
Contributor

@SantiagoTorres SantiagoTorres left a comment

Choose a reason for hiding this comment

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

I think we are almost there. I just have an overarching question.

Signed-off-by: Aditya Sirish <[email protected]>
@SantiagoTorres
Copy link
Contributor

awesome, LGTM. Merging!

@SantiagoTorres SantiagoTorres merged commit 4cc1cdf into jenkinsci:master May 14, 2020
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