-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Appu Goundan <[email protected]>
- Loading branch information
1 parent
8e91247
commit 3b57066
Showing
9 changed files
with
349 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Conformance Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
workflow_dispatch: | ||
# TODO: add cron | ||
|
||
jobs: | ||
conformance: | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
java-version: [11, 17] | ||
fail-fast: false | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | ||
|
||
- name: Set up JDK ${{ matrix.java-version }} | ||
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 | ||
with: | ||
java-version: ${{ matrix.java-version }} | ||
distribution: 'temurin' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0 | ||
|
||
- name: Build tuf cli | ||
run: ./gradlew :tuf-cli:build | ||
|
||
- name: Unpack tuf distribution | ||
run: tar -xvf ${{ github.workspace }}/tuf-cli/build/distributions/tuf-cli-*.tar --strip-components 1 | ||
|
||
- uses: theupdateframework/tuf-conformance@v2 | ||
with: | ||
entrypoint: ${{ github.workspace }}/bin/tuf-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Sigstore-Java Tuf CLI | ||
|
||
Used for conformance testing and internal processes. This is not meant for public consumption, we will not support | ||
any usecase that uses this. | ||
|
||
## Usage | ||
|
||
### Help | ||
``` | ||
./gradlew tuf-cli:run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
plugins { | ||
id("build-logic.java") | ||
id("application") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(project(":sigstore-java")) | ||
implementation("info.picocli:picocli:4.7.6") | ||
implementation("com.google.guava:guava:33.3.1-jre") | ||
|
||
implementation(platform("com.google.oauth-client:google-oauth-client-bom:1.36.0")) | ||
implementation("com.google.oauth-client:google-oauth-client") | ||
|
||
annotationProcessor("info.picocli:picocli-codegen:4.7.6") | ||
} | ||
|
||
tasks.compileJava { | ||
options.compilerArgs.add("-Aproject=${project.group}/${project.name}") | ||
} | ||
|
||
application { | ||
mainClass.set("dev.sigstore.tuf.cli.Tuf") | ||
} | ||
tasks.run.configure { | ||
workingDir = rootProject.projectDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2024 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore.tuf.cli; | ||
|
||
import dev.sigstore.tuf.FileSystemTufStore; | ||
import dev.sigstore.tuf.HttpFetcher; | ||
import dev.sigstore.tuf.MetaFetcher; | ||
import dev.sigstore.tuf.PassthroughCacheMetaStore; | ||
import dev.sigstore.tuf.RootProvider; | ||
import dev.sigstore.tuf.TrustedMetaStore; | ||
import dev.sigstore.tuf.Updater; | ||
import java.util.concurrent.Callable; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
@Command(name = "download", description = "download targets from a remote location") | ||
public class Download implements Callable<Integer> { | ||
|
||
@ParentCommand private Tuf tufCommand; | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
var fsStore = FileSystemTufStore.newFileSystemStore(tufCommand.metadataDir); | ||
var tuf = | ||
Updater.builder() | ||
.setTrustedMetaStore( | ||
TrustedMetaStore.newTrustedMetaStore( | ||
PassthroughCacheMetaStore.newPassthroughMetaCache(fsStore))) | ||
.setTrustedRootPath(RootProvider.fromFile(tufCommand.metadataDir.resolve("root.json"))) | ||
.setMetaFetcher(MetaFetcher.newFetcher(HttpFetcher.newFetcher(tufCommand.metadataUrl))) | ||
.setTargetFetcher(HttpFetcher.newFetcher(tufCommand.targetBaseUrl)) | ||
.setTargetStore(fsStore) | ||
.build(); | ||
tuf.downloadTarget(tufCommand.targetName); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2024 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore.tuf.cli; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.concurrent.Callable; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Parameters; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
@Command(name = "init", description = "initialize a local tuf repo") | ||
public class Init implements Callable<Integer> { | ||
|
||
@Parameters(arity = "1", paramLabel = "<TRUSTED_ROOT>") | ||
Path trustedRoot; | ||
|
||
@ParentCommand private Tuf tufCommand; | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
if (!Files.isRegularFile(trustedRoot)) { | ||
throw new IllegalArgumentException(trustedRoot + " is not a regular file"); | ||
} | ||
if (Files.exists(tufCommand.metadataDir)) { | ||
if (!Files.isDirectory(tufCommand.metadataDir)) { | ||
throw new IllegalArgumentException(tufCommand.metadataDir + " is not a directory"); | ||
} | ||
} else { | ||
Files.createDirectories(tufCommand.metadataDir); | ||
} | ||
|
||
Files.copy(trustedRoot, tufCommand.metadataDir.resolve("root.json")); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2024 The Sigstore Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.sigstore.tuf.cli; | ||
|
||
import dev.sigstore.tuf.FileSystemTufStore; | ||
import dev.sigstore.tuf.HttpFetcher; | ||
import dev.sigstore.tuf.MetaFetcher; | ||
import dev.sigstore.tuf.PassthroughCacheMetaStore; | ||
import dev.sigstore.tuf.RootProvider; | ||
import dev.sigstore.tuf.TrustedMetaStore; | ||
import dev.sigstore.tuf.Updater; | ||
import java.util.concurrent.Callable; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.ParentCommand; | ||
|
||
@Command(name = "refresh", description = "update local tuf metadata from the repository") | ||
public class Refresh implements Callable<Integer> { | ||
|
||
@ParentCommand private Tuf tufCommand; | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
var fsStore = FileSystemTufStore.newFileSystemStore(tufCommand.metadataDir); | ||
var tuf = | ||
Updater.builder() | ||
.setTrustedMetaStore( | ||
TrustedMetaStore.newTrustedMetaStore( | ||
PassthroughCacheMetaStore.newPassthroughMetaCache(fsStore))) | ||
.setTrustedRootPath(RootProvider.fromFile(tufCommand.metadataDir.resolve("root.json"))) | ||
.setMetaFetcher(MetaFetcher.newFetcher(HttpFetcher.newFetcher(tufCommand.metadataUrl))) | ||
.build(); | ||
tuf.update(); | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.