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

feat: Update doc and code for Maven plugin #680

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions experimental/maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ The plugin wraps the [the slsa verifier](https://github.com/slsa-framework/slsa-

## Prerequisites

To use the plugin you must have Go, Java and Maven installed. It has currently only been tested on Ubuntu.
laurentsimon marked this conversation as resolved.
Show resolved Hide resolved
To use the plugin you must have Java and Maven installed. It has currently only been tested on Ubuntu.

The plugin requires that the slsa-verifier is already installed on the machine.
The plugin requires that the slsa-verifier is already installed on the machine. Follow [these steps to install it](https://github.com/slsa-framework/slsa-verifier#installation).

## Development status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
// Retrieve the slsa file of the artifact
executeMojo(
plugin(
// NOTE: https://mvnrepository.com/artifact/com.googlecode.maven-download-plugin.
groupId("com.googlecode.maven-download-plugin"),
artifactId("download-maven-plugin"),
version("1.7.0")
Expand All @@ -88,7 +89,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
element(name("groupId"), artifact.getGroupId()),
element(name("artifactId"), artifact.getArtifactId()),
element(name("version"), artifact.getVersion()),
element(name("type"), "intoto.build.slsa"),
element(name("type"), "build.slsa"),
laurentsimon marked this conversation as resolved.
Show resolved Hide resolved
element(name("classifier"), "jar")
),
executionEnvironment(
Expand Down Expand Up @@ -117,41 +118,36 @@ public void execute() throws MojoExecutionException, MojoFailureException {
)
);
} catch(MojoExecutionException e) {
getLog().info("Skipping slsa verification for " + artifactStr + ": No slsa file found.");
getLog().info("Skipping SLSA verification for " + artifactStr + ": No SLSA provenance found.");
continue;
}

// Verify slsa file
try {
// Run slsa verification on the artifact and print the result
// It will never fail the build process
// This might be prone to command-injections. TODO: Secure against that.
String arguments = "verify-artifact --provenance-path ";
arguments += "${project.build.directory}/slsa/" + artifact.getArtifactId() + "-" + artifact.getVersion() + "-jar.intoto.build.slsa ";
arguments += " --source-uri ./ ${project.build.directory}/slsa/" + artifact.getArtifactId() + "-" + artifact.getVersion() + ".jar";
executeMojo(
plugin(
groupId("org.codehaus.mojo"),
artifactId("exec-maven-plugin"),
version("3.1.0")
),
goal("exec"),
configuration(
element(name("executable"), verifierPath),
element(name("commandlineArgs"), arguments),
element(name("useMavenLogger"), "true")
),
executionEnvironment(
project,
mavenSession,
pluginManager
)
);
} catch(MojoExecutionException e) {
// TODO: Properly interpret the output based on the verification plugin.
getLog().info("Skipping slsa verification: Fail to run slsa verifier.");
return;
}
// Run slsa verification on the artifact and print the result
// It will never fail the build process
// TODO(#665): Harden against script injections.
String arguments = "verify-artifact --provenance-path ";
arguments += "${project.build.directory}/slsa/" + artifact.getArtifactId() + "-" + artifact.getVersion() + "-jar.build.slsa ";
laurentsimon marked this conversation as resolved.
Show resolved Hide resolved
arguments += " --source-uri ./ ${project.build.directory}/slsa/" + artifact.getArtifactId() + "-" + artifact.getVersion() + ".jar";
// NOTE: This command may throw an exception, indicating that provenance verification failed.