Skip to content

Commit 38de185

Browse files
committed
Integrate sigstore/sigstore-maven-plugin into repo
- Move sigstore-maven-plugin in sigstore/sigstore-java - Make it a gradle module (and build with gradle :o! sorry) Signed-off-by: Appu Goundan <[email protected]>
1 parent 97c9e8b commit 38de185

File tree

16 files changed

+667
-39
lines changed

16 files changed

+667
-39
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import org.gradle.api.attributes.Bundling
2+
import org.gradle.api.attributes.Category
3+
import org.gradle.kotlin.dsl.*
4+
import java.io.File
5+
6+
plugins {
7+
java
8+
}
9+
10+
val sigstoreJavaRuntime by configurations.creating {
11+
description = "declares dependencies that will be useful for testing purposes"
12+
isCanBeConsumed = false
13+
isCanBeResolved = false
14+
}
15+
16+
val sigstoreJavaTestClasspath by configurations.creating {
17+
description = "sigstore-java in local repository for testing purposes"
18+
isCanBeConsumed = false
19+
isCanBeResolved = true
20+
extendsFrom(sigstoreJavaRuntime)
21+
attributes {
22+
attribute(Category.CATEGORY_ATTRIBUTE, objects.named("maven-repository"))
23+
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
24+
}
25+
}
26+
27+
tasks.test {
28+
dependsOn(sigstoreJavaTestClasspath)
29+
systemProperty("sigstore.test.current.version", version)
30+
val projectDir = layout.projectDirectory.asFile
31+
// This adds paths to the local repositories that contain currently-built sigstore-java
32+
// It enables testing both "sigstore-java from Central" and "sigstore-java build locally" in the plugin tests
33+
jvmArgumentProviders.add(
34+
// Gradle does not support Provider for systemProperties yet, see https://github.com/gradle/gradle/issues/12247
35+
CommandLineArgumentProvider {
36+
listOf(
37+
"-Dsigstore.test.local.maven.repo=" +
38+
sigstoreJavaTestClasspath.joinToString(File.pathSeparator) {
39+
it.toRelativeString(projectDir)
40+
},
41+
)
42+
}
43+
)
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import org.gradle.api.attributes.Bundling
2+
import org.gradle.api.attributes.Category
3+
import org.gradle.kotlin.dsl.*
4+
import java.io.File
5+
6+
plugins {
7+
java
8+
}
9+
10+
val sigstoreMavenPluginRuntime by configurations.creating {
11+
description = "declares dependencies that will be useful for testing purposes"
12+
isCanBeConsumed = false
13+
isCanBeResolved = false
14+
}
15+
16+
val sigstoreMavenPluginTestClasspath by configurations.creating {
17+
description = "sigstore-maven-plugin in local repository for testing purposes"
18+
isCanBeConsumed = false
19+
isCanBeResolved = true
20+
extendsFrom(sigstoreMavenPluginRuntime)
21+
attributes {
22+
attribute(Category.CATEGORY_ATTRIBUTE, objects.named("maven-repository"))
23+
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
24+
}
25+
}
26+
27+
tasks.test {
28+
dependsOn(sigstoreMavenPluginTestClasspath)
29+
systemProperty("sigstore.test.current.maven.plugin.version", version)
30+
val projectDir = layout.projectDirectory.asFile
31+
// This adds paths to the local repositories that contain currently-built sigstore-maven-plugin
32+
jvmArgumentProviders.add(
33+
// Gradle does not support Provider for systemProperties yet, see https://github.com/gradle/gradle/issues/12247
34+
CommandLineArgumentProvider {
35+
listOf(
36+
"-Dsigstore.test.local.maven.plugin.repo=" +
37+
sigstoreMavenPluginTestClasspath.joinToString(File.pathSeparator) {
38+
it.toRelativeString(projectDir)
39+
},
40+
)
41+
}
42+
)
43+
}

build-logic/publishing/src/main/kotlin/build-logic.kotlin-dsl-published-gradle-plugin.gradle.kts

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,5 @@ plugins {
66
id("build-logic.reproducible-builds")
77
id("build-logic.dokka-javadoc")
88
id("build-logic.publish-to-central")
9-
}
10-
11-
val sigstoreJavaRuntime by configurations.creating {
12-
description = "declares dependencies that will be useful for testing purposes"
13-
isCanBeConsumed = false
14-
isCanBeResolved = false
15-
}
16-
17-
val sigstoreJavaTestClasspath by configurations.creating {
18-
description = "sigstore-java in local repository for testing purposes"
19-
isCanBeConsumed = false
20-
isCanBeResolved = true
21-
extendsFrom(sigstoreJavaRuntime)
22-
attributes {
23-
attribute(Category.CATEGORY_ATTRIBUTE, objects.named("maven-repository"))
24-
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
25-
}
26-
}
27-
28-
tasks.test {
29-
dependsOn(sigstoreJavaTestClasspath)
30-
systemProperty("sigstore.test.current.version", version)
31-
val projectDir = layout.projectDirectory.asFile
32-
// This adds paths to the local repositories that contain currently-built sigstore-java
33-
// It enables testing both "sigstore-java from Central" and "sigstore-java build locally" in the plugin tests
34-
jvmArgumentProviders.add(
35-
// Gradle does not support Provider for systemProperties yet, see https://github.com/gradle/gradle/issues/12247
36-
CommandLineArgumentProvider {
37-
listOf(
38-
"-Dsigstore.test.local.maven.repo=" +
39-
sigstoreJavaTestClasspath.joinToString(File.pathSeparator) {
40-
it.toRelativeString(projectDir)
41-
}
42-
)
43-
}
44-
)
9+
id("build-logic.depends-on-local-sigstore-java-repo")
4510
}

build-logic/publishing/src/main/kotlin/build-logic.publish-to-tmp-maven-repo.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.kotlin.dsl.registering
2+
13
plugins {
24
id("java-library")
35
id("maven-publish")

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ include("sigstore-gradle:sigstore-gradle-sign-base-plugin")
88
include("sigstore-gradle:sigstore-gradle-sign-plugin")
99
include("sigstore-testkit")
1010
include("sigstore-cli")
11+
include("sigstore-maven-plugin")
1112

1213
include("fuzzing")

sigstore-java/src/main/java/dev/sigstore/KeylessSigner.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
import java.util.List;
6565
import java.util.Map;
6666
import java.util.concurrent.locks.ReentrantReadWriteLock;
67-
import org.checkerframework.checker.nullness.qual.Nullable;
67+
import javax.annotation.Nullable;
6868

6969
/**
7070
* A full sigstore keyless signing flow.
@@ -93,14 +93,16 @@ public class KeylessSigner implements AutoCloseable {
9393

9494
/** The code signing certificate from Fulcio. */
9595
@GuardedBy("lock")
96-
private @Nullable CertPath signingCert;
96+
@Nullable
97+
private CertPath signingCert;
9798

9899
/**
99100
* Representation {@link #signingCert} in PEM bytes format. This is used to avoid serializing the
100101
* certificate for each use.
101102
*/
102103
@GuardedBy("lock")
103-
private byte @Nullable [] signingCertPemBytes;
104+
@Nullable
105+
private byte[] signingCertPemBytes;
104106

105107
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
106108

sigstore-java/src/main/java/dev/sigstore/encryption/certificates/Certificates.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.StringWriter;
2323
import java.nio.charset.StandardCharsets;
2424
import java.security.cert.*;
25+
import java.time.temporal.ChronoUnit;
2526
import java.util.ArrayList;
2627
import java.util.Collections;
2728
import java.util.List;
@@ -208,4 +209,9 @@ public static boolean isSelfSigned(CertPath certPath) {
208209
public static X509Certificate getLeaf(CertPath certPath) {
209210
return (X509Certificate) certPath.getCertificates().get(0);
210211
}
212+
213+
public static long validity(X509Certificate certificate, ChronoUnit unit) {
214+
return unit.between(
215+
certificate.getNotAfter().toInstant(), certificate.getNotBefore().toInstant());
216+
}
211217
}

sigstore-maven-plugin/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.vscode
2+
.factorypath
3+
.project
4+
.classpath
5+
.settings/
6+
*.iml
7+
*.ipr
8+
.idea
9+
*.class
10+
*.jar
11+
target/
12+
pom.xml.tag
13+
pom.xml.releaseBackup
14+
pom.xml.versionsBackup
15+
pom.xml.next
16+
pom.xml.bak
17+
release.properties
18+
dependency-reduced-pom.xml
19+
buildNumber.properties
20+
.mvn/timing.properties
21+
.mvn/wrapper/maven-wrapper.jar
22+
.apt_generated/
23+
.apt_generated_tests/
24+
bin/

sigstore-maven-plugin/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
sigstore-maven-plugin
2+
=====================
3+
4+
[![Maven Central](https://img.shields.io/maven-central/v/dev.sigstore/sigstore-maven-plugin.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/dev.sigstore/sigstore-maven-plugin)
5+
6+
This is a Maven plugin that can be used to use the "keyless" signing paradigm supported by Sigstore.
7+
This plugin is still in early phases, then has known limitations described below.
8+
9+
sign
10+
----
11+
12+
```xml
13+
<plugin>
14+
<groupId>dev.sigstore</groupId>
15+
<artifactId>sigstore-maven-plugin</artifactId>
16+
<version>0.4.0</version>
17+
<executions>
18+
<execution>
19+
<id>sign</id>
20+
<goals>
21+
<goal>sign</goal>
22+
</goals>
23+
</execution>
24+
</executions>
25+
</plugin>
26+
```
27+
28+
Notes:
29+
30+
- GPG: Maven Central publication rules require GPG signing each files: to avoid GPG signing of `.sigstore.json` files, just use version 3.1.0 minimum of [maven-gpg-plugin](https://maven.apache.org/plugins/maven-gpg-plugin/).
31+
- `.md5`/`.sha1`: to avoid unneeded checksum files for `.sigstore.java` files, use Maven 3.9.2 minimum or create `.mvn/maven.config` file containing `-Daether.checksums.omitChecksumsForExtensions=.asc,.sigstore.java`
32+
33+
Known limitations:
34+
35+
- Maven multi-module build: each module will require an OIDC authentication,
36+
- 10 minutes signing session: if a build takes more than 10 minutes, a new OIDC authentication will be required each 10 minutes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
plugins {
2+
id("build-logic.java-published-library")
3+
id("build-logic.test-junit5")
4+
id("build-logic.depends-on-local-sigstore-java-repo")
5+
id("build-logic.depends-on-local-sigstore-maven-plugin-repo")
6+
id("de.benediktritter.maven-plugin-development") version "0.4.3"
7+
}
8+
9+
dependencies {
10+
compileOnly("org.apache.maven:maven-plugin-api:3.9.8")
11+
compileOnly("org.apache.maven:maven-core:3.9.8")
12+
compileOnly("org.apache.maven:maven-core:3.9.8")
13+
compileOnly("org.apache.maven.plugin-tools:maven-plugin-annotations:3.13.1")
14+
15+
implementation(project(":sigstore-java"))
16+
implementation("org.bouncycastle:bcutil-jdk18on:1.78.1")
17+
implementation("org.apache.maven.plugins:maven-gpg-plugin:3.1.0")
18+
19+
testImplementation("org.apache.maven.shared:maven-verifier:1.8.0")
20+
21+
testImplementation(project(":sigstore-testkit"))
22+
23+
sigstoreJavaRuntime(project(":sigstore-java")) {
24+
because("Test code needs access locally-built sigstore-java as a Maven repository")
25+
}
26+
sigstoreMavenPluginRuntime(project(":sigstore-maven-plugin")) {
27+
because("Test code needs access locally-built sigstore-java as a Maven repository")
28+
}
29+
}

0 commit comments

Comments
 (0)