Skip to content

Commit d52685f

Browse files
author
dlorenc
authored
Add a flag to specify an artifact by hash. (sigstore#285)
This is required when uploading jars by URL. Signed-off-by: Dan Lorenc <dlorenc@google.com>
1 parent 42aa2b0 commit d52685f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cmd/rekor-cli/app/pflags.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func addArtifactPFlags(cmd *cobra.Command) error {
7979
cmd.Flags().Var(&fileOrURLFlag{}, "public-key", "path or URL to public key file")
8080

8181
cmd.Flags().Var(&fileOrURLFlag{}, "artifact", "path or URL to artifact file")
82+
cmd.Flags().Var(&uuidFlag{}, "artifact-hash", "hex encoded SHA256 hash of artifact (when using URL)")
8283

8384
cmd.Flags().Var(&fileOrURLFlag{}, "entry", "path or URL to pre-formatted entry file")
8485

@@ -182,6 +183,10 @@ func CreateJarFromPFlags() (models.ProposedEntry, error) {
182183
dataURL, err := url.Parse(artifact)
183184
if err == nil && dataURL.IsAbs() {
184185
re.JARModel.Archive.URL = strfmt.URI(artifact)
186+
re.JARModel.Archive.Hash = &models.JarV001SchemaArchiveHash{
187+
Algorithm: swag.String(models.JarV001SchemaArchiveHashAlgorithmSha256),
188+
Value: swag.String(viper.GetString("artifact-hash")),
189+
}
185190
} else {
186191
artifactBytes, err := ioutil.ReadFile(filepath.Clean(artifact))
187192
if err != nil {

tests/e2e_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ func TestJAR(t *testing.T) {
254254
outputContains(t, out, "Created entry at")
255255
out = runCli(t, "upload", "--artifact", artifactPath, "--type", "jar")
256256
outputContains(t, out, "Entry already exists")
257+
}
257258

259+
func TestJARURL(t *testing.T) {
260+
out := runCli(t, "upload", "--artifact", "https://get.jenkins.io/war-stable/2.277.3/jenkins.war", "--type", "jar", "--artifact-hash=3e22c7e8cd7c8ee1e92cbaa8d0d303a7b53e07bc2a152ddc66f8ce55caea91ab")
261+
outputContains(t, out, "Created entry at")
258262
}
259263

260264
func TestX509(t *testing.T) {

0 commit comments

Comments
 (0)