repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
theupdateframework/notary
client/changelist/changelist.go
Add
func (cl *memChangelist) Add(c Change) error { cl.changes = append(cl.changes, c) return nil }
go
func (cl *memChangelist) Add(c Change) error { cl.changes = append(cl.changes, c) return nil }
[ "func", "(", "cl", "*", "memChangelist", ")", "Add", "(", "c", "Change", ")", "error", "{", "cl", ".", "changes", "=", "append", "(", "cl", ".", "changes", ",", "c", ")", "\n", "return", "nil", "\n", "}" ]
// Add adds a change to the in-memory change list
[ "Add", "adds", "a", "change", "to", "the", "in", "-", "memory", "change", "list" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/changelist.go#L19-L22
train
theupdateframework/notary
client/changelist/changelist.go
Clear
func (cl *memChangelist) Clear(archive string) error { // appending to a nil list initializes it. cl.changes = nil return nil }
go
func (cl *memChangelist) Clear(archive string) error { // appending to a nil list initializes it. cl.changes = nil return nil }
[ "func", "(", "cl", "*", "memChangelist", ")", "Clear", "(", "archive", "string", ")", "error", "{", "// appending to a nil list initializes it.", "cl", ".", "changes", "=", "nil", "\n", "return", "nil", "\n", "}" ]
// Clear empties the changelist file.
[ "Clear", "empties", "the", "changelist", "file", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/changelist.go#L48-L52
train
theupdateframework/notary
client/changelist/changelist.go
Next
func (m *MemChangeListIterator) Next() (item Change, err error) { if m.index >= len(m.collection) { return nil, IteratorBoundsError(m.index) } item = m.collection[m.index] m.index++ return item, err }
go
func (m *MemChangeListIterator) Next() (item Change, err error) { if m.index >= len(m.collection) { return nil, IteratorBoundsError(m.index) } item = m.collection[m.index] m.index++ return item, err }
[ "func", "(", "m", "*", "MemChangeListIterator", ")", "Next", "(", ")", "(", "item", "Change", ",", "err", "error", ")", "{", "if", "m", ".", "index", ">=", "len", "(", "m", ".", "collection", ")", "{", "return", "nil", ",", "IteratorBoundsError", "("...
// Next returns the next Change
[ "Next", "returns", "the", "next", "Change" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/changelist.go#L70-L77
train
theupdateframework/notary
client/changelist/file_changelist.go
NewFileChangelist
func NewFileChangelist(dir string) (*FileChangelist, error) { logrus.Debug("Making dir path: ", dir) err := os.MkdirAll(dir, 0700) if err != nil { return nil, err } return &FileChangelist{dir: dir}, nil }
go
func NewFileChangelist(dir string) (*FileChangelist, error) { logrus.Debug("Making dir path: ", dir) err := os.MkdirAll(dir, 0700) if err != nil { return nil, err } return &FileChangelist{dir: dir}, nil }
[ "func", "NewFileChangelist", "(", "dir", "string", ")", "(", "*", "FileChangelist", ",", "error", ")", "{", "logrus", ".", "Debug", "(", "\"", "\"", ",", "dir", ")", "\n", "err", ":=", "os", ".", "MkdirAll", "(", "dir", ",", "0700", ")", "\n", "if"...
// NewFileChangelist is a convenience method for returning FileChangeLists
[ "NewFileChangelist", "is", "a", "convenience", "method", "for", "returning", "FileChangeLists" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L22-L29
train
theupdateframework/notary
client/changelist/file_changelist.go
getFileNames
func getFileNames(dirName string) ([]os.FileInfo, error) { var dirListing, fileInfos []os.FileInfo dir, err := os.Open(dirName) if err != nil { return fileInfos, err } defer dir.Close() dirListing, err = dir.Readdir(0) if err != nil { return fileInfos, err } for _, f := range dirListing { if f.IsDir() { ...
go
func getFileNames(dirName string) ([]os.FileInfo, error) { var dirListing, fileInfos []os.FileInfo dir, err := os.Open(dirName) if err != nil { return fileInfos, err } defer dir.Close() dirListing, err = dir.Readdir(0) if err != nil { return fileInfos, err } for _, f := range dirListing { if f.IsDir() { ...
[ "func", "getFileNames", "(", "dirName", "string", ")", "(", "[", "]", "os", ".", "FileInfo", ",", "error", ")", "{", "var", "dirListing", ",", "fileInfos", "[", "]", "os", ".", "FileInfo", "\n", "dir", ",", "err", ":=", "os", ".", "Open", "(", "dir...
// getFileNames reads directory, filtering out child directories
[ "getFileNames", "reads", "directory", "filtering", "out", "child", "directories" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L32-L51
train
theupdateframework/notary
client/changelist/file_changelist.go
unmarshalFile
func unmarshalFile(dirname string, f os.FileInfo) (*TUFChange, error) { c := &TUFChange{} raw, err := ioutil.ReadFile(filepath.Join(dirname, f.Name())) if err != nil { return c, err } err = json.Unmarshal(raw, c) if err != nil { return c, err } return c, nil }
go
func unmarshalFile(dirname string, f os.FileInfo) (*TUFChange, error) { c := &TUFChange{} raw, err := ioutil.ReadFile(filepath.Join(dirname, f.Name())) if err != nil { return c, err } err = json.Unmarshal(raw, c) if err != nil { return c, err } return c, nil }
[ "func", "unmarshalFile", "(", "dirname", "string", ",", "f", "os", ".", "FileInfo", ")", "(", "*", "TUFChange", ",", "error", ")", "{", "c", ":=", "&", "TUFChange", "{", "}", "\n", "raw", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filepath", ...
// Read a JSON formatted file from disk; convert to TUFChange struct
[ "Read", "a", "JSON", "formatted", "file", "from", "disk", ";", "convert", "to", "TUFChange", "struct" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L54-L65
train
theupdateframework/notary
client/changelist/file_changelist.go
List
func (cl FileChangelist) List() []Change { var changes []Change fileInfos, err := getFileNames(cl.dir) if err != nil { return changes } for _, f := range fileInfos { c, err := unmarshalFile(cl.dir, f) if err != nil { logrus.Warn(err.Error()) continue } changes = append(changes, c) } return change...
go
func (cl FileChangelist) List() []Change { var changes []Change fileInfos, err := getFileNames(cl.dir) if err != nil { return changes } for _, f := range fileInfos { c, err := unmarshalFile(cl.dir, f) if err != nil { logrus.Warn(err.Error()) continue } changes = append(changes, c) } return change...
[ "func", "(", "cl", "FileChangelist", ")", "List", "(", ")", "[", "]", "Change", "{", "var", "changes", "[", "]", "Change", "\n", "fileInfos", ",", "err", ":=", "getFileNames", "(", "cl", ".", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// List returns a list of sorted changes
[ "List", "returns", "a", "list", "of", "sorted", "changes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L68-L83
train
theupdateframework/notary
client/changelist/file_changelist.go
Add
func (cl FileChangelist) Add(c Change) error { cJSON, err := json.Marshal(c) if err != nil { return err } filename := fmt.Sprintf("%020d_%s.change", time.Now().UnixNano(), uuid.Generate()) return ioutil.WriteFile(filepath.Join(cl.dir, filename), cJSON, 0644) }
go
func (cl FileChangelist) Add(c Change) error { cJSON, err := json.Marshal(c) if err != nil { return err } filename := fmt.Sprintf("%020d_%s.change", time.Now().UnixNano(), uuid.Generate()) return ioutil.WriteFile(filepath.Join(cl.dir, filename), cJSON, 0644) }
[ "func", "(", "cl", "FileChangelist", ")", "Add", "(", "c", "Change", ")", "error", "{", "cJSON", ",", "err", ":=", "json", ".", "Marshal", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "filename", ":=", "fm...
// Add adds a change to the file change list
[ "Add", "adds", "a", "change", "to", "the", "file", "change", "list" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L86-L93
train
theupdateframework/notary
client/changelist/file_changelist.go
Clear
func (cl FileChangelist) Clear(archive string) error { dir, err := os.Open(cl.dir) if err != nil { return err } defer dir.Close() files, err := dir.Readdir(0) if err != nil { return err } for _, f := range files { os.Remove(filepath.Join(cl.dir, f.Name())) } return nil }
go
func (cl FileChangelist) Clear(archive string) error { dir, err := os.Open(cl.dir) if err != nil { return err } defer dir.Close() files, err := dir.Readdir(0) if err != nil { return err } for _, f := range files { os.Remove(filepath.Join(cl.dir, f.Name())) } return nil }
[ "func", "(", "cl", "FileChangelist", ")", "Clear", "(", "archive", "string", ")", "error", "{", "dir", ",", "err", ":=", "os", ".", "Open", "(", "cl", ".", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer"...
// Clear clears the change list // N.B. archiving not currently implemented
[ "Clear", "clears", "the", "change", "list", "N", ".", "B", ".", "archiving", "not", "currently", "implemented" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L118-L132
train
theupdateframework/notary
client/changelist/file_changelist.go
NewIterator
func (cl FileChangelist) NewIterator() (ChangeIterator, error) { fileInfos, err := getFileNames(cl.dir) if err != nil { return &FileChangeListIterator{}, err } return &FileChangeListIterator{dirname: cl.dir, collection: fileInfos}, nil }
go
func (cl FileChangelist) NewIterator() (ChangeIterator, error) { fileInfos, err := getFileNames(cl.dir) if err != nil { return &FileChangeListIterator{}, err } return &FileChangeListIterator{dirname: cl.dir, collection: fileInfos}, nil }
[ "func", "(", "cl", "FileChangelist", ")", "NewIterator", "(", ")", "(", "ChangeIterator", ",", "error", ")", "{", "fileInfos", ",", "err", ":=", "getFileNames", "(", "cl", ".", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "FileChange...
// NewIterator creates an iterator from FileChangelist
[ "NewIterator", "creates", "an", "iterator", "from", "FileChangelist" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L146-L152
train
theupdateframework/notary
client/changelist/file_changelist.go
Next
func (m *FileChangeListIterator) Next() (item Change, err error) { if m.index >= len(m.collection) { return nil, IteratorBoundsError(m.index) } f := m.collection[m.index] m.index++ item, err = unmarshalFile(m.dirname, f) return }
go
func (m *FileChangeListIterator) Next() (item Change, err error) { if m.index >= len(m.collection) { return nil, IteratorBoundsError(m.index) } f := m.collection[m.index] m.index++ item, err = unmarshalFile(m.dirname, f) return }
[ "func", "(", "m", "*", "FileChangeListIterator", ")", "Next", "(", ")", "(", "item", "Change", ",", "err", "error", ")", "{", "if", "m", ".", "index", ">=", "len", "(", "m", ".", "collection", ")", "{", "return", "nil", ",", "IteratorBoundsError", "(...
// Next returns the next Change in the FileChangeList
[ "Next", "returns", "the", "next", "Change", "in", "the", "FileChangeList" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L170-L178
train
theupdateframework/notary
client/changelist/file_changelist.go
Less
func (cs fileChanges) Less(i, j int) bool { return cs[i].Name() < cs[j].Name() }
go
func (cs fileChanges) Less(i, j int) bool { return cs[i].Name() < cs[j].Name() }
[ "func", "(", "cs", "fileChanges", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "cs", "[", "i", "]", ".", "Name", "(", ")", "<", "cs", "[", "j", "]", ".", "Name", "(", ")", "\n", "}" ]
// Less compares the names of two different file changes
[ "Less", "compares", "the", "names", "of", "two", "different", "file", "changes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L193-L195
train
theupdateframework/notary
client/changelist/file_changelist.go
Swap
func (cs fileChanges) Swap(i, j int) { tmp := cs[i] cs[i] = cs[j] cs[j] = tmp }
go
func (cs fileChanges) Swap(i, j int) { tmp := cs[i] cs[i] = cs[j] cs[j] = tmp }
[ "func", "(", "cs", "fileChanges", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "tmp", ":=", "cs", "[", "i", "]", "\n", "cs", "[", "i", "]", "=", "cs", "[", "j", "]", "\n", "cs", "[", "j", "]", "=", "tmp", "\n", "}" ]
// Swap swaps the position of two file changes
[ "Swap", "swaps", "the", "position", "of", "two", "file", "changes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/file_changelist.go#L198-L202
train
theupdateframework/notary
trustmanager/remoteks/server.go
Set
func (s *GRPCStorage) Set(ctx context.Context, msg *SetMsg) (*google_protobuf.Empty, error) { logrus.Debugf("storing: %s", msg.FileName) err := s.backend.Set(msg.FileName, msg.Data) if err != nil { logrus.Errorf("failed to store: %s", err.Error()) } return &google_protobuf.Empty{}, err }
go
func (s *GRPCStorage) Set(ctx context.Context, msg *SetMsg) (*google_protobuf.Empty, error) { logrus.Debugf("storing: %s", msg.FileName) err := s.backend.Set(msg.FileName, msg.Data) if err != nil { logrus.Errorf("failed to store: %s", err.Error()) } return &google_protobuf.Empty{}, err }
[ "func", "(", "s", "*", "GRPCStorage", ")", "Set", "(", "ctx", "context", ".", "Context", ",", "msg", "*", "SetMsg", ")", "(", "*", "google_protobuf", ".", "Empty", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "msg", ".", ...
// Set writes the provided data under the given identifier.
[ "Set", "writes", "the", "provided", "data", "under", "the", "given", "identifier", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/server.go#L27-L34
train
theupdateframework/notary
trustmanager/remoteks/server.go
Remove
func (s *GRPCStorage) Remove(ctx context.Context, fn *FileNameMsg) (*google_protobuf.Empty, error) { return &google_protobuf.Empty{}, s.backend.Remove(fn.FileName) }
go
func (s *GRPCStorage) Remove(ctx context.Context, fn *FileNameMsg) (*google_protobuf.Empty, error) { return &google_protobuf.Empty{}, s.backend.Remove(fn.FileName) }
[ "func", "(", "s", "*", "GRPCStorage", ")", "Remove", "(", "ctx", "context", ".", "Context", ",", "fn", "*", "FileNameMsg", ")", "(", "*", "google_protobuf", ".", "Empty", ",", "error", ")", "{", "return", "&", "google_protobuf", ".", "Empty", "{", "}",...
// Remove deletes the data associated with the provided identifier.
[ "Remove", "deletes", "the", "data", "associated", "with", "the", "provided", "identifier", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/server.go#L37-L39
train
theupdateframework/notary
trustmanager/remoteks/server.go
Get
func (s *GRPCStorage) Get(ctx context.Context, fn *FileNameMsg) (*ByteMsg, error) { data, err := s.backend.Get(fn.FileName) if err != nil { return &ByteMsg{}, err } return &ByteMsg{Data: data}, nil }
go
func (s *GRPCStorage) Get(ctx context.Context, fn *FileNameMsg) (*ByteMsg, error) { data, err := s.backend.Get(fn.FileName) if err != nil { return &ByteMsg{}, err } return &ByteMsg{Data: data}, nil }
[ "func", "(", "s", "*", "GRPCStorage", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "fn", "*", "FileNameMsg", ")", "(", "*", "ByteMsg", ",", "error", ")", "{", "data", ",", "err", ":=", "s", ".", "backend", ".", "Get", "(", "fn", ".", ...
// Get returns the data associated with the provided identifier.
[ "Get", "returns", "the", "data", "associated", "with", "the", "provided", "identifier", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/server.go#L42-L48
train
theupdateframework/notary
trustmanager/remoteks/server.go
ListFiles
func (s *GRPCStorage) ListFiles(ctx context.Context, _ *google_protobuf.Empty) (*StringListMsg, error) { lst := s.backend.ListFiles() logrus.Debugf("found %d keys", len(lst)) return &StringListMsg{ FileNames: lst, }, nil }
go
func (s *GRPCStorage) ListFiles(ctx context.Context, _ *google_protobuf.Empty) (*StringListMsg, error) { lst := s.backend.ListFiles() logrus.Debugf("found %d keys", len(lst)) return &StringListMsg{ FileNames: lst, }, nil }
[ "func", "(", "s", "*", "GRPCStorage", ")", "ListFiles", "(", "ctx", "context", ".", "Context", ",", "_", "*", "google_protobuf", ".", "Empty", ")", "(", "*", "StringListMsg", ",", "error", ")", "{", "lst", ":=", "s", ".", "backend", ".", "ListFiles", ...
// ListFiles returns all known identifiers in the storage backend.
[ "ListFiles", "returns", "all", "known", "identifiers", "in", "the", "storage", "backend", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/server.go#L51-L57
train
theupdateframework/notary
tuf/data/types.go
MetadataRoleMapToStringMap
func MetadataRoleMapToStringMap(roles map[RoleName][]byte) map[string][]byte { metadata := make(map[string][]byte) for k, v := range roles { metadata[k.String()] = v } return metadata }
go
func MetadataRoleMapToStringMap(roles map[RoleName][]byte) map[string][]byte { metadata := make(map[string][]byte) for k, v := range roles { metadata[k.String()] = v } return metadata }
[ "func", "MetadataRoleMapToStringMap", "(", "roles", "map", "[", "RoleName", "]", "[", "]", "byte", ")", "map", "[", "string", "]", "[", "]", "byte", "{", "metadata", ":=", "make", "(", "map", "[", "string", "]", "[", "]", "byte", ")", "\n", "for", ...
// MetadataRoleMapToStringMap generates a map string of bytes from a map RoleName of bytes
[ "MetadataRoleMapToStringMap", "generates", "a", "map", "string", "of", "bytes", "from", "a", "map", "RoleName", "of", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L44-L50
train
theupdateframework/notary
tuf/data/types.go
NewRoleList
func NewRoleList(roles []string) []RoleName { var roleNames []RoleName for _, role := range roles { roleNames = append(roleNames, RoleName(role)) } return roleNames }
go
func NewRoleList(roles []string) []RoleName { var roleNames []RoleName for _, role := range roles { roleNames = append(roleNames, RoleName(role)) } return roleNames }
[ "func", "NewRoleList", "(", "roles", "[", "]", "string", ")", "[", "]", "RoleName", "{", "var", "roleNames", "[", "]", "RoleName", "\n", "for", "_", ",", "role", ":=", "range", "roles", "{", "roleNames", "=", "append", "(", "roleNames", ",", "RoleName"...
// NewRoleList generates an array of RoleName objects from a slice of strings
[ "NewRoleList", "generates", "an", "array", "of", "RoleName", "objects", "from", "a", "slice", "of", "strings" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L53-L59
train
theupdateframework/notary
tuf/data/types.go
RolesListToStringList
func RolesListToStringList(roles []RoleName) []string { var roleNames []string for _, role := range roles { roleNames = append(roleNames, role.String()) } return roleNames }
go
func RolesListToStringList(roles []RoleName) []string { var roleNames []string for _, role := range roles { roleNames = append(roleNames, role.String()) } return roleNames }
[ "func", "RolesListToStringList", "(", "roles", "[", "]", "RoleName", ")", "[", "]", "string", "{", "var", "roleNames", "[", "]", "string", "\n", "for", "_", ",", "role", ":=", "range", "roles", "{", "roleNames", "=", "append", "(", "roleNames", ",", "r...
// RolesListToStringList generates an array of string objects from a slice of roles
[ "RolesListToStringList", "generates", "an", "array", "of", "string", "objects", "from", "a", "slice", "of", "roles" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L62-L68
train
theupdateframework/notary
tuf/data/types.go
ValidTUFType
func ValidTUFType(typ string, role RoleName) bool { if ValidRole(role) { // All targets delegation roles must have // the valid type is for targets. if role == "" { // role is unknown and does not map to // a type return false } if strings.HasPrefix(role.String(), CanonicalTargetsRole.String()+"/") ...
go
func ValidTUFType(typ string, role RoleName) bool { if ValidRole(role) { // All targets delegation roles must have // the valid type is for targets. if role == "" { // role is unknown and does not map to // a type return false } if strings.HasPrefix(role.String(), CanonicalTargetsRole.String()+"/") ...
[ "func", "ValidTUFType", "(", "typ", "string", ",", "role", "RoleName", ")", "bool", "{", "if", "ValidRole", "(", "role", ")", "{", "// All targets delegation roles must have", "// the valid type is for targets.", "if", "role", "==", "\"", "\"", "{", "// role is unkn...
// ValidTUFType checks if the given type is valid for the role
[ "ValidTUFType", "checks", "if", "the", "given", "type", "is", "valid", "for", "the", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L115-L135
train
theupdateframework/notary
tuf/data/types.go
Equals
func (f FileMeta) Equals(o FileMeta) bool { if o.Length != f.Length || len(f.Hashes) != len(f.Hashes) { return false } if f.Custom == nil && o.Custom != nil || f.Custom != nil && o.Custom == nil { return false } // we don't care if these are valid hashes, just that they are equal for key, val := range f.Hashe...
go
func (f FileMeta) Equals(o FileMeta) bool { if o.Length != f.Length || len(f.Hashes) != len(f.Hashes) { return false } if f.Custom == nil && o.Custom != nil || f.Custom != nil && o.Custom == nil { return false } // we don't care if these are valid hashes, just that they are equal for key, val := range f.Hashe...
[ "func", "(", "f", "FileMeta", ")", "Equals", "(", "o", "FileMeta", ")", "bool", "{", "if", "o", ".", "Length", "!=", "f", ".", "Length", "||", "len", "(", "f", ".", "Hashes", ")", "!=", "len", "(", "f", ".", "Hashes", ")", "{", "return", "false...
// Equals returns true if the other FileMeta object is equivalent to this one
[ "Equals", "returns", "true", "if", "the", "other", "FileMeta", "object", "is", "equivalent", "to", "this", "one" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L188-L213
train
theupdateframework/notary
tuf/data/types.go
CheckHashes
func CheckHashes(payload []byte, name string, hashes Hashes) error { cnt := 0 // k, v indicate the hash algorithm and the corresponding value for k, v := range hashes { switch k { case notary.SHA256: checksum := sha256.Sum256(payload) if subtle.ConstantTimeCompare(checksum[:], v) == 0 { return ErrMism...
go
func CheckHashes(payload []byte, name string, hashes Hashes) error { cnt := 0 // k, v indicate the hash algorithm and the corresponding value for k, v := range hashes { switch k { case notary.SHA256: checksum := sha256.Sum256(payload) if subtle.ConstantTimeCompare(checksum[:], v) == 0 { return ErrMism...
[ "func", "CheckHashes", "(", "payload", "[", "]", "byte", ",", "name", "string", ",", "hashes", "Hashes", ")", "error", "{", "cnt", ":=", "0", "\n\n", "// k, v indicate the hash algorithm and the corresponding value", "for", "k", ",", "v", ":=", "range", "hashes"...
// CheckHashes verifies all the checksums specified by the "hashes" of the payload.
[ "CheckHashes", "verifies", "all", "the", "checksums", "specified", "by", "the", "hashes", "of", "the", "payload", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L216-L242
train
theupdateframework/notary
tuf/data/types.go
CompareMultiHashes
func CompareMultiHashes(hashes1, hashes2 Hashes) error { // First check if the two hash structures are valid if err := CheckValidHashStructures(hashes1); err != nil { return err } if err := CheckValidHashStructures(hashes2); err != nil { return err } // Check if they have at least one matching hash, and no co...
go
func CompareMultiHashes(hashes1, hashes2 Hashes) error { // First check if the two hash structures are valid if err := CheckValidHashStructures(hashes1); err != nil { return err } if err := CheckValidHashStructures(hashes2); err != nil { return err } // Check if they have at least one matching hash, and no co...
[ "func", "CompareMultiHashes", "(", "hashes1", ",", "hashes2", "Hashes", ")", "error", "{", "// First check if the two hash structures are valid", "if", "err", ":=", "CheckValidHashStructures", "(", "hashes1", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n",...
// CompareMultiHashes verifies that the two Hashes passed in can represent the same data. // This means that both maps must have at least one key defined for which they map, and no conflicts. // Note that we check the intersection of map keys, which adds support for non-default hash algorithms in notary
[ "CompareMultiHashes", "verifies", "that", "the", "two", "Hashes", "passed", "in", "can", "represent", "the", "same", "data", ".", "This", "means", "that", "both", "maps", "must", "have", "at", "least", "one", "key", "defined", "for", "which", "they", "map", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L247-L276
train
theupdateframework/notary
tuf/data/types.go
CheckValidHashStructures
func CheckValidHashStructures(hashes Hashes) error { cnt := 0 for k, v := range hashes { switch k { case notary.SHA256: if len(v) != sha256.Size { return ErrInvalidChecksum{alg: notary.SHA256} } cnt++ case notary.SHA512: if len(v) != sha512.Size { return ErrInvalidChecksum{alg: notary.SHA51...
go
func CheckValidHashStructures(hashes Hashes) error { cnt := 0 for k, v := range hashes { switch k { case notary.SHA256: if len(v) != sha256.Size { return ErrInvalidChecksum{alg: notary.SHA256} } cnt++ case notary.SHA512: if len(v) != sha512.Size { return ErrInvalidChecksum{alg: notary.SHA51...
[ "func", "CheckValidHashStructures", "(", "hashes", "Hashes", ")", "error", "{", "cnt", ":=", "0", "\n\n", "for", "k", ",", "v", ":=", "range", "hashes", "{", "switch", "k", "{", "case", "notary", ".", "SHA256", ":", "if", "len", "(", "v", ")", "!=", ...
// CheckValidHashStructures returns an error, or nil, depending on whether // the content of the hashes is valid or not.
[ "CheckValidHashStructures", "returns", "an", "error", "or", "nil", "depending", "on", "whether", "the", "content", "of", "the", "hashes", "is", "valid", "or", "not", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L280-L303
train
theupdateframework/notary
tuf/data/types.go
NewFileMeta
func NewFileMeta(r io.Reader, hashAlgorithms ...string) (FileMeta, error) { if len(hashAlgorithms) == 0 { hashAlgorithms = []string{defaultHashAlgorithm} } hashes := make(map[string]hash.Hash, len(hashAlgorithms)) for _, hashAlgorithm := range hashAlgorithms { var h hash.Hash switch hashAlgorithm { case not...
go
func NewFileMeta(r io.Reader, hashAlgorithms ...string) (FileMeta, error) { if len(hashAlgorithms) == 0 { hashAlgorithms = []string{defaultHashAlgorithm} } hashes := make(map[string]hash.Hash, len(hashAlgorithms)) for _, hashAlgorithm := range hashAlgorithms { var h hash.Hash switch hashAlgorithm { case not...
[ "func", "NewFileMeta", "(", "r", "io", ".", "Reader", ",", "hashAlgorithms", "...", "string", ")", "(", "FileMeta", ",", "error", ")", "{", "if", "len", "(", "hashAlgorithms", ")", "==", "0", "{", "hashAlgorithms", "=", "[", "]", "string", "{", "defaul...
// NewFileMeta generates a FileMeta object from the reader, using the // hash algorithms provided
[ "NewFileMeta", "generates", "a", "FileMeta", "object", "from", "the", "reader", "using", "the", "hash", "algorithms", "provided" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L307-L334
train
theupdateframework/notary
tuf/data/types.go
NewDelegations
func NewDelegations() *Delegations { return &Delegations{ Keys: make(map[string]PublicKey), Roles: make([]*Role, 0), } }
go
func NewDelegations() *Delegations { return &Delegations{ Keys: make(map[string]PublicKey), Roles: make([]*Role, 0), } }
[ "func", "NewDelegations", "(", ")", "*", "Delegations", "{", "return", "&", "Delegations", "{", "Keys", ":", "make", "(", "map", "[", "string", "]", "PublicKey", ")", ",", "Roles", ":", "make", "(", "[", "]", "*", "Role", ",", "0", ")", ",", "}", ...
// NewDelegations initializes an empty Delegations object
[ "NewDelegations", "initializes", "an", "empty", "Delegations", "object" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L343-L348
train
theupdateframework/notary
tuf/data/types.go
SetDefaultExpiryTimes
func SetDefaultExpiryTimes(times map[RoleName]time.Duration) { for key, value := range times { if _, ok := defaultExpiryTimes[key]; !ok { logrus.Errorf("Attempted to set default expiry for an unknown role: %s", key.String()) continue } defaultExpiryTimes[key] = value } }
go
func SetDefaultExpiryTimes(times map[RoleName]time.Duration) { for key, value := range times { if _, ok := defaultExpiryTimes[key]; !ok { logrus.Errorf("Attempted to set default expiry for an unknown role: %s", key.String()) continue } defaultExpiryTimes[key] = value } }
[ "func", "SetDefaultExpiryTimes", "(", "times", "map", "[", "RoleName", "]", "time", ".", "Duration", ")", "{", "for", "key", ",", "value", ":=", "range", "times", "{", "if", "_", ",", "ok", ":=", "defaultExpiryTimes", "[", "key", "]", ";", "!", "ok", ...
// SetDefaultExpiryTimes allows one to change the default expiries.
[ "SetDefaultExpiryTimes", "allows", "one", "to", "change", "the", "default", "expiries", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L359-L367
train
theupdateframework/notary
tuf/data/types.go
DefaultExpires
func DefaultExpires(role RoleName) time.Time { if d, ok := defaultExpiryTimes[role]; ok { return time.Now().Add(d) } var t time.Time return t.UTC().Round(time.Second) }
go
func DefaultExpires(role RoleName) time.Time { if d, ok := defaultExpiryTimes[role]; ok { return time.Now().Add(d) } var t time.Time return t.UTC().Round(time.Second) }
[ "func", "DefaultExpires", "(", "role", "RoleName", ")", "time", ".", "Time", "{", "if", "d", ",", "ok", ":=", "defaultExpiryTimes", "[", "role", "]", ";", "ok", "{", "return", "time", ".", "Now", "(", ")", ".", "Add", "(", "d", ")", "\n", "}", "\...
// DefaultExpires gets the default expiry time for the given role
[ "DefaultExpires", "gets", "the", "default", "expiry", "time", "for", "the", "given", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L370-L376
train
theupdateframework/notary
tuf/data/types.go
UnmarshalJSON
func (s *Signature) UnmarshalJSON(data []byte) error { uSignature := unmarshalledSignature{} err := json.Unmarshal(data, &uSignature) if err != nil { return err } uSignature.Method = SigAlgorithm(strings.ToLower(string(uSignature.Method))) *s = Signature(uSignature) return nil }
go
func (s *Signature) UnmarshalJSON(data []byte) error { uSignature := unmarshalledSignature{} err := json.Unmarshal(data, &uSignature) if err != nil { return err } uSignature.Method = SigAlgorithm(strings.ToLower(string(uSignature.Method))) *s = Signature(uSignature) return nil }
[ "func", "(", "s", "*", "Signature", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "uSignature", ":=", "unmarshalledSignature", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "uSignature", ")", "\...
// UnmarshalJSON does a custom unmarshalling of the signature JSON
[ "UnmarshalJSON", "does", "a", "custom", "unmarshalling", "of", "the", "signature", "JSON" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/types.go#L381-L390
train
theupdateframework/notary
cryptoservice/crypto_service.go
Create
func (cs *CryptoService) Create(role data.RoleName, gun data.GUN, algorithm string) (data.PublicKey, error) { if algorithm == data.RSAKey { return nil, fmt.Errorf("%s keys can only be imported", data.RSAKey) } privKey, err := utils.GenerateKey(algorithm) if err != nil { return nil, fmt.Errorf("failed to genera...
go
func (cs *CryptoService) Create(role data.RoleName, gun data.GUN, algorithm string) (data.PublicKey, error) { if algorithm == data.RSAKey { return nil, fmt.Errorf("%s keys can only be imported", data.RSAKey) } privKey, err := utils.GenerateKey(algorithm) if err != nil { return nil, fmt.Errorf("failed to genera...
[ "func", "(", "cs", "*", "CryptoService", ")", "Create", "(", "role", "data", ".", "RoleName", ",", "gun", "data", ".", "GUN", ",", "algorithm", "string", ")", "(", "data", ".", "PublicKey", ",", "error", ")", "{", "if", "algorithm", "==", "data", "."...
// Create is used to generate keys for targets, snapshots and timestamps
[ "Create", "is", "used", "to", "generate", "keys", "for", "targets", "snapshots", "and", "timestamps" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L41-L54
train
theupdateframework/notary
cryptoservice/crypto_service.go
GetPrivateKey
func (cs *CryptoService) GetPrivateKey(keyID string) (k data.PrivateKey, role data.RoleName, err error) { for _, ks := range cs.keyStores { if k, role, err = ks.GetKey(keyID); err == nil { return } switch err.(type) { case trustmanager.ErrPasswordInvalid, trustmanager.ErrAttemptsExceeded: return defaul...
go
func (cs *CryptoService) GetPrivateKey(keyID string) (k data.PrivateKey, role data.RoleName, err error) { for _, ks := range cs.keyStores { if k, role, err = ks.GetKey(keyID); err == nil { return } switch err.(type) { case trustmanager.ErrPasswordInvalid, trustmanager.ErrAttemptsExceeded: return defaul...
[ "func", "(", "cs", "*", "CryptoService", ")", "GetPrivateKey", "(", "keyID", "string", ")", "(", "k", "data", ".", "PrivateKey", ",", "role", "data", ".", "RoleName", ",", "err", "error", ")", "{", "for", "_", ",", "ks", ":=", "range", "cs", ".", "...
// GetPrivateKey returns a private key and role if present by ID.
[ "GetPrivateKey", "returns", "a", "private", "key", "and", "role", "if", "present", "by", "ID", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L57-L70
train
theupdateframework/notary
cryptoservice/crypto_service.go
GetKey
func (cs *CryptoService) GetKey(keyID string) data.PublicKey { privKey, _, err := cs.GetPrivateKey(keyID) if err != nil { return nil } return data.PublicKeyFromPrivate(privKey) }
go
func (cs *CryptoService) GetKey(keyID string) data.PublicKey { privKey, _, err := cs.GetPrivateKey(keyID) if err != nil { return nil } return data.PublicKeyFromPrivate(privKey) }
[ "func", "(", "cs", "*", "CryptoService", ")", "GetKey", "(", "keyID", "string", ")", "data", ".", "PublicKey", "{", "privKey", ",", "_", ",", "err", ":=", "cs", ".", "GetPrivateKey", "(", "keyID", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// GetKey returns a key by ID
[ "GetKey", "returns", "a", "key", "by", "ID" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L73-L79
train
theupdateframework/notary
cryptoservice/crypto_service.go
GetKeyInfo
func (cs *CryptoService) GetKeyInfo(keyID string) (trustmanager.KeyInfo, error) { for _, store := range cs.keyStores { if info, err := store.GetKeyInfo(keyID); err == nil { return info, nil } } return trustmanager.KeyInfo{}, fmt.Errorf("Could not find info for keyID %s", keyID) }
go
func (cs *CryptoService) GetKeyInfo(keyID string) (trustmanager.KeyInfo, error) { for _, store := range cs.keyStores { if info, err := store.GetKeyInfo(keyID); err == nil { return info, nil } } return trustmanager.KeyInfo{}, fmt.Errorf("Could not find info for keyID %s", keyID) }
[ "func", "(", "cs", "*", "CryptoService", ")", "GetKeyInfo", "(", "keyID", "string", ")", "(", "trustmanager", ".", "KeyInfo", ",", "error", ")", "{", "for", "_", ",", "store", ":=", "range", "cs", ".", "keyStores", "{", "if", "info", ",", "err", ":="...
// GetKeyInfo returns role and GUN info of a key by ID
[ "GetKeyInfo", "returns", "role", "and", "GUN", "info", "of", "a", "key", "by", "ID" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L82-L89
train
theupdateframework/notary
cryptoservice/crypto_service.go
RemoveKey
func (cs *CryptoService) RemoveKey(keyID string) (err error) { for _, ks := range cs.keyStores { ks.RemoveKey(keyID) } return // returns whatever the final values were }
go
func (cs *CryptoService) RemoveKey(keyID string) (err error) { for _, ks := range cs.keyStores { ks.RemoveKey(keyID) } return // returns whatever the final values were }
[ "func", "(", "cs", "*", "CryptoService", ")", "RemoveKey", "(", "keyID", "string", ")", "(", "err", "error", ")", "{", "for", "_", ",", "ks", ":=", "range", "cs", ".", "keyStores", "{", "ks", ".", "RemoveKey", "(", "keyID", ")", "\n", "}", "\n", ...
// RemoveKey deletes a key by ID
[ "RemoveKey", "deletes", "a", "key", "by", "ID" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L92-L97
train
theupdateframework/notary
cryptoservice/crypto_service.go
AddKey
func (cs *CryptoService) AddKey(role data.RoleName, gun data.GUN, key data.PrivateKey) (err error) { // First check if this key already exists in any of our keystores for _, ks := range cs.keyStores { if keyInfo, err := ks.GetKeyInfo(key.ID()); err == nil { if keyInfo.Role != role { return fmt.Errorf("key wi...
go
func (cs *CryptoService) AddKey(role data.RoleName, gun data.GUN, key data.PrivateKey) (err error) { // First check if this key already exists in any of our keystores for _, ks := range cs.keyStores { if keyInfo, err := ks.GetKeyInfo(key.ID()); err == nil { if keyInfo.Role != role { return fmt.Errorf("key wi...
[ "func", "(", "cs", "*", "CryptoService", ")", "AddKey", "(", "role", "data", ".", "RoleName", ",", "gun", "data", ".", "GUN", ",", "key", "data", ".", "PrivateKey", ")", "(", "err", "error", ")", "{", "// First check if this key already exists in any of our ke...
// AddKey adds a private key to a specified role. // The GUN is inferred from the cryptoservice itself for non-root roles
[ "AddKey", "adds", "a", "private", "key", "to", "a", "specified", "role", ".", "The", "GUN", "is", "inferred", "from", "the", "cryptoservice", "itself", "for", "non", "-", "root", "roles" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L101-L120
train
theupdateframework/notary
cryptoservice/crypto_service.go
ListKeys
func (cs *CryptoService) ListKeys(role data.RoleName) []string { var res []string for _, ks := range cs.keyStores { for k, r := range ks.ListKeys() { if r.Role == role { res = append(res, k) } } } return res }
go
func (cs *CryptoService) ListKeys(role data.RoleName) []string { var res []string for _, ks := range cs.keyStores { for k, r := range ks.ListKeys() { if r.Role == role { res = append(res, k) } } } return res }
[ "func", "(", "cs", "*", "CryptoService", ")", "ListKeys", "(", "role", "data", ".", "RoleName", ")", "[", "]", "string", "{", "var", "res", "[", "]", "string", "\n", "for", "_", ",", "ks", ":=", "range", "cs", ".", "keyStores", "{", "for", "k", "...
// ListKeys returns a list of key IDs valid for the given role
[ "ListKeys", "returns", "a", "list", "of", "key", "IDs", "valid", "for", "the", "given", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L123-L133
train
theupdateframework/notary
cryptoservice/crypto_service.go
ListAllKeys
func (cs *CryptoService) ListAllKeys() map[string]data.RoleName { res := make(map[string]data.RoleName) for _, ks := range cs.keyStores { for k, r := range ks.ListKeys() { res[k] = r.Role // keys are content addressed so don't care about overwrites } } return res }
go
func (cs *CryptoService) ListAllKeys() map[string]data.RoleName { res := make(map[string]data.RoleName) for _, ks := range cs.keyStores { for k, r := range ks.ListKeys() { res[k] = r.Role // keys are content addressed so don't care about overwrites } } return res }
[ "func", "(", "cs", "*", "CryptoService", ")", "ListAllKeys", "(", ")", "map", "[", "string", "]", "data", ".", "RoleName", "{", "res", ":=", "make", "(", "map", "[", "string", "]", "data", ".", "RoleName", ")", "\n", "for", "_", ",", "ks", ":=", ...
// ListAllKeys returns a map of key IDs to role
[ "ListAllKeys", "returns", "a", "map", "of", "key", "IDs", "to", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L136-L144
train
theupdateframework/notary
cryptoservice/crypto_service.go
CheckRootKeyIsEncrypted
func CheckRootKeyIsEncrypted(pemBytes []byte) error { block, _ := pem.Decode(pemBytes) if block == nil { return ErrNoValidPrivateKey } if block.Type == "ENCRYPTED PRIVATE KEY" { return nil } if !notary.FIPSEnabled() && x509.IsEncryptedPEMBlock(block) { return nil } return ErrRootKeyNotEncrypted }
go
func CheckRootKeyIsEncrypted(pemBytes []byte) error { block, _ := pem.Decode(pemBytes) if block == nil { return ErrNoValidPrivateKey } if block.Type == "ENCRYPTED PRIVATE KEY" { return nil } if !notary.FIPSEnabled() && x509.IsEncryptedPEMBlock(block) { return nil } return ErrRootKeyNotEncrypted }
[ "func", "CheckRootKeyIsEncrypted", "(", "pemBytes", "[", "]", "byte", ")", "error", "{", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "pemBytes", ")", "\n", "if", "block", "==", "nil", "{", "return", "ErrNoValidPrivateKey", "\n", "}", "\n\n", "if"...
// CheckRootKeyIsEncrypted makes sure the root key is encrypted. We have // internal assumptions that depend on this.
[ "CheckRootKeyIsEncrypted", "makes", "sure", "the", "root", "key", "is", "encrypted", ".", "We", "have", "internal", "assumptions", "that", "depend", "on", "this", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cryptoservice/crypto_service.go#L148-L162
train
theupdateframework/notary
signer/api/rpc_api.go
CreateKey
func (s *KeyManagementServer) CreateKey(ctx context.Context, req *pb.CreateKeyRequest) (*pb.PublicKey, error) { service := s.CryptoServices[req.Algorithm] logger := ctxu.GetLogger(ctx) if service == nil { logger.Error("CreateKey: unsupported algorithm: ", req.Algorithm) return nil, fmt.Errorf("algorithm %s not...
go
func (s *KeyManagementServer) CreateKey(ctx context.Context, req *pb.CreateKeyRequest) (*pb.PublicKey, error) { service := s.CryptoServices[req.Algorithm] logger := ctxu.GetLogger(ctx) if service == nil { logger.Error("CreateKey: unsupported algorithm: ", req.Algorithm) return nil, fmt.Errorf("algorithm %s not...
[ "func", "(", "s", "*", "KeyManagementServer", ")", "CreateKey", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "CreateKeyRequest", ")", "(", "*", "pb", ".", "PublicKey", ",", "error", ")", "{", "service", ":=", "s", ".", "CryptoServ...
//CreateKey returns a PublicKey created using KeyManagementServer's SigningService
[ "CreateKey", "returns", "a", "PublicKey", "created", "using", "KeyManagementServer", "s", "SigningService" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/api/rpc_api.go#L30-L57
train
theupdateframework/notary
signer/api/rpc_api.go
DeleteKey
func (s *KeyManagementServer) DeleteKey(ctx context.Context, keyID *pb.KeyID) (*pb.Void, error) { logger := ctxu.GetLogger(ctx) // delete key ID from all services for _, service := range s.CryptoServices { if err := service.RemoveKey(keyID.ID); err != nil { logger.Errorf("Failed to delete key %s", keyID.ID) ...
go
func (s *KeyManagementServer) DeleteKey(ctx context.Context, keyID *pb.KeyID) (*pb.Void, error) { logger := ctxu.GetLogger(ctx) // delete key ID from all services for _, service := range s.CryptoServices { if err := service.RemoveKey(keyID.ID); err != nil { logger.Errorf("Failed to delete key %s", keyID.ID) ...
[ "func", "(", "s", "*", "KeyManagementServer", ")", "DeleteKey", "(", "ctx", "context", ".", "Context", ",", "keyID", "*", "pb", ".", "KeyID", ")", "(", "*", "pb", ".", "Void", ",", "error", ")", "{", "logger", ":=", "ctxu", ".", "GetLogger", "(", "...
//DeleteKey deletes they key associated with a KeyID
[ "DeleteKey", "deletes", "they", "key", "associated", "with", "a", "KeyID" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/api/rpc_api.go#L60-L71
train
theupdateframework/notary
signer/api/rpc_api.go
GetKeyInfo
func (s *KeyManagementServer) GetKeyInfo(ctx context.Context, keyID *pb.KeyID) (*pb.GetKeyInfoResponse, error) { privKey, role, err := findKeyByID(s.CryptoServices, keyID) logger := ctxu.GetLogger(ctx) if err != nil { logger.Errorf("GetKeyInfo: key %s not found", keyID.ID) return nil, grpc.Errorf(codes.NotFoun...
go
func (s *KeyManagementServer) GetKeyInfo(ctx context.Context, keyID *pb.KeyID) (*pb.GetKeyInfoResponse, error) { privKey, role, err := findKeyByID(s.CryptoServices, keyID) logger := ctxu.GetLogger(ctx) if err != nil { logger.Errorf("GetKeyInfo: key %s not found", keyID.ID) return nil, grpc.Errorf(codes.NotFoun...
[ "func", "(", "s", "*", "KeyManagementServer", ")", "GetKeyInfo", "(", "ctx", "context", ".", "Context", ",", "keyID", "*", "pb", ".", "KeyID", ")", "(", "*", "pb", ".", "GetKeyInfoResponse", ",", "error", ")", "{", "privKey", ",", "role", ",", "err", ...
//GetKeyInfo returns they PublicKey associated with a KeyID
[ "GetKeyInfo", "returns", "they", "PublicKey", "associated", "with", "a", "KeyID" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/api/rpc_api.go#L74-L93
train
theupdateframework/notary
signer/api/rpc_api.go
Sign
func (s *SignerServer) Sign(ctx context.Context, sr *pb.SignatureRequest) (*pb.Signature, error) { privKey, _, err := findKeyByID(s.CryptoServices, sr.KeyID) logger := ctxu.GetLogger(ctx) switch err.(type) { case trustmanager.ErrKeyNotFound: logger.Errorf("Sign: key %s not found", sr.KeyID.ID) return nil, grp...
go
func (s *SignerServer) Sign(ctx context.Context, sr *pb.SignatureRequest) (*pb.Signature, error) { privKey, _, err := findKeyByID(s.CryptoServices, sr.KeyID) logger := ctxu.GetLogger(ctx) switch err.(type) { case trustmanager.ErrKeyNotFound: logger.Errorf("Sign: key %s not found", sr.KeyID.ID) return nil, grp...
[ "func", "(", "s", "*", "SignerServer", ")", "Sign", "(", "ctx", "context", ".", "Context", ",", "sr", "*", "pb", ".", "SignatureRequest", ")", "(", "*", "pb", ".", "Signature", ",", "error", ")", "{", "privKey", ",", "_", ",", "err", ":=", "findKey...
//Sign signs a message and returns the signature using a private key associate with the KeyID from the SignatureRequest
[ "Sign", "signs", "a", "message", "and", "returns", "the", "signature", "using", "a", "private", "key", "associate", "with", "the", "KeyID", "from", "the", "SignatureRequest" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/api/rpc_api.go#L96-L131
train
theupdateframework/notary
cmd/notary/tuf.go
getTargetCustom
func getTargetCustom(targetCustomFilename string) (*canonicaljson.RawMessage, error) { targetCustom := new(canonicaljson.RawMessage) rawTargetCustom, err := ioutil.ReadFile(targetCustomFilename) if err != nil { return nil, err } if err := targetCustom.UnmarshalJSON(rawTargetCustom); err != nil { return nil, e...
go
func getTargetCustom(targetCustomFilename string) (*canonicaljson.RawMessage, error) { targetCustom := new(canonicaljson.RawMessage) rawTargetCustom, err := ioutil.ReadFile(targetCustomFilename) if err != nil { return nil, err } if err := targetCustom.UnmarshalJSON(rawTargetCustom); err != nil { return nil, e...
[ "func", "getTargetCustom", "(", "targetCustomFilename", "string", ")", "(", "*", "canonicaljson", ".", "RawMessage", ",", "error", ")", "{", "targetCustom", ":=", "new", "(", "canonicaljson", ".", "RawMessage", ")", "\n", "rawTargetCustom", ",", "err", ":=", "...
// Open and read a file containing the targetCustom data
[ "Open", "and", "read", "a", "file", "containing", "the", "targetCustom", "data" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/tuf.go#L256-L267
train
theupdateframework/notary
cmd/notary/tuf.go
importRootKey
func importRootKey(cmd *cobra.Command, rootKey string, nRepo notaryclient.Repository, retriever notary.PassRetriever) ([]string, error) { var rootKeyList []string if rootKey != "" { privKey, err := readKey(data.CanonicalRootRole, rootKey, retriever) if err != nil { return nil, err } // add root key to rep...
go
func importRootKey(cmd *cobra.Command, rootKey string, nRepo notaryclient.Repository, retriever notary.PassRetriever) ([]string, error) { var rootKeyList []string if rootKey != "" { privKey, err := readKey(data.CanonicalRootRole, rootKey, retriever) if err != nil { return nil, err } // add root key to rep...
[ "func", "importRootKey", "(", "cmd", "*", "cobra", ".", "Command", ",", "rootKey", "string", ",", "nRepo", "notaryclient", ".", "Repository", ",", "retriever", "notary", ".", "PassRetriever", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "...
// importRootKey imports the root key from path then adds the key to repo // returns key ids
[ "importRootKey", "imports", "the", "root", "key", "from", "path", "then", "adds", "the", "key", "to", "repo", "returns", "key", "ids" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/tuf.go#L413-L441
train
theupdateframework/notary
cmd/notary/tuf.go
importRootCert
func importRootCert(certFilePath string) ([]data.PublicKey, error) { publicKeys := make([]data.PublicKey, 0, 1) if certFilePath == "" { return publicKeys, nil } // read certificate from file certPEM, err := ioutil.ReadFile(certFilePath) if err != nil { return nil, fmt.Errorf("error reading certificate file:...
go
func importRootCert(certFilePath string) ([]data.PublicKey, error) { publicKeys := make([]data.PublicKey, 0, 1) if certFilePath == "" { return publicKeys, nil } // read certificate from file certPEM, err := ioutil.ReadFile(certFilePath) if err != nil { return nil, fmt.Errorf("error reading certificate file:...
[ "func", "importRootCert", "(", "certFilePath", "string", ")", "(", "[", "]", "data", ".", "PublicKey", ",", "error", ")", "{", "publicKeys", ":=", "make", "(", "[", "]", "data", ".", "PublicKey", ",", "0", ",", "1", ")", "\n\n", "if", "certFilePath", ...
// importRootCert imports the base64 encoded public certificate corresponding to the root key // returns empty slice if path is empty
[ "importRootCert", "imports", "the", "base64", "encoded", "public", "certificate", "corresponding", "to", "the", "root", "key", "returns", "empty", "slice", "if", "path", "is", "empty" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/tuf.go#L445-L470
train
theupdateframework/notary
cmd/notary/tuf.go
readKey
func readKey(role data.RoleName, keyFilename string, retriever notary.PassRetriever) (data.PrivateKey, error) { pemBytes, err := ioutil.ReadFile(keyFilename) if err != nil { return nil, fmt.Errorf("Error reading input root key file: %v", err) } isEncrypted := true if err = cryptoservice.CheckRootKeyIsEncrypted(p...
go
func readKey(role data.RoleName, keyFilename string, retriever notary.PassRetriever) (data.PrivateKey, error) { pemBytes, err := ioutil.ReadFile(keyFilename) if err != nil { return nil, fmt.Errorf("Error reading input root key file: %v", err) } isEncrypted := true if err = cryptoservice.CheckRootKeyIsEncrypted(p...
[ "func", "readKey", "(", "role", "data", ".", "RoleName", ",", "keyFilename", "string", ",", "retriever", "notary", ".", "PassRetriever", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "pemBytes", ",", "err", ":=", "ioutil", ".", "ReadFile", ...
// Attempt to read a role key from a file, and return it as a data.PrivateKey // If key is for the Root role, it must be encrypted
[ "Attempt", "to", "read", "a", "role", "key", "from", "a", "file", "and", "return", "it", "as", "a", "data", ".", "PrivateKey", "If", "key", "is", "for", "the", "Root", "role", "it", "must", "be", "encrypted" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/tuf.go#L514-L537
train
theupdateframework/notary
server/handlers/validation.go
validateUpdate
func validateUpdate(cs signed.CryptoService, gun data.GUN, updates []storage.MetaUpdate, store storage.MetaStore) ([]storage.MetaUpdate, error) { // some delegated targets role may be invalid based on other updates // that have been made by other clients. We'll rebuild the slice of // updates with only the things w...
go
func validateUpdate(cs signed.CryptoService, gun data.GUN, updates []storage.MetaUpdate, store storage.MetaStore) ([]storage.MetaUpdate, error) { // some delegated targets role may be invalid based on other updates // that have been made by other clients. We'll rebuild the slice of // updates with only the things w...
[ "func", "validateUpdate", "(", "cs", "signed", ".", "CryptoService", ",", "gun", "data", ".", "GUN", ",", "updates", "[", "]", "storage", ".", "MetaUpdate", ",", "store", "storage", ".", "MetaStore", ")", "(", "[", "]", "storage", ".", "MetaUpdate", ",",...
// validateUpload checks that the updates being pushed // are semantically correct and the signatures are correct // A list of possibly modified updates are returned if all // validation was successful. This allows the snapshot to be // created and added if snapshotting has been delegated to the // server
[ "validateUpload", "checks", "that", "the", "updates", "being", "pushed", "are", "semantically", "correct", "and", "the", "signatures", "are", "correct", "A", "list", "of", "possibly", "modified", "updates", "are", "returned", "if", "all", "validation", "was", "s...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/validation.go#L25-L99
train
theupdateframework/notary
server/handlers/validation.go
generateSnapshot
func generateSnapshot(gun data.GUN, builder tuf.RepoBuilder, store storage.MetaStore) (*storage.MetaUpdate, error) { var prev *data.SignedSnapshot _, currentJSON, err := store.GetCurrent(gun, data.CanonicalSnapshotRole) if err == nil { prev = new(data.SignedSnapshot) if err = json.Unmarshal(currentJSON, prev); e...
go
func generateSnapshot(gun data.GUN, builder tuf.RepoBuilder, store storage.MetaStore) (*storage.MetaUpdate, error) { var prev *data.SignedSnapshot _, currentJSON, err := store.GetCurrent(gun, data.CanonicalSnapshotRole) if err == nil { prev = new(data.SignedSnapshot) if err = json.Unmarshal(currentJSON, prev); e...
[ "func", "generateSnapshot", "(", "gun", "data", ".", "GUN", ",", "builder", "tuf", ".", "RepoBuilder", ",", "store", "storage", ".", "MetaStore", ")", "(", "*", "storage", ".", "MetaUpdate", ",", "error", ")", "{", "var", "prev", "*", "data", ".", "Sig...
// generateSnapshot generates a new snapshot from the previous one in the store - this assumes all // the other roles except timestamp have already been set on the repo, and will set the generated // snapshot on the repo as well
[ "generateSnapshot", "generates", "a", "new", "snapshot", "from", "the", "previous", "one", "in", "the", "store", "-", "this", "assumes", "all", "the", "other", "roles", "except", "timestamp", "have", "already", "been", "set", "on", "the", "repo", "and", "wil...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/validation.go#L152-L185
train
theupdateframework/notary
server/handlers/validation.go
generateTimestamp
func generateTimestamp(gun data.GUN, builder tuf.RepoBuilder, store storage.MetaStore) (*storage.MetaUpdate, error) { var prev *data.SignedTimestamp _, currentJSON, err := store.GetCurrent(gun, data.CanonicalTimestampRole) switch err.(type) { case nil: prev = new(data.SignedTimestamp) if err := json.Unmarshal(...
go
func generateTimestamp(gun data.GUN, builder tuf.RepoBuilder, store storage.MetaStore) (*storage.MetaUpdate, error) { var prev *data.SignedTimestamp _, currentJSON, err := store.GetCurrent(gun, data.CanonicalTimestampRole) switch err.(type) { case nil: prev = new(data.SignedTimestamp) if err := json.Unmarshal(...
[ "func", "generateTimestamp", "(", "gun", "data", ".", "GUN", ",", "builder", "tuf", ".", "RepoBuilder", ",", "store", "storage", ".", "MetaStore", ")", "(", "*", "storage", ".", "MetaUpdate", ",", "error", ")", "{", "var", "prev", "*", "data", ".", "Si...
// generateTimestamp generates a new timestamp from the previous one in the store - this assumes all // the other roles have already been set on the repo, and will set the generated timestamp on the repo as well
[ "generateTimestamp", "generates", "a", "new", "timestamp", "from", "the", "previous", "one", "in", "the", "store", "-", "this", "assumes", "all", "the", "other", "roles", "have", "already", "been", "set", "on", "the", "repo", "and", "will", "set", "the", "...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/validation.go#L189-L224
train
theupdateframework/notary
tuf/signed/sign.go
Sign
func Sign(service CryptoService, s *data.Signed, signingKeys []data.PublicKey, minSignatures int, otherWhitelistedKeys []data.PublicKey) error { logrus.Debugf("sign called with %d/%d required keys", minSignatures, len(signingKeys)) signatures := make([]data.Signature, 0, len(s.Signatures)+1) signingKeyIDs := make(...
go
func Sign(service CryptoService, s *data.Signed, signingKeys []data.PublicKey, minSignatures int, otherWhitelistedKeys []data.PublicKey) error { logrus.Debugf("sign called with %d/%d required keys", minSignatures, len(signingKeys)) signatures := make([]data.Signature, 0, len(s.Signatures)+1) signingKeyIDs := make(...
[ "func", "Sign", "(", "service", "CryptoService", ",", "s", "*", "data", ".", "Signed", ",", "signingKeys", "[", "]", "data", ".", "PublicKey", ",", "minSignatures", "int", ",", "otherWhitelistedKeys", "[", "]", "data", ".", "PublicKey", ")", "error", "{", ...
// Sign takes a data.Signed and a cryptoservice containing private keys, // calculates and adds at least minSignature signatures using signingKeys the // data.Signed. It will also clean up any signatures that are not in produced // by either a signingKey or an otherWhitelistedKey. // Note that in most cases, otherWhit...
[ "Sign", "takes", "a", "data", ".", "Signed", "and", "a", "cryptoservice", "containing", "private", "keys", "calculates", "and", "adds", "at", "least", "minSignature", "signatures", "using", "signingKeys", "the", "data", ".", "Signed", ".", "It", "will", "also"...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/sign.go#L32-L113
train
theupdateframework/notary
tuf/utils/role_sort.go
Swap
func (r RoleList) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
go
func (r RoleList) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
[ "func", "(", "r", "RoleList", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "r", "[", "i", "]", ",", "r", "[", "j", "]", "=", "r", "[", "j", "]", ",", "r", "[", "i", "]", "\n", "}" ]
// Swap the items at 2 locations in the list
[ "Swap", "the", "items", "at", "2", "locations", "in", "the", "list" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/utils/role_sort.go#L29-L31
train
theupdateframework/notary
client/reader.go
GetTargetByName
func (r *reader) GetTargetByName(name string, roles ...data.RoleName) (*TargetWithRole, error) { if len(roles) == 0 { roles = append(roles, data.CanonicalTargetsRole) } var resultMeta data.FileMeta var resultRoleName data.RoleName var foundTarget bool for _, role := range roles { // Define an array of roles t...
go
func (r *reader) GetTargetByName(name string, roles ...data.RoleName) (*TargetWithRole, error) { if len(roles) == 0 { roles = append(roles, data.CanonicalTargetsRole) } var resultMeta data.FileMeta var resultRoleName data.RoleName var foundTarget bool for _, role := range roles { // Define an array of roles t...
[ "func", "(", "r", "*", "reader", ")", "GetTargetByName", "(", "name", "string", ",", "roles", "...", "data", ".", "RoleName", ")", "(", "*", "TargetWithRole", ",", "error", ")", "{", "if", "len", "(", "roles", ")", "==", "0", "{", "roles", "=", "ap...
// GetTargetByName returns a target by the given name. If no roles are passed // it uses the targets role and does a search of the entire delegation // graph, finding the first entry in a breadth first search of the delegations. // If roles are passed, they should be passed in descending priority and // the target entr...
[ "GetTargetByName", "returns", "a", "target", "by", "the", "given", "name", ".", "If", "no", "roles", "are", "passed", "it", "uses", "the", "targets", "role", "and", "does", "a", "search", "of", "the", "entire", "delegation", "graph", "finding", "the", "fir...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/reader.go#L117-L148
train
theupdateframework/notary
client/reader.go
GetAllTargetMetadataByName
func (r *reader) GetAllTargetMetadataByName(name string) ([]TargetSignedStruct, error) { var targetInfoList []TargetSignedStruct // Define a visitor function to find the specified target getAllTargetInfoByNameVisitorFunc := func(tgt *data.SignedTargets, validRole data.DelegationRole) interface{} { if tgt == nil {...
go
func (r *reader) GetAllTargetMetadataByName(name string) ([]TargetSignedStruct, error) { var targetInfoList []TargetSignedStruct // Define a visitor function to find the specified target getAllTargetInfoByNameVisitorFunc := func(tgt *data.SignedTargets, validRole data.DelegationRole) interface{} { if tgt == nil {...
[ "func", "(", "r", "*", "reader", ")", "GetAllTargetMetadataByName", "(", "name", "string", ")", "(", "[", "]", "TargetSignedStruct", ",", "error", ")", "{", "var", "targetInfoList", "[", "]", "TargetSignedStruct", "\n\n", "// Define a visitor function to find the sp...
// GetAllTargetMetadataByName searches the entire delegation role tree to find the specified target by name for all // roles, and returns a list of TargetSignedStructs for each time it finds the specified target. // If given an empty string for a target name, it will return back all targets signed into the repository i...
[ "GetAllTargetMetadataByName", "searches", "the", "entire", "delegation", "role", "tree", "to", "find", "the", "specified", "target", "by", "name", "for", "all", "roles", "and", "returns", "a", "list", "of", "TargetSignedStructs", "for", "each", "time", "it", "fi...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/reader.go#L153-L193
train
theupdateframework/notary
client/reader.go
ListRoles
func (r *reader) ListRoles() ([]RoleWithSignatures, error) { // Get all role info from our updated keysDB, can be empty roles := r.tufRepo.GetAllLoadedRoles() var roleWithSigs []RoleWithSignatures // Populate RoleWithSignatures with Role from keysDB and signatures from TUF metadata for _, role := range roles { ...
go
func (r *reader) ListRoles() ([]RoleWithSignatures, error) { // Get all role info from our updated keysDB, can be empty roles := r.tufRepo.GetAllLoadedRoles() var roleWithSigs []RoleWithSignatures // Populate RoleWithSignatures with Role from keysDB and signatures from TUF metadata for _, role := range roles { ...
[ "func", "(", "r", "*", "reader", ")", "ListRoles", "(", ")", "(", "[", "]", "RoleWithSignatures", ",", "error", ")", "{", "// Get all role info from our updated keysDB, can be empty", "roles", ":=", "r", ".", "tufRepo", ".", "GetAllLoadedRoles", "(", ")", "\n\n"...
// ListRoles returns a list of RoleWithSignatures objects for this repo // This represents the latest metadata for each role in this repo
[ "ListRoles", "returns", "a", "list", "of", "RoleWithSignatures", "objects", "for", "this", "repo", "This", "represents", "the", "latest", "metadata", "for", "each", "role", "in", "this", "repo" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/reader.go#L197-L227
train
theupdateframework/notary
client/reader.go
GetDelegationRoles
func (r *reader) GetDelegationRoles() ([]data.Role, error) { // All top level delegations (ex: targets/level1) are stored exclusively in targets.json _, ok := r.tufRepo.Targets[data.CanonicalTargetsRole] if !ok { return nil, store.ErrMetaNotFound{Resource: data.CanonicalTargetsRole.String()} } // make a copy fo...
go
func (r *reader) GetDelegationRoles() ([]data.Role, error) { // All top level delegations (ex: targets/level1) are stored exclusively in targets.json _, ok := r.tufRepo.Targets[data.CanonicalTargetsRole] if !ok { return nil, store.ErrMetaNotFound{Resource: data.CanonicalTargetsRole.String()} } // make a copy fo...
[ "func", "(", "r", "*", "reader", ")", "GetDelegationRoles", "(", ")", "(", "[", "]", "data", ".", "Role", ",", "error", ")", "{", "// All top level delegations (ex: targets/level1) are stored exclusively in targets.json", "_", ",", "ok", ":=", "r", ".", "tufRepo",...
// GetDelegationRoles returns the keys and roles of the repository's delegations // Also converts key IDs to canonical key IDs to keep consistent with signing prompts
[ "GetDelegationRoles", "returns", "the", "keys", "and", "roles", "of", "the", "repository", "s", "delegations", "Also", "converts", "key", "IDs", "to", "canonical", "key", "IDs", "to", "keep", "consistent", "with", "signing", "prompts" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/reader.go#L231-L257
train
theupdateframework/notary
cmd/notary-server/config.go
getRequiredGunPrefixes
func getRequiredGunPrefixes(configuration *viper.Viper) ([]string, error) { prefixes := configuration.GetStringSlice("repositories.gun_prefixes") for _, prefix := range prefixes { p := path.Clean(strings.TrimSpace(prefix)) if p+"/" != prefix || strings.HasPrefix(p, "/") || strings.HasPrefix(p, "..") { return n...
go
func getRequiredGunPrefixes(configuration *viper.Viper) ([]string, error) { prefixes := configuration.GetStringSlice("repositories.gun_prefixes") for _, prefix := range prefixes { p := path.Clean(strings.TrimSpace(prefix)) if p+"/" != prefix || strings.HasPrefix(p, "/") || strings.HasPrefix(p, "..") { return n...
[ "func", "getRequiredGunPrefixes", "(", "configuration", "*", "viper", ".", "Viper", ")", "(", "[", "]", "string", ",", "error", ")", "{", "prefixes", ":=", "configuration", ".", "GetStringSlice", "(", "\"", "\"", ")", "\n", "for", "_", ",", "prefix", ":=...
// gets the required gun prefixes accepted by this server
[ "gets", "the", "required", "gun", "prefixes", "accepted", "by", "this", "server" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-server/config.go#L32-L41
train
theupdateframework/notary
cmd/notary-server/config.go
getAddrAndTLSConfig
func getAddrAndTLSConfig(configuration *viper.Viper) (string, *tls.Config, error) { httpAddr := configuration.GetString("server.http_addr") if httpAddr == "" { return "", nil, fmt.Errorf("http listen address required for server") } tlsConfig, err := utils.ParseServerTLS(configuration, false) if err != nil { r...
go
func getAddrAndTLSConfig(configuration *viper.Viper) (string, *tls.Config, error) { httpAddr := configuration.GetString("server.http_addr") if httpAddr == "" { return "", nil, fmt.Errorf("http listen address required for server") } tlsConfig, err := utils.ParseServerTLS(configuration, false) if err != nil { r...
[ "func", "getAddrAndTLSConfig", "(", "configuration", "*", "viper", ".", "Viper", ")", "(", "string", ",", "*", "tls", ".", "Config", ",", "error", ")", "{", "httpAddr", ":=", "configuration", ".", "GetString", "(", "\"", "\"", ")", "\n", "if", "httpAddr"...
// get the address for the HTTP server, and parses the optional TLS // configuration for the server - if no TLS configuration is specified, // TLS is not enabled.
[ "get", "the", "address", "for", "the", "HTTP", "server", "and", "parses", "the", "optional", "TLS", "configuration", "for", "the", "server", "-", "if", "no", "TLS", "configuration", "is", "specified", "TLS", "is", "not", "enabled", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-server/config.go#L46-L57
train
theupdateframework/notary
cmd/notary-server/config.go
grpcTLS
func grpcTLS(configuration *viper.Viper) (*tls.Config, error) { rootCA := utils.GetPathRelativeToConfig(configuration, "trust_service.tls_ca_file") clientCert := utils.GetPathRelativeToConfig(configuration, "trust_service.tls_client_cert") clientKey := utils.GetPathRelativeToConfig(configuration, "trust_service.tls_...
go
func grpcTLS(configuration *viper.Viper) (*tls.Config, error) { rootCA := utils.GetPathRelativeToConfig(configuration, "trust_service.tls_ca_file") clientCert := utils.GetPathRelativeToConfig(configuration, "trust_service.tls_client_cert") clientKey := utils.GetPathRelativeToConfig(configuration, "trust_service.tls_...
[ "func", "grpcTLS", "(", "configuration", "*", "viper", ".", "Viper", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "rootCA", ":=", "utils", ".", "GetPathRelativeToConfig", "(", "configuration", ",", "\"", "\"", ")", "\n", "clientCert", ":=...
// sets up TLS for the GRPC connection to notary-signer
[ "sets", "up", "TLS", "for", "the", "GRPC", "connection", "to", "notary", "-", "signer" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-server/config.go#L60-L80
train
theupdateframework/notary
cmd/notary-server/config.go
getStore
func getStore(configuration *viper.Viper, hRegister healthRegister, doBootstrap bool) ( storage.MetaStore, error) { var store storage.MetaStore backend := configuration.GetString("storage.backend") logrus.Infof("Using %s backend", backend) switch backend { case notary.MemoryBackend: return storage.NewMemStorag...
go
func getStore(configuration *viper.Viper, hRegister healthRegister, doBootstrap bool) ( storage.MetaStore, error) { var store storage.MetaStore backend := configuration.GetString("storage.backend") logrus.Infof("Using %s backend", backend) switch backend { case notary.MemoryBackend: return storage.NewMemStorag...
[ "func", "getStore", "(", "configuration", "*", "viper", ".", "Viper", ",", "hRegister", "healthRegister", ",", "doBootstrap", "bool", ")", "(", "storage", ".", "MetaStore", ",", "error", ")", "{", "var", "store", "storage", ".", "MetaStore", "\n", "backend",...
// parses the configuration and returns a backing store for the TUF files
[ "parses", "the", "configuration", "and", "returns", "a", "backing", "store", "for", "the", "TUF", "files" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-server/config.go#L83-L130
train
theupdateframework/notary
cmd/notary-server/config.go
getTrustService
func getTrustService(configuration *viper.Viper, sFactory signerFactory, hRegister healthRegister) (signed.CryptoService, string, error) { switch configuration.GetString("trust_service.type") { case "local": logrus.Info("Using local signing service, which requires ED25519. " + "Ignoring all other trust_service...
go
func getTrustService(configuration *viper.Viper, sFactory signerFactory, hRegister healthRegister) (signed.CryptoService, string, error) { switch configuration.GetString("trust_service.type") { case "local": logrus.Info("Using local signing service, which requires ED25519. " + "Ignoring all other trust_service...
[ "func", "getTrustService", "(", "configuration", "*", "viper", ".", "Viper", ",", "sFactory", "signerFactory", ",", "hRegister", "healthRegister", ")", "(", "signed", ".", "CryptoService", ",", "string", ",", "error", ")", "{", "switch", "configuration", ".", ...
// parses the configuration and determines which trust service and key algorithm // to return
[ "parses", "the", "configuration", "and", "determines", "which", "trust", "service", "and", "key", "algorithm", "to", "return" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-server/config.go#L145-L194
train
theupdateframework/notary
trustmanager/remoteks/client.go
NewRemoteStore
func NewRemoteStore(server string, tlsConfig *tls.Config, timeout time.Duration) (*RemoteStore, error) { cc, err := grpc.Dial( server, grpc.WithTransportCredentials( credentials.NewTLS(tlsConfig), ), grpc.WithBlock(), ) if err != nil { return nil, err } if timeout == 0 { timeout = DefaultTimeout } ...
go
func NewRemoteStore(server string, tlsConfig *tls.Config, timeout time.Duration) (*RemoteStore, error) { cc, err := grpc.Dial( server, grpc.WithTransportCredentials( credentials.NewTLS(tlsConfig), ), grpc.WithBlock(), ) if err != nil { return nil, err } if timeout == 0 { timeout = DefaultTimeout } ...
[ "func", "NewRemoteStore", "(", "server", "string", ",", "tlsConfig", "*", "tls", ".", "Config", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "RemoteStore", ",", "error", ")", "{", "cc", ",", "err", ":=", "grpc", ".", "Dial", "(", "server", ...
// NewRemoteStore instantiates a RemoteStore.
[ "NewRemoteStore", "instantiates", "a", "RemoteStore", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/client.go#L32-L51
train
theupdateframework/notary
trustmanager/remoteks/client.go
getContext
func (s *RemoteStore) getContext() (context.Context, context.CancelFunc) { return context.WithTimeout(context.Background(), s.timeout) }
go
func (s *RemoteStore) getContext() (context.Context, context.CancelFunc) { return context.WithTimeout(context.Background(), s.timeout) }
[ "func", "(", "s", "*", "RemoteStore", ")", "getContext", "(", ")", "(", "context", ".", "Context", ",", "context", ".", "CancelFunc", ")", "{", "return", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "s", ".", "timeou...
// getContext returns a context with the timeout configured at initialization // time of the RemoteStore.
[ "getContext", "returns", "a", "context", "with", "the", "timeout", "configured", "at", "initialization", "time", "of", "the", "RemoteStore", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/client.go#L55-L57
train
theupdateframework/notary
trustmanager/remoteks/client.go
Set
func (s *RemoteStore) Set(fileName string, data []byte) error { sm := &SetMsg{ FileName: fileName, Data: data, } ctx, cancel := s.getContext() defer cancel() _, err := s.client.Set(ctx, sm) return err }
go
func (s *RemoteStore) Set(fileName string, data []byte) error { sm := &SetMsg{ FileName: fileName, Data: data, } ctx, cancel := s.getContext() defer cancel() _, err := s.client.Set(ctx, sm) return err }
[ "func", "(", "s", "*", "RemoteStore", ")", "Set", "(", "fileName", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "sm", ":=", "&", "SetMsg", "{", "FileName", ":", "fileName", ",", "Data", ":", "data", ",", "}", "\n", "ctx", ",", "can...
// Set stores the data using the provided fileName
[ "Set", "stores", "the", "data", "using", "the", "provided", "fileName" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/client.go#L60-L69
train
theupdateframework/notary
trustmanager/remoteks/client.go
Remove
func (s *RemoteStore) Remove(fileName string) error { fm := &FileNameMsg{ FileName: fileName, } ctx, cancel := s.getContext() defer cancel() _, err := s.client.Remove(ctx, fm) return err }
go
func (s *RemoteStore) Remove(fileName string) error { fm := &FileNameMsg{ FileName: fileName, } ctx, cancel := s.getContext() defer cancel() _, err := s.client.Remove(ctx, fm) return err }
[ "func", "(", "s", "*", "RemoteStore", ")", "Remove", "(", "fileName", "string", ")", "error", "{", "fm", ":=", "&", "FileNameMsg", "{", "FileName", ":", "fileName", ",", "}", "\n", "ctx", ",", "cancel", ":=", "s", ".", "getContext", "(", ")", "\n", ...
// Remove deletes a file from the store relative to the store's base directory. // Paths are expected to be cleaned server side.
[ "Remove", "deletes", "a", "file", "from", "the", "store", "relative", "to", "the", "store", "s", "base", "directory", ".", "Paths", "are", "expected", "to", "be", "cleaned", "server", "side", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/client.go#L73-L81
train
theupdateframework/notary
trustmanager/remoteks/client.go
Get
func (s *RemoteStore) Get(fileName string) ([]byte, error) { fm := &FileNameMsg{ FileName: fileName, } ctx, cancel := s.getContext() defer cancel() bm, err := s.client.Get(ctx, fm) if err != nil { return nil, err } return bm.Data, nil }
go
func (s *RemoteStore) Get(fileName string) ([]byte, error) { fm := &FileNameMsg{ FileName: fileName, } ctx, cancel := s.getContext() defer cancel() bm, err := s.client.Get(ctx, fm) if err != nil { return nil, err } return bm.Data, nil }
[ "func", "(", "s", "*", "RemoteStore", ")", "Get", "(", "fileName", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "fm", ":=", "&", "FileNameMsg", "{", "FileName", ":", "fileName", ",", "}", "\n", "ctx", ",", "cancel", ":=", "s", "....
// Get returns the file content found at fileName relative to the base directory // of the file store. Paths are expected to be cleaned server side.
[ "Get", "returns", "the", "file", "content", "found", "at", "fileName", "relative", "to", "the", "base", "directory", "of", "the", "file", "store", ".", "Paths", "are", "expected", "to", "be", "cleaned", "server", "side", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/client.go#L85-L96
train
theupdateframework/notary
trustmanager/remoteks/client.go
ListFiles
func (s *RemoteStore) ListFiles() []string { logrus.Infof("listing files from %s", s.location) ctx, cancel := s.getContext() defer cancel() fl, err := s.client.ListFiles(ctx, &google_protobuf.Empty{}) if err != nil { logrus.Errorf("error listing files from %s: %s", s.location, err.Error()) return nil } retur...
go
func (s *RemoteStore) ListFiles() []string { logrus.Infof("listing files from %s", s.location) ctx, cancel := s.getContext() defer cancel() fl, err := s.client.ListFiles(ctx, &google_protobuf.Empty{}) if err != nil { logrus.Errorf("error listing files from %s: %s", s.location, err.Error()) return nil } retur...
[ "func", "(", "s", "*", "RemoteStore", ")", "ListFiles", "(", ")", "[", "]", "string", "{", "logrus", ".", "Infof", "(", "\"", "\"", ",", "s", ".", "location", ")", "\n", "ctx", ",", "cancel", ":=", "s", ".", "getContext", "(", ")", "\n", "defer",...
// ListFiles returns a list of paths relative to the base directory of the // filestore. Any of these paths must be retrievable via the // Storage.Get method.
[ "ListFiles", "returns", "a", "list", "of", "paths", "relative", "to", "the", "base", "directory", "of", "the", "filestore", ".", "Any", "of", "these", "paths", "must", "be", "retrievable", "via", "the", "Storage", ".", "Get", "method", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/remoteks/client.go#L101-L111
train
theupdateframework/notary
client/client.go
NewRepository
func NewRepository(gun data.GUN, baseURL string, remoteStore store.RemoteStore, cache store.MetadataStore, trustPinning trustpinning.TrustPinConfig, cryptoService signed.CryptoService, cl changelist.Changelist) (Repository, error) { // Repo's remote store is either a valid remote store or an OfflineStore if remoteS...
go
func NewRepository(gun data.GUN, baseURL string, remoteStore store.RemoteStore, cache store.MetadataStore, trustPinning trustpinning.TrustPinConfig, cryptoService signed.CryptoService, cl changelist.Changelist) (Repository, error) { // Repo's remote store is either a valid remote store or an OfflineStore if remoteS...
[ "func", "NewRepository", "(", "gun", "data", ".", "GUN", ",", "baseURL", "string", ",", "remoteStore", "store", ".", "RemoteStore", ",", "cache", "store", ".", "MetadataStore", ",", "trustPinning", "trustpinning", ".", "TrustPinConfig", ",", "cryptoService", "si...
// NewRepository is the base method that returns a new notary repository. // It expects an initialized cache. In case of a nil remote store, a default // offline store is used.
[ "NewRepository", "is", "the", "base", "method", "that", "returns", "a", "new", "notary", "repository", ".", "It", "expects", "an", "initialized", "cache", ".", "In", "case", "of", "a", "nil", "remote", "store", "a", "default", "offline", "store", "is", "us...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L97-L121
train
theupdateframework/notary
client/client.go
ListTargets
func (r *repository) ListTargets(roles ...data.RoleName) ([]*TargetWithRole, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).ListTargets(roles...) }
go
func (r *repository) ListTargets(roles ...data.RoleName) ([]*TargetWithRole, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).ListTargets(roles...) }
[ "func", "(", "r", "*", "repository", ")", "ListTargets", "(", "roles", "...", "data", ".", "RoleName", ")", "(", "[", "]", "*", "TargetWithRole", ",", "error", ")", "{", "if", "err", ":=", "r", ".", "updateTUF", "(", "false", ")", ";", "err", "!=",...
// ListTargets calls update first before listing targets
[ "ListTargets", "calls", "update", "first", "before", "listing", "targets" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L146-L151
train
theupdateframework/notary
client/client.go
GetTargetByName
func (r *repository) GetTargetByName(name string, roles ...data.RoleName) (*TargetWithRole, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).GetTargetByName(name, roles...) }
go
func (r *repository) GetTargetByName(name string, roles ...data.RoleName) (*TargetWithRole, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).GetTargetByName(name, roles...) }
[ "func", "(", "r", "*", "repository", ")", "GetTargetByName", "(", "name", "string", ",", "roles", "...", "data", ".", "RoleName", ")", "(", "*", "TargetWithRole", ",", "error", ")", "{", "if", "err", ":=", "r", ".", "updateTUF", "(", "false", ")", ";...
// GetTargetByName calls update first before getting target by name
[ "GetTargetByName", "calls", "update", "first", "before", "getting", "target", "by", "name" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L154-L159
train
theupdateframework/notary
client/client.go
GetAllTargetMetadataByName
func (r *repository) GetAllTargetMetadataByName(name string) ([]TargetSignedStruct, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).GetAllTargetMetadataByName(name) }
go
func (r *repository) GetAllTargetMetadataByName(name string) ([]TargetSignedStruct, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).GetAllTargetMetadataByName(name) }
[ "func", "(", "r", "*", "repository", ")", "GetAllTargetMetadataByName", "(", "name", "string", ")", "(", "[", "]", "TargetSignedStruct", ",", "error", ")", "{", "if", "err", ":=", "r", ".", "updateTUF", "(", "false", ")", ";", "err", "!=", "nil", "{", ...
// GetAllTargetMetadataByName calls update first before getting targets by name
[ "GetAllTargetMetadataByName", "calls", "update", "first", "before", "getting", "targets", "by", "name" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L162-L168
train
theupdateframework/notary
client/client.go
ListRoles
func (r *repository) ListRoles() ([]RoleWithSignatures, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).ListRoles() }
go
func (r *repository) ListRoles() ([]RoleWithSignatures, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).ListRoles() }
[ "func", "(", "r", "*", "repository", ")", "ListRoles", "(", ")", "(", "[", "]", "RoleWithSignatures", ",", "error", ")", "{", "if", "err", ":=", "r", ".", "updateTUF", "(", "false", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", ...
// ListRoles calls update first before getting roles
[ "ListRoles", "calls", "update", "first", "before", "getting", "roles" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L171-L176
train
theupdateframework/notary
client/client.go
GetDelegationRoles
func (r *repository) GetDelegationRoles() ([]data.Role, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).GetDelegationRoles() }
go
func (r *repository) GetDelegationRoles() ([]data.Role, error) { if err := r.updateTUF(false); err != nil { return nil, err } return NewReadOnly(r.tufRepo).GetDelegationRoles() }
[ "func", "(", "r", "*", "repository", ")", "GetDelegationRoles", "(", ")", "(", "[", "]", "data", ".", "Role", ",", "error", ")", "{", "if", "err", ":=", "r", ".", "updateTUF", "(", "false", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",",...
// GetDelegationRoles calls update first before getting all delegation roles
[ "GetDelegationRoles", "calls", "update", "first", "before", "getting", "all", "delegation", "roles" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L179-L184
train
theupdateframework/notary
client/client.go
NewTarget
func NewTarget(targetName, targetPath string, targetCustom *canonicaljson.RawMessage) (*Target, error) { b, err := ioutil.ReadFile(targetPath) if err != nil { return nil, err } meta, err := data.NewFileMeta(bytes.NewBuffer(b), data.NotaryDefaultHashes...) if err != nil { return nil, err } return &Target{Na...
go
func NewTarget(targetName, targetPath string, targetCustom *canonicaljson.RawMessage) (*Target, error) { b, err := ioutil.ReadFile(targetPath) if err != nil { return nil, err } meta, err := data.NewFileMeta(bytes.NewBuffer(b), data.NotaryDefaultHashes...) if err != nil { return nil, err } return &Target{Na...
[ "func", "NewTarget", "(", "targetName", ",", "targetPath", "string", ",", "targetCustom", "*", "canonicaljson", ".", "RawMessage", ")", "(", "*", "Target", ",", "error", ")", "{", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "targetPath", ")", ...
// NewTarget is a helper method that returns a Target
[ "NewTarget", "is", "a", "helper", "method", "that", "returns", "a", "Target" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L187-L199
train
theupdateframework/notary
client/client.go
rootCertKey
func rootCertKey(gun data.GUN, privKey data.PrivateKey) (data.PublicKey, error) { // Hard-coded policy: the generated certificate expires in 10 years. startTime := time.Now() cert, err := cryptoservice.GenerateCertificate( privKey, gun, startTime, startTime.Add(notary.Year*10)) if err != nil { return nil, err ...
go
func rootCertKey(gun data.GUN, privKey data.PrivateKey) (data.PublicKey, error) { // Hard-coded policy: the generated certificate expires in 10 years. startTime := time.Now() cert, err := cryptoservice.GenerateCertificate( privKey, gun, startTime, startTime.Add(notary.Year*10)) if err != nil { return nil, err ...
[ "func", "rootCertKey", "(", "gun", "data", ".", "GUN", ",", "privKey", "data", ".", "PrivateKey", ")", "(", "data", ".", "PublicKey", ",", "error", ")", "{", "// Hard-coded policy: the generated certificate expires in 10 years.", "startTime", ":=", "time", ".", "N...
// rootCertKey generates the corresponding certificate for the private key given the privKey and repo's GUN
[ "rootCertKey", "generates", "the", "corresponding", "certificate", "for", "the", "private", "key", "given", "the", "privKey", "and", "repo", "s", "GUN" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L202-L217
train
theupdateframework/notary
client/client.go
initialize
func (r *repository) initialize(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { // currently we only support server managing timestamps and snapshots, and // nothing else - timestamps are always managed by the server, and implicit // (do not have to be passed in as part...
go
func (r *repository) initialize(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { // currently we only support server managing timestamps and snapshots, and // nothing else - timestamps are always managed by the server, and implicit // (do not have to be passed in as part...
[ "func", "(", "r", "*", "repository", ")", "initialize", "(", "rootKeyIDs", "[", "]", "string", ",", "rootCerts", "[", "]", "data", ".", "PublicKey", ",", "serverManagedRoles", "...", "data", ".", "RoleName", ")", "error", "{", "// currently we only support ser...
// initialize initializes the notary repository with a set of rootkeys, root certificates and roles.
[ "initialize", "initializes", "the", "notary", "repository", "with", "a", "set", "of", "rootkeys", "root", "certificates", "and", "roles", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L225-L298
train
theupdateframework/notary
client/client.go
createNewPublicKeyFromKeyIDs
func (r *repository) createNewPublicKeyFromKeyIDs(keyIDs []string) ([]data.PublicKey, error) { publicKeys := []data.PublicKey{} privKeys, err := getAllPrivKeys(keyIDs, r.GetCryptoService()) if err != nil { return nil, err } for _, privKey := range privKeys { rootKey, err := rootCertKey(r.gun, privKey) if e...
go
func (r *repository) createNewPublicKeyFromKeyIDs(keyIDs []string) ([]data.PublicKey, error) { publicKeys := []data.PublicKey{} privKeys, err := getAllPrivKeys(keyIDs, r.GetCryptoService()) if err != nil { return nil, err } for _, privKey := range privKeys { rootKey, err := rootCertKey(r.gun, privKey) if e...
[ "func", "(", "r", "*", "repository", ")", "createNewPublicKeyFromKeyIDs", "(", "keyIDs", "[", "]", "string", ")", "(", "[", "]", "data", ".", "PublicKey", ",", "error", ")", "{", "publicKeys", ":=", "[", "]", "data", ".", "PublicKey", "{", "}", "\n\n",...
// createNewPublicKeyFromKeyIDs generates a set of public keys corresponding to the given list of // key IDs existing in the repository's CryptoService. // the public keys returned are ordered to correspond to the keyIDs
[ "createNewPublicKeyFromKeyIDs", "generates", "a", "set", "of", "public", "keys", "corresponding", "to", "the", "given", "list", "of", "key", "IDs", "existing", "in", "the", "repository", "s", "CryptoService", ".", "the", "public", "keys", "returned", "are", "ord...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L303-L319
train
theupdateframework/notary
client/client.go
keyExistsInList
func keyExistsInList(cert data.PublicKey, ids map[string]bool) error { pubKeyID, err := utils.CanonicalKeyID(cert) if err != nil { return fmt.Errorf("failed to obtain the public key id from the given certificate: %v", err) } if _, ok := ids[pubKeyID]; ok { return nil } return errKeyNotFound{} }
go
func keyExistsInList(cert data.PublicKey, ids map[string]bool) error { pubKeyID, err := utils.CanonicalKeyID(cert) if err != nil { return fmt.Errorf("failed to obtain the public key id from the given certificate: %v", err) } if _, ok := ids[pubKeyID]; ok { return nil } return errKeyNotFound{} }
[ "func", "keyExistsInList", "(", "cert", "data", ".", "PublicKey", ",", "ids", "map", "[", "string", "]", "bool", ")", "error", "{", "pubKeyID", ",", "err", ":=", "utils", ".", "CanonicalKeyID", "(", "cert", ")", "\n", "if", "err", "!=", "nil", "{", "...
// keyExistsInList returns the id of the private key in ids that matches the public key // otherwise return empty string
[ "keyExistsInList", "returns", "the", "id", "of", "the", "private", "key", "in", "ids", "that", "matches", "the", "public", "key", "otherwise", "return", "empty", "string" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L371-L380
train
theupdateframework/notary
client/client.go
InitializeWithCertificate
func (r *repository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { // If we explicitly pass in certificate(s) but not key, then look keys up using certificate if len(rootKeyIDs) == 0 && len(rootCerts) != 0 { rootKeyIDs = []string{} availa...
go
func (r *repository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { // If we explicitly pass in certificate(s) but not key, then look keys up using certificate if len(rootKeyIDs) == 0 && len(rootCerts) != 0 { rootKeyIDs = []string{} availa...
[ "func", "(", "r", "*", "repository", ")", "InitializeWithCertificate", "(", "rootKeyIDs", "[", "]", "string", ",", "rootCerts", "[", "]", "data", ".", "PublicKey", ",", "serverManagedRoles", "...", "data", ".", "RoleName", ")", "error", "{", "// If we explicit...
// InitializeWithCertificate initializes the repository with root keys and their corresponding certificates
[ "InitializeWithCertificate", "initializes", "the", "repository", "with", "root", "keys", "and", "their", "corresponding", "certificates" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L383-L403
train
theupdateframework/notary
client/client.go
addChange
func addChange(cl changelist.Changelist, c changelist.Change, roles ...data.RoleName) error { if len(roles) == 0 { roles = []data.RoleName{data.CanonicalTargetsRole} } var changes []changelist.Change for _, role := range roles { // Ensure we can only add targets to the CanonicalTargetsRole, // or a Delegatio...
go
func addChange(cl changelist.Changelist, c changelist.Change, roles ...data.RoleName) error { if len(roles) == 0 { roles = []data.RoleName{data.CanonicalTargetsRole} } var changes []changelist.Change for _, role := range roles { // Ensure we can only add targets to the CanonicalTargetsRole, // or a Delegatio...
[ "func", "addChange", "(", "cl", "changelist", ".", "Changelist", ",", "c", "changelist", ".", "Change", ",", "roles", "...", "data", ".", "RoleName", ")", "error", "{", "if", "len", "(", "roles", ")", "==", "0", "{", "roles", "=", "[", "]", "data", ...
// adds a TUF Change template to the given roles
[ "adds", "a", "TUF", "Change", "template", "to", "the", "given", "roles" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L468-L499
train
theupdateframework/notary
client/client.go
AddTarget
func (r *repository) AddTarget(target *Target, roles ...data.RoleName) error { if len(target.Hashes) == 0 { return fmt.Errorf("no hashes specified for target \"%s\"", target.Name) } logrus.Debugf("Adding target \"%s\" with sha256 \"%x\" and size %d bytes.\n", target.Name, target.Hashes["sha256"], target.Length) ...
go
func (r *repository) AddTarget(target *Target, roles ...data.RoleName) error { if len(target.Hashes) == 0 { return fmt.Errorf("no hashes specified for target \"%s\"", target.Name) } logrus.Debugf("Adding target \"%s\" with sha256 \"%x\" and size %d bytes.\n", target.Name, target.Hashes["sha256"], target.Length) ...
[ "func", "(", "r", "*", "repository", ")", "AddTarget", "(", "target", "*", "Target", ",", "roles", "...", "data", ".", "RoleName", ")", "error", "{", "if", "len", "(", "target", ".", "Hashes", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(...
// AddTarget creates new changelist entries to add a target to the given roles // in the repository when the changelist gets applied at publish time. // If roles are unspecified, the default role is "targets"
[ "AddTarget", "creates", "new", "changelist", "entries", "to", "add", "a", "target", "to", "the", "given", "roles", "in", "the", "repository", "when", "the", "changelist", "gets", "applied", "at", "publish", "time", ".", "If", "roles", "are", "unspecified", "...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L504-L520
train
theupdateframework/notary
client/client.go
RemoveTarget
func (r *repository) RemoveTarget(targetName string, roles ...data.RoleName) error { logrus.Debugf("Removing target \"%s\"", targetName) template := changelist.NewTUFChange(changelist.ActionDelete, "", changelist.TypeTargetsTarget, targetName, nil) return addChange(r.changelist, template, roles...) }
go
func (r *repository) RemoveTarget(targetName string, roles ...data.RoleName) error { logrus.Debugf("Removing target \"%s\"", targetName) template := changelist.NewTUFChange(changelist.ActionDelete, "", changelist.TypeTargetsTarget, targetName, nil) return addChange(r.changelist, template, roles...) }
[ "func", "(", "r", "*", "repository", ")", "RemoveTarget", "(", "targetName", "string", ",", "roles", "...", "data", ".", "RoleName", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\\\"", "\\\"", "\"", ",", "targetName", ")", "\n", "template", ...
// RemoveTarget creates new changelist entries to remove a target from the given // roles in the repository when the changelist gets applied at publish time. // If roles are unspecified, the default role is "target".
[ "RemoveTarget", "creates", "new", "changelist", "entries", "to", "remove", "a", "target", "from", "the", "given", "roles", "in", "the", "repository", "when", "the", "changelist", "gets", "applied", "at", "publish", "time", ".", "If", "roles", "are", "unspecifi...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L525-L530
train
theupdateframework/notary
client/client.go
getRemoteStore
func (r *repository) getRemoteStore() store.RemoteStore { if r.remoteStore != nil { return r.remoteStore } r.remoteStore = &store.OfflineStore{} return r.remoteStore }
go
func (r *repository) getRemoteStore() store.RemoteStore { if r.remoteStore != nil { return r.remoteStore } r.remoteStore = &store.OfflineStore{} return r.remoteStore }
[ "func", "(", "r", "*", "repository", ")", "getRemoteStore", "(", ")", "store", ".", "RemoteStore", "{", "if", "r", ".", "remoteStore", "!=", "nil", "{", "return", "r", ".", "remoteStore", "\n", "}", "\n\n", "r", ".", "remoteStore", "=", "&", "store", ...
// getRemoteStore returns the remoteStore of a repository if valid or // or an OfflineStore otherwise
[ "getRemoteStore", "returns", "the", "remoteStore", "of", "a", "repository", "if", "valid", "or", "or", "an", "OfflineStore", "otherwise" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L539-L547
train
theupdateframework/notary
client/client.go
Publish
func (r *repository) Publish() error { if err := r.publish(r.changelist); err != nil { return err } if err := r.changelist.Clear(""); err != nil { // This is not a critical problem when only a single host is pushing // but will cause weird behaviour if changelist cleanup is failing // and there are multiple ...
go
func (r *repository) Publish() error { if err := r.publish(r.changelist); err != nil { return err } if err := r.changelist.Clear(""); err != nil { // This is not a critical problem when only a single host is pushing // but will cause weird behaviour if changelist cleanup is failing // and there are multiple ...
[ "func", "(", "r", "*", "repository", ")", "Publish", "(", ")", "error", "{", "if", "err", ":=", "r", ".", "publish", "(", "r", ".", "changelist", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "r", ".", ...
// Publish pushes the local changes in signed material to the remote notary-server // Conceptually it performs an operation similar to a `git rebase`
[ "Publish", "pushes", "the", "local", "changes", "in", "signed", "material", "to", "the", "remote", "notary", "-", "server", "Conceptually", "it", "performs", "an", "operation", "similar", "to", "a", "git", "rebase" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L551-L562
train
theupdateframework/notary
client/client.go
publish
func (r *repository) publish(cl changelist.Changelist) error { var initialPublish bool // update first before publishing if err := r.updateTUF(true); err != nil { // If the remote is not aware of the repo, then this is being published // for the first time. Try to initialize the repository before publishing. ...
go
func (r *repository) publish(cl changelist.Changelist) error { var initialPublish bool // update first before publishing if err := r.updateTUF(true); err != nil { // If the remote is not aware of the repo, then this is being published // for the first time. Try to initialize the repository before publishing. ...
[ "func", "(", "r", "*", "repository", ")", "publish", "(", "cl", "changelist", ".", "Changelist", ")", "error", "{", "var", "initialPublish", "bool", "\n", "// update first before publishing", "if", "err", ":=", "r", ".", "updateTUF", "(", "true", ")", ";", ...
// publish pushes the changes in the given changelist to the remote notary-server // Conceptually it performs an operation similar to a `git rebase`
[ "publish", "pushes", "the", "changes", "in", "the", "given", "changelist", "to", "the", "remote", "notary", "-", "server", "Conceptually", "it", "performs", "an", "operation", "similar", "to", "a", "git", "rebase" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L566-L649
train
theupdateframework/notary
client/client.go
getOldRootPublicKeys
func getOldRootPublicKeys(root *data.SignedRoot) data.KeyList { rootRole, err := root.BuildBaseRole(data.CanonicalRootRole) if err != nil { return nil } return rootRole.ListKeys() }
go
func getOldRootPublicKeys(root *data.SignedRoot) data.KeyList { rootRole, err := root.BuildBaseRole(data.CanonicalRootRole) if err != nil { return nil } return rootRole.ListKeys() }
[ "func", "getOldRootPublicKeys", "(", "root", "*", "data", ".", "SignedRoot", ")", "data", ".", "KeyList", "{", "rootRole", ",", "err", ":=", "root", ".", "BuildBaseRole", "(", "data", ".", "CanonicalRootRole", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// get all the saved previous roles keys < the current root version
[ "get", "all", "the", "saved", "previous", "roles", "keys", "<", "the", "current", "root", "version" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L743-L749
train
theupdateframework/notary
client/client.go
saveMetadata
func (r *repository) saveMetadata(ignoreSnapshot bool) error { logrus.Debugf("Saving changes to Trusted Collection.") rootJSON, err := serializeCanonicalRole(r.tufRepo, data.CanonicalRootRole, nil) if err != nil { return err } err = r.cache.Set(data.CanonicalRootRole.String(), rootJSON) if err != nil { retur...
go
func (r *repository) saveMetadata(ignoreSnapshot bool) error { logrus.Debugf("Saving changes to Trusted Collection.") rootJSON, err := serializeCanonicalRole(r.tufRepo, data.CanonicalRootRole, nil) if err != nil { return err } err = r.cache.Set(data.CanonicalRootRole.String(), rootJSON) if err != nil { retur...
[ "func", "(", "r", "*", "repository", ")", "saveMetadata", "(", "ignoreSnapshot", "bool", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "rootJSON", ",", "err", ":=", "serializeCanonicalRole", "(", "r", ".", "tufRepo", ",", "dat...
// saveMetadata saves contents of r.tufRepo onto the local disk, creating // signatures as necessary, possibly prompting for passphrases.
[ "saveMetadata", "saves", "contents", "of", "r", ".", "tufRepo", "onto", "the", "local", "disk", "creating", "signatures", "as", "necessary", "possibly", "prompting", "for", "passphrases", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L801-L841
train
theupdateframework/notary
client/client.go
pubKeyListForRotation
func (r *repository) pubKeyListForRotation(role data.RoleName, serverManaged bool, newKeys []string) (pubKeyList data.KeyList, err error) { var pubKey data.PublicKey // If server manages the key being rotated, request a rotation and return the new key if serverManaged { remote := r.getRemoteStore() pubKey, err ...
go
func (r *repository) pubKeyListForRotation(role data.RoleName, serverManaged bool, newKeys []string) (pubKeyList data.KeyList, err error) { var pubKey data.PublicKey // If server manages the key being rotated, request a rotation and return the new key if serverManaged { remote := r.getRemoteStore() pubKey, err ...
[ "func", "(", "r", "*", "repository", ")", "pubKeyListForRotation", "(", "role", "data", ".", "RoleName", ",", "serverManaged", "bool", ",", "newKeys", "[", "]", "string", ")", "(", "pubKeyList", "data", ".", "KeyList", ",", "err", "error", ")", "{", "var...
// Given a set of new keys to rotate to and a set of keys to drop, returns the list of current keys to use
[ "Given", "a", "set", "of", "new", "keys", "to", "rotate", "to", "and", "a", "set", "of", "keys", "to", "drop", "returns", "the", "list", "of", "current", "keys", "to", "use" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L866-L909
train
theupdateframework/notary
client/client.go
DeleteTrustData
func DeleteTrustData(baseDir string, gun data.GUN, URL string, rt http.RoundTripper, deleteRemote bool) error { localRepo := filepath.Join(baseDir, tufDir, filepath.FromSlash(gun.String())) // Remove the tufRepoPath directory, which includes local TUF metadata files and changelist information if err := os.RemoveAll(...
go
func DeleteTrustData(baseDir string, gun data.GUN, URL string, rt http.RoundTripper, deleteRemote bool) error { localRepo := filepath.Join(baseDir, tufDir, filepath.FromSlash(gun.String())) // Remove the tufRepoPath directory, which includes local TUF metadata files and changelist information if err := os.RemoveAll(...
[ "func", "DeleteTrustData", "(", "baseDir", "string", ",", "gun", "data", ".", "GUN", ",", "URL", "string", ",", "rt", "http", ".", "RoundTripper", ",", "deleteRemote", "bool", ")", "error", "{", "localRepo", ":=", "filepath", ".", "Join", "(", "baseDir", ...
// DeleteTrustData removes the trust data stored for this repo in the TUF cache on the client side // Note that we will not delete any private key material from local storage
[ "DeleteTrustData", "removes", "the", "trust", "data", "stored", "for", "this", "repo", "in", "the", "TUF", "cache", "on", "the", "client", "side", "Note", "that", "we", "will", "not", "delete", "any", "private", "key", "material", "from", "local", "storage" ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/client.go#L974-L992
train
theupdateframework/notary
tuf/tuf.go
NewRepo
func NewRepo(cryptoService signed.CryptoService) *Repo { return &Repo{ Targets: make(map[data.RoleName]*data.SignedTargets), cryptoService: cryptoService, } }
go
func NewRepo(cryptoService signed.CryptoService) *Repo { return &Repo{ Targets: make(map[data.RoleName]*data.SignedTargets), cryptoService: cryptoService, } }
[ "func", "NewRepo", "(", "cryptoService", "signed", ".", "CryptoService", ")", "*", "Repo", "{", "return", "&", "Repo", "{", "Targets", ":", "make", "(", "map", "[", "data", ".", "RoleName", "]", "*", "data", ".", "SignedTargets", ")", ",", "cryptoService...
// NewRepo initializes a Repo instance with a CryptoService. // If the Repo will only be used for reading, the CryptoService // can be nil.
[ "NewRepo", "initializes", "a", "Repo", "instance", "with", "a", "CryptoService", ".", "If", "the", "Repo", "will", "only", "be", "used", "for", "reading", "the", "CryptoService", "can", "be", "nil", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L76-L81
train
theupdateframework/notary
tuf/tuf.go
AddBaseKeys
func (tr *Repo) AddBaseKeys(role data.RoleName, keys ...data.PublicKey) error { if tr.Root == nil { return ErrNotLoaded{Role: data.CanonicalRootRole} } ids := []string{} for _, k := range keys { // Store only the public portion tr.Root.Signed.Keys[k.ID()] = k tr.Root.Signed.Roles[role].KeyIDs = append(tr.Ro...
go
func (tr *Repo) AddBaseKeys(role data.RoleName, keys ...data.PublicKey) error { if tr.Root == nil { return ErrNotLoaded{Role: data.CanonicalRootRole} } ids := []string{} for _, k := range keys { // Store only the public portion tr.Root.Signed.Keys[k.ID()] = k tr.Root.Signed.Roles[role].KeyIDs = append(tr.Ro...
[ "func", "(", "tr", "*", "Repo", ")", "AddBaseKeys", "(", "role", "data", ".", "RoleName", ",", "keys", "...", "data", ".", "PublicKey", ")", "error", "{", "if", "tr", ".", "Root", "==", "nil", "{", "return", "ErrNotLoaded", "{", "Role", ":", "data", ...
// AddBaseKeys is used to add keys to the role in root.json
[ "AddBaseKeys", "is", "used", "to", "add", "keys", "to", "the", "role", "in", "root", ".", "json" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L84-L114
train
theupdateframework/notary
tuf/tuf.go
ReplaceBaseKeys
func (tr *Repo) ReplaceBaseKeys(role data.RoleName, keys ...data.PublicKey) error { r, err := tr.GetBaseRole(role) if err != nil { return err } err = tr.RemoveBaseKeys(role, r.ListKeyIDs()...) if err != nil { return err } return tr.AddBaseKeys(role, keys...) }
go
func (tr *Repo) ReplaceBaseKeys(role data.RoleName, keys ...data.PublicKey) error { r, err := tr.GetBaseRole(role) if err != nil { return err } err = tr.RemoveBaseKeys(role, r.ListKeyIDs()...) if err != nil { return err } return tr.AddBaseKeys(role, keys...) }
[ "func", "(", "tr", "*", "Repo", ")", "ReplaceBaseKeys", "(", "role", "data", ".", "RoleName", ",", "keys", "...", "data", ".", "PublicKey", ")", "error", "{", "r", ",", "err", ":=", "tr", ".", "GetBaseRole", "(", "role", ")", "\n", "if", "err", "!=...
// ReplaceBaseKeys is used to replace all keys for the given role with the new keys
[ "ReplaceBaseKeys", "is", "used", "to", "replace", "all", "keys", "for", "the", "given", "role", "with", "the", "new", "keys" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L117-L127
train
theupdateframework/notary
tuf/tuf.go
RemoveBaseKeys
func (tr *Repo) RemoveBaseKeys(role data.RoleName, keyIDs ...string) error { if tr.Root == nil { return ErrNotLoaded{Role: data.CanonicalRootRole} } var keep []string toDelete := make(map[string]struct{}) emptyStruct := struct{}{} // remove keys from specified role for _, k := range keyIDs { toDelete[k] = em...
go
func (tr *Repo) RemoveBaseKeys(role data.RoleName, keyIDs ...string) error { if tr.Root == nil { return ErrNotLoaded{Role: data.CanonicalRootRole} } var keep []string toDelete := make(map[string]struct{}) emptyStruct := struct{}{} // remove keys from specified role for _, k := range keyIDs { toDelete[k] = em...
[ "func", "(", "tr", "*", "Repo", ")", "RemoveBaseKeys", "(", "role", "data", ".", "RoleName", ",", "keyIDs", "...", "string", ")", "error", "{", "if", "tr", ".", "Root", "==", "nil", "{", "return", "ErrNotLoaded", "{", "Role", ":", "data", ".", "Canon...
// RemoveBaseKeys is used to remove keys from the roles in root.json
[ "RemoveBaseKeys", "is", "used", "to", "remove", "keys", "from", "the", "roles", "in", "root", ".", "json" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L130-L183
train
theupdateframework/notary
tuf/tuf.go
GetBaseRole
func (tr *Repo) GetBaseRole(name data.RoleName) (data.BaseRole, error) { if !data.ValidRole(name) { return data.BaseRole{}, data.ErrInvalidRole{Role: name, Reason: "invalid base role name"} } if tr.Root == nil { return data.BaseRole{}, ErrNotLoaded{data.CanonicalRootRole} } // Find the role data public keys fo...
go
func (tr *Repo) GetBaseRole(name data.RoleName) (data.BaseRole, error) { if !data.ValidRole(name) { return data.BaseRole{}, data.ErrInvalidRole{Role: name, Reason: "invalid base role name"} } if tr.Root == nil { return data.BaseRole{}, ErrNotLoaded{data.CanonicalRootRole} } // Find the role data public keys fo...
[ "func", "(", "tr", "*", "Repo", ")", "GetBaseRole", "(", "name", "data", ".", "RoleName", ")", "(", "data", ".", "BaseRole", ",", "error", ")", "{", "if", "!", "data", ".", "ValidRole", "(", "name", ")", "{", "return", "data", ".", "BaseRole", "{",...
// GetBaseRole gets a base role from this repo's metadata
[ "GetBaseRole", "gets", "a", "base", "role", "from", "this", "repo", "s", "metadata" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L203-L217
train
theupdateframework/notary
tuf/tuf.go
GetDelegationRole
func (tr *Repo) GetDelegationRole(name data.RoleName) (data.DelegationRole, error) { if !data.IsDelegation(name) { return data.DelegationRole{}, data.ErrInvalidRole{Role: name, Reason: "invalid delegation name"} } if tr.Root == nil { return data.DelegationRole{}, ErrNotLoaded{data.CanonicalRootRole} } _, ok :=...
go
func (tr *Repo) GetDelegationRole(name data.RoleName) (data.DelegationRole, error) { if !data.IsDelegation(name) { return data.DelegationRole{}, data.ErrInvalidRole{Role: name, Reason: "invalid delegation name"} } if tr.Root == nil { return data.DelegationRole{}, ErrNotLoaded{data.CanonicalRootRole} } _, ok :=...
[ "func", "(", "tr", "*", "Repo", ")", "GetDelegationRole", "(", "name", "data", ".", "RoleName", ")", "(", "data", ".", "DelegationRole", ",", "error", ")", "{", "if", "!", "data", ".", "IsDelegation", "(", "name", ")", "{", "return", "data", ".", "De...
// GetDelegationRole gets a delegation role from this repo's metadata, walking from the targets role down to the delegation itself
[ "GetDelegationRole", "gets", "a", "delegation", "role", "from", "this", "repo", "s", "metadata", "walking", "from", "the", "targets", "role", "down", "to", "the", "delegation", "itself" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L220-L282
train
theupdateframework/notary
tuf/tuf.go
GetAllLoadedRoles
func (tr *Repo) GetAllLoadedRoles() []*data.Role { var res []*data.Role if tr.Root == nil { // if root isn't loaded, we should consider we have no loaded roles because we can't // trust any other state that might be present return res } for name, rr := range tr.Root.Signed.Roles { res = append(res, &data.Ro...
go
func (tr *Repo) GetAllLoadedRoles() []*data.Role { var res []*data.Role if tr.Root == nil { // if root isn't loaded, we should consider we have no loaded roles because we can't // trust any other state that might be present return res } for name, rr := range tr.Root.Signed.Roles { res = append(res, &data.Ro...
[ "func", "(", "tr", "*", "Repo", ")", "GetAllLoadedRoles", "(", ")", "[", "]", "*", "data", ".", "Role", "{", "var", "res", "[", "]", "*", "data", ".", "Role", "\n", "if", "tr", ".", "Root", "==", "nil", "{", "// if root isn't loaded, we should consider...
// GetAllLoadedRoles returns a list of all role entries loaded in this TUF repo, could be empty
[ "GetAllLoadedRoles", "returns", "a", "list", "of", "all", "role", "entries", "loaded", "in", "this", "TUF", "repo", "could", "be", "empty" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L285-L304
train
theupdateframework/notary
tuf/tuf.go
delegationUpdateVisitor
func delegationUpdateVisitor(roleName data.RoleName, addKeys data.KeyList, removeKeys, addPaths, removePaths []string, clearAllPaths bool, newThreshold int) walkVisitorFunc { return func(tgt *data.SignedTargets, validRole data.DelegationRole) interface{} { var err error // Validate the changes underneath this rest...
go
func delegationUpdateVisitor(roleName data.RoleName, addKeys data.KeyList, removeKeys, addPaths, removePaths []string, clearAllPaths bool, newThreshold int) walkVisitorFunc { return func(tgt *data.SignedTargets, validRole data.DelegationRole) interface{} { var err error // Validate the changes underneath this rest...
[ "func", "delegationUpdateVisitor", "(", "roleName", "data", ".", "RoleName", ",", "addKeys", "data", ".", "KeyList", ",", "removeKeys", ",", "addPaths", ",", "removePaths", "[", "]", "string", ",", "clearAllPaths", "bool", ",", "newThreshold", "int", ")", "wal...
// Walk to parent, and either create or update this delegation. We can only create a new delegation if we're given keys // Ensure all updates are valid, by checking against parent ancestor paths and ensuring the keys meet the role threshold.
[ "Walk", "to", "parent", "and", "either", "create", "or", "update", "this", "delegation", ".", "We", "can", "only", "create", "a", "new", "delegation", "if", "we", "re", "given", "keys", "Ensure", "all", "updates", "are", "valid", "by", "checking", "against...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L308-L378
train
theupdateframework/notary
tuf/tuf.go
UpdateDelegationPaths
func (tr *Repo) UpdateDelegationPaths(roleName data.RoleName, addPaths, removePaths []string, clearPaths bool) error { if !data.IsDelegation(roleName) { return data.ErrInvalidRole{Role: roleName, Reason: "not a valid delegated role"} } parent := roleName.Parent() if err := tr.VerifyCanSign(parent); err != nil { ...
go
func (tr *Repo) UpdateDelegationPaths(roleName data.RoleName, addPaths, removePaths []string, clearPaths bool) error { if !data.IsDelegation(roleName) { return data.ErrInvalidRole{Role: roleName, Reason: "not a valid delegated role"} } parent := roleName.Parent() if err := tr.VerifyCanSign(parent); err != nil { ...
[ "func", "(", "tr", "*", "Repo", ")", "UpdateDelegationPaths", "(", "roleName", "data", ".", "RoleName", ",", "addPaths", ",", "removePaths", "[", "]", "string", ",", "clearPaths", "bool", ")", "error", "{", "if", "!", "data", ".", "IsDelegation", "(", "r...
// UpdateDelegationPaths updates the appropriate delegation's paths. // It is not allowed to create a new delegation.
[ "UpdateDelegationPaths", "updates", "the", "appropriate", "delegation", "s", "paths", ".", "It", "is", "not", "allowed", "to", "create", "a", "new", "delegation", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L482-L507
train
theupdateframework/notary
tuf/tuf.go
DeleteDelegation
func (tr *Repo) DeleteDelegation(roleName data.RoleName) error { if !data.IsDelegation(roleName) { return data.ErrInvalidRole{Role: roleName, Reason: "not a valid delegated role"} } parent := roleName.Parent() if err := tr.VerifyCanSign(parent); err != nil { return err } // delete delegated data from Target...
go
func (tr *Repo) DeleteDelegation(roleName data.RoleName) error { if !data.IsDelegation(roleName) { return data.ErrInvalidRole{Role: roleName, Reason: "not a valid delegated role"} } parent := roleName.Parent() if err := tr.VerifyCanSign(parent); err != nil { return err } // delete delegated data from Target...
[ "func", "(", "tr", "*", "Repo", ")", "DeleteDelegation", "(", "roleName", "data", ".", "RoleName", ")", "error", "{", "if", "!", "data", ".", "IsDelegation", "(", "roleName", ")", "{", "return", "data", ".", "ErrInvalidRole", "{", "Role", ":", "roleName"...
// DeleteDelegation removes a delegated targets role from its parent // targets object. It also deletes the delegation from the snapshot. // DeleteDelegation will only make use of the role Name field.
[ "DeleteDelegation", "removes", "a", "delegated", "targets", "role", "from", "its", "parent", "targets", "object", ".", "It", "also", "deletes", "the", "delegation", "from", "the", "snapshot", ".", "DeleteDelegation", "will", "only", "make", "use", "of", "the", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L512-L551
train
theupdateframework/notary
tuf/tuf.go
InitRoot
func (tr *Repo) InitRoot(root, timestamp, snapshot, targets data.BaseRole, consistent bool) error { rootRoles := make(map[data.RoleName]*data.RootRole) rootKeys := make(map[string]data.PublicKey) for _, r := range []data.BaseRole{root, timestamp, snapshot, targets} { rootRoles[r.Name] = &data.RootRole{ Thresho...
go
func (tr *Repo) InitRoot(root, timestamp, snapshot, targets data.BaseRole, consistent bool) error { rootRoles := make(map[data.RoleName]*data.RootRole) rootKeys := make(map[string]data.PublicKey) for _, r := range []data.BaseRole{root, timestamp, snapshot, targets} { rootRoles[r.Name] = &data.RootRole{ Thresho...
[ "func", "(", "tr", "*", "Repo", ")", "InitRoot", "(", "root", ",", "timestamp", ",", "snapshot", ",", "targets", "data", ".", "BaseRole", ",", "consistent", "bool", ")", "error", "{", "rootRoles", ":=", "make", "(", "map", "[", "data", ".", "RoleName",...
// InitRoot initializes an empty root file with the 4 core roles passed to the // method, and the consistent flag.
[ "InitRoot", "initializes", "an", "empty", "root", "file", "with", "the", "4", "core", "roles", "passed", "to", "the", "method", "and", "the", "consistent", "flag", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L555-L575
train