Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rekor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SafSec
rekor
Commits
dd5382c9
Commit
dd5382c9
authored
4 years ago
by
Dan Lorenc
Browse files
Options
Downloads
Patches
Plain Diff
Fix get with --uuid.
parent
3fa05602
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/cli/app/get.go
+14
-10
14 additions, 10 deletions
cmd/cli/app/get.go
cmd/cli/app/log_info.go
+4
-4
4 additions, 4 deletions
cmd/cli/app/log_info.go
tests/e2e_test.go
+4
-2
4 additions, 2 deletions
tests/e2e_test.go
with
22 additions
and
16 deletions
cmd/cli/app/get.go
+
14
−
10
View file @
dd5382c9
...
...
@@ -30,6 +30,17 @@ import (
"github.com/spf13/viper"
)
type
getCmdOutput
struct
{
Body
[]
byte
LogIndex
int
}
func
(
g
*
getCmdOutput
)
String
()
string
{
s
:=
fmt
.
Sprintf
(
"%d
\n
"
,
g
.
LogIndex
)
s
+=
fmt
.
Sprintf
(
"%s
\n
"
,
g
.
Body
)
return
s
}
// getCmd represents the get command
var
getCmd
=
&
cobra
.
Command
{
Use
:
"get"
,
...
...
@@ -60,11 +71,7 @@ var getCmd = &cobra.Command{
if
err
!=
nil
{
return
nil
,
err
}
for
k
,
entry
:=
range
resp
.
Payload
{
if
k
!=
logIndex
{
continue
}
for
_
,
entry
:=
range
resp
.
Payload
{
return
parseEntry
(
entry
)
}
}
...
...
@@ -97,15 +104,12 @@ func parseEntry(e models.LogEntryAnon) (interface{}, error) {
return
nil
,
err
}
// Now parse that back into JSON in the format "body, logindex"
obj
:=
struct
{
Body
[]
byte
LogIndex
int
}{}
obj
:=
getCmdOutput
{}
if
err
:=
json
.
Unmarshal
(
bytes
,
&
obj
);
err
!=
nil
{
return
nil
,
err
}
return
obj
,
nil
return
&
obj
,
nil
}
func
init
()
{
...
...
This diff is collapsed.
Click to expand it.
cmd/cli/app/log_info.go
+
4
−
4
View file @
dd5382c9
...
...
@@ -33,14 +33,14 @@ import (
"github.com/spf13/viper"
)
type
get
CmdOutput
struct
{
type
logInfo
CmdOutput
struct
{
TreeSize
int64
RootHash
string
}
func
(
g
*
get
CmdOutput
)
String
()
string
{
func
(
l
*
logInfo
CmdOutput
)
String
()
string
{
// Verification is always successful if we return an object.
return
fmt
.
Sprintf
(
"Verification Successful!
\n
Tree Size: %v
\n
Root Hash: %s
\n
"
,
g
.
TreeSize
,
g
.
RootHash
)
return
fmt
.
Sprintf
(
"Verification Successful!
\n
Tree Size: %v
\n
Root Hash: %s
\n
"
,
l
.
TreeSize
,
l
.
RootHash
)
}
// logInfoCmd represents the current information about the transparency log
...
...
@@ -60,7 +60,7 @@ var logInfoCmd = &cobra.Command{
}
logInfo
:=
result
.
GetPayload
()
cmdOutput
:=
&
get
CmdOutput
{
cmdOutput
:=
&
logInfo
CmdOutput
{
TreeSize
:
*
logInfo
.
TreeSize
,
RootHash
:
*
logInfo
.
RootHash
,
}
...
...
This diff is collapsed.
Click to expand it.
tests/e2e_test.go
+
4
−
2
View file @
dd5382c9
...
...
@@ -6,6 +6,7 @@ import (
"encoding/json"
"io/ioutil"
"path/filepath"
"strconv"
"strings"
"testing"
"time"
...
...
@@ -95,7 +96,7 @@ func TestGet(t *testing.T) {
splitUrl
:=
strings
.
Split
(
url
,
"/"
)
uuid
:=
splitUrl
[
len
(
splitUrl
)
-
1
]
out
=
runCli
(
t
,
"get"
,
"--uuid"
,
uuid
)
out
=
runCli
(
t
,
"get"
,
"--format=json"
,
"--uuid"
,
uuid
)
// The output here should be in JSON with this structure:
g
:=
struct
{
Body
string
...
...
@@ -104,7 +105,8 @@ func TestGet(t *testing.T) {
if
err
:=
json
.
Unmarshal
([]
byte
(
out
),
&
g
);
err
!=
nil
{
t
.
Error
(
err
)
}
// TODO: check the actual data in here.
// Get it with the logindex as well
runCli
(
t
,
"get"
,
"--format=json"
,
"--log-index"
,
strconv
.
Itoa
(
g
.
LogIndex
))
// check index via the file and public key to ensure that the index has updated correctly
out
=
runCli
(
t
,
"search"
,
"--artifact"
,
artifactPath
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment