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
tuf/data/keys.go
NewRSAPublicKey
func NewRSAPublicKey(public []byte) *RSAPublicKey { return &RSAPublicKey{ TUFKey: TUFKey{ Type: RSAKey, Value: KeyPair{ Public: public, Private: nil, }, }, } }
go
func NewRSAPublicKey(public []byte) *RSAPublicKey { return &RSAPublicKey{ TUFKey: TUFKey{ Type: RSAKey, Value: KeyPair{ Public: public, Private: nil, }, }, } }
[ "func", "NewRSAPublicKey", "(", "public", "[", "]", "byte", ")", "*", "RSAPublicKey", "{", "return", "&", "RSAPublicKey", "{", "TUFKey", ":", "TUFKey", "{", "Type", ":", "RSAKey", ",", "Value", ":", "KeyPair", "{", "Public", ":", "public", ",", "Private"...
// NewRSAPublicKey initializes a new public key with the RSA type
[ "NewRSAPublicKey", "initializes", "a", "new", "public", "key", "with", "the", "RSA", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L301-L311
train
theupdateframework/notary
tuf/data/keys.go
NewRSAx509PublicKey
func NewRSAx509PublicKey(public []byte) *RSAx509PublicKey { return &RSAx509PublicKey{ TUFKey: TUFKey{ Type: RSAx509Key, Value: KeyPair{ Public: public, Private: nil, }, }, } }
go
func NewRSAx509PublicKey(public []byte) *RSAx509PublicKey { return &RSAx509PublicKey{ TUFKey: TUFKey{ Type: RSAx509Key, Value: KeyPair{ Public: public, Private: nil, }, }, } }
[ "func", "NewRSAx509PublicKey", "(", "public", "[", "]", "byte", ")", "*", "RSAx509PublicKey", "{", "return", "&", "RSAx509PublicKey", "{", "TUFKey", ":", "TUFKey", "{", "Type", ":", "RSAx509Key", ",", "Value", ":", "KeyPair", "{", "Public", ":", "public", ...
// NewRSAx509PublicKey initializes a new public key with the RSAx509Key type
[ "NewRSAx509PublicKey", "initializes", "a", "new", "public", "key", "with", "the", "RSAx509Key", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L314-L324
train
theupdateframework/notary
tuf/data/keys.go
NewED25519PublicKey
func NewED25519PublicKey(public []byte) *ED25519PublicKey { return &ED25519PublicKey{ TUFKey: TUFKey{ Type: ED25519Key, Value: KeyPair{ Public: public, Private: nil, }, }, } }
go
func NewED25519PublicKey(public []byte) *ED25519PublicKey { return &ED25519PublicKey{ TUFKey: TUFKey{ Type: ED25519Key, Value: KeyPair{ Public: public, Private: nil, }, }, } }
[ "func", "NewED25519PublicKey", "(", "public", "[", "]", "byte", ")", "*", "ED25519PublicKey", "{", "return", "&", "ED25519PublicKey", "{", "TUFKey", ":", "TUFKey", "{", "Type", ":", "ED25519Key", ",", "Value", ":", "KeyPair", "{", "Public", ":", "public", ...
// NewED25519PublicKey initializes a new public key with the ED25519Key type
[ "NewED25519PublicKey", "initializes", "a", "new", "public", "key", "with", "the", "ED25519Key", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L327-L337
train
theupdateframework/notary
tuf/data/keys.go
NewECDSAPrivateKey
func NewECDSAPrivateKey(public PublicKey, private []byte) (*ECDSAPrivateKey, error) { switch public.(type) { case *ECDSAPublicKey, *ECDSAx509PublicKey: default: return nil, errors.New("invalid public key type provided to NewECDSAPrivateKey") } ecdsaPrivKey, err := x509.ParseECPrivateKey(private) if err != nil {...
go
func NewECDSAPrivateKey(public PublicKey, private []byte) (*ECDSAPrivateKey, error) { switch public.(type) { case *ECDSAPublicKey, *ECDSAx509PublicKey: default: return nil, errors.New("invalid public key type provided to NewECDSAPrivateKey") } ecdsaPrivKey, err := x509.ParseECPrivateKey(private) if err != nil {...
[ "func", "NewECDSAPrivateKey", "(", "public", "PublicKey", ",", "private", "[", "]", "byte", ")", "(", "*", "ECDSAPrivateKey", ",", "error", ")", "{", "switch", "public", ".", "(", "type", ")", "{", "case", "*", "ECDSAPublicKey", ",", "*", "ECDSAx509PublicK...
// NewECDSAPrivateKey initializes a new ECDSA private key
[ "NewECDSAPrivateKey", "initializes", "a", "new", "ECDSA", "private", "key" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L375-L390
train
theupdateframework/notary
tuf/data/keys.go
NewRSAPrivateKey
func NewRSAPrivateKey(public PublicKey, private []byte) (*RSAPrivateKey, error) { switch public.(type) { case *RSAPublicKey, *RSAx509PublicKey: default: return nil, errors.New("invalid public key type provided to NewRSAPrivateKey") } rsaPrivKey, err := x509.ParsePKCS1PrivateKey(private) if err != nil { return...
go
func NewRSAPrivateKey(public PublicKey, private []byte) (*RSAPrivateKey, error) { switch public.(type) { case *RSAPublicKey, *RSAx509PublicKey: default: return nil, errors.New("invalid public key type provided to NewRSAPrivateKey") } rsaPrivKey, err := x509.ParsePKCS1PrivateKey(private) if err != nil { return...
[ "func", "NewRSAPrivateKey", "(", "public", "PublicKey", ",", "private", "[", "]", "byte", ")", "(", "*", "RSAPrivateKey", ",", "error", ")", "{", "switch", "public", ".", "(", "type", ")", "{", "case", "*", "RSAPublicKey", ",", "*", "RSAx509PublicKey", "...
// NewRSAPrivateKey initialized a new RSA private key
[ "NewRSAPrivateKey", "initialized", "a", "new", "RSA", "private", "key" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L393-L408
train
theupdateframework/notary
tuf/data/keys.go
NewED25519PrivateKey
func NewED25519PrivateKey(public ED25519PublicKey, private []byte) (*ED25519PrivateKey, error) { return &ED25519PrivateKey{ ED25519PublicKey: public, privateKey: privateKey{private: private}, }, nil }
go
func NewED25519PrivateKey(public ED25519PublicKey, private []byte) (*ED25519PrivateKey, error) { return &ED25519PrivateKey{ ED25519PublicKey: public, privateKey: privateKey{private: private}, }, nil }
[ "func", "NewED25519PrivateKey", "(", "public", "ED25519PublicKey", ",", "private", "[", "]", "byte", ")", "(", "*", "ED25519PrivateKey", ",", "error", ")", "{", "return", "&", "ED25519PrivateKey", "{", "ED25519PublicKey", ":", "public", ",", "privateKey", ":", ...
// NewED25519PrivateKey initialized a new ED25519 private key
[ "NewED25519PrivateKey", "initialized", "a", "new", "ED25519", "private", "key" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L411-L416
train
theupdateframework/notary
tuf/data/keys.go
Sign
func (k ECDSAPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { ecdsaPrivKey, ok := k.CryptoSigner().(*ecdsa.PrivateKey) if !ok { return nil, errors.New("signer was based on the wrong key type") } hashed := sha256.Sum256(msg) sigASN1, err := ecdsaPrivKey.Sign(ran...
go
func (k ECDSAPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { ecdsaPrivKey, ok := k.CryptoSigner().(*ecdsa.PrivateKey) if !ok { return nil, errors.New("signer was based on the wrong key type") } hashed := sha256.Sum256(msg) sigASN1, err := ecdsaPrivKey.Sign(ran...
[ "func", "(", "k", "ECDSAPrivateKey", ")", "Sign", "(", "rand", "io", ".", "Reader", ",", "msg", "[", "]", "byte", ",", "opts", "crypto", ".", "SignerOpts", ")", "(", "signature", "[", "]", "byte", ",", "err", "error", ")", "{", "ecdsaPrivKey", ",", ...
// Sign creates an ecdsa signature
[ "Sign", "creates", "an", "ecdsa", "signature" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L445-L471
train
theupdateframework/notary
tuf/data/keys.go
Sign
func (k RSAPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { hashed := sha256.Sum256(msg) if opts == nil { opts = &rsa.PSSOptions{ SaltLength: rsa.PSSSaltLengthEqualsHash, Hash: crypto.SHA256, } } return k.CryptoSigner().Sign(rand, hashed[:], opts) ...
go
func (k RSAPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { hashed := sha256.Sum256(msg) if opts == nil { opts = &rsa.PSSOptions{ SaltLength: rsa.PSSSaltLengthEqualsHash, Hash: crypto.SHA256, } } return k.CryptoSigner().Sign(rand, hashed[:], opts) ...
[ "func", "(", "k", "RSAPrivateKey", ")", "Sign", "(", "rand", "io", ".", "Reader", ",", "msg", "[", "]", "byte", ",", "opts", "crypto", ".", "SignerOpts", ")", "(", "signature", "[", "]", "byte", ",", "err", "error", ")", "{", "hashed", ":=", "sha25...
// Sign creates an rsa signature
[ "Sign", "creates", "an", "rsa", "signature" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L474-L483
train
theupdateframework/notary
tuf/data/keys.go
Sign
func (k ED25519PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { priv := make([]byte, ed25519.PrivateKeySize) // The ed25519 key is serialized as public key then private key, so just use private key here. copy(priv, k.private[ed25519.PublicKeySize:]) return ed25519...
go
func (k ED25519PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { priv := make([]byte, ed25519.PrivateKeySize) // The ed25519 key is serialized as public key then private key, so just use private key here. copy(priv, k.private[ed25519.PublicKeySize:]) return ed25519...
[ "func", "(", "k", "ED25519PrivateKey", ")", "Sign", "(", "rand", "io", ".", "Reader", ",", "msg", "[", "]", "byte", ",", "opts", "crypto", ".", "SignerOpts", ")", "(", "signature", "[", "]", "byte", ",", "err", "error", ")", "{", "priv", ":=", "mak...
// Sign creates an ed25519 signature
[ "Sign", "creates", "an", "ed25519", "signature" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L486-L491
train
theupdateframework/notary
tuf/data/keys.go
Sign
func (k UnknownPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { return nil, errors.New("unknown key type, cannot sign") }
go
func (k UnknownPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) { return nil, errors.New("unknown key type, cannot sign") }
[ "func", "(", "k", "UnknownPrivateKey", ")", "Sign", "(", "rand", "io", ".", "Reader", ",", "msg", "[", "]", "byte", ",", "opts", "crypto", ".", "SignerOpts", ")", "(", "signature", "[", "]", "byte", ",", "err", "error", ")", "{", "return", "nil", "...
// Sign on an UnknownPrivateKey raises an error because the client does not // know how to sign with this key type.
[ "Sign", "on", "an", "UnknownPrivateKey", "raises", "an", "error", "because", "the", "client", "does", "not", "know", "how", "to", "sign", "with", "this", "key", "type", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L495-L497
train
theupdateframework/notary
tuf/data/keys.go
PublicKeyFromPrivate
func PublicKeyFromPrivate(pk PrivateKey) PublicKey { return typedPublicKey(TUFKey{ Type: pk.Algorithm(), Value: KeyPair{ Public: pk.Public(), Private: nil, }, }) }
go
func PublicKeyFromPrivate(pk PrivateKey) PublicKey { return typedPublicKey(TUFKey{ Type: pk.Algorithm(), Value: KeyPair{ Public: pk.Public(), Private: nil, }, }) }
[ "func", "PublicKeyFromPrivate", "(", "pk", "PrivateKey", ")", "PublicKey", "{", "return", "typedPublicKey", "(", "TUFKey", "{", "Type", ":", "pk", ".", "Algorithm", "(", ")", ",", "Value", ":", "KeyPair", "{", "Public", ":", "pk", ".", "Public", "(", ")"...
// PublicKeyFromPrivate returns a new TUFKey based on a private key, with // the private key bytes guaranteed to be nil.
[ "PublicKeyFromPrivate", "returns", "a", "new", "TUFKey", "based", "on", "a", "private", "key", "with", "the", "private", "key", "bytes", "guaranteed", "to", "be", "nil", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L521-L529
train
theupdateframework/notary
cmd/notary/prettyprint.go
prettyPrintKeys
func prettyPrintKeys(keyStores []trustmanager.KeyStore, writer io.Writer) { var info []keyInfo for _, store := range keyStores { for keyID, keyIDInfo := range store.ListKeys() { info = append(info, keyInfo{ role: keyIDInfo.Role, location: store.Name(), gun: keyIDInfo.Gun, keyID: keyI...
go
func prettyPrintKeys(keyStores []trustmanager.KeyStore, writer io.Writer) { var info []keyInfo for _, store := range keyStores { for keyID, keyIDInfo := range store.ListKeys() { info = append(info, keyInfo{ role: keyIDInfo.Role, location: store.Name(), gun: keyIDInfo.Gun, keyID: keyI...
[ "func", "prettyPrintKeys", "(", "keyStores", "[", "]", "trustmanager", ".", "KeyStore", ",", "writer", "io", ".", "Writer", ")", "{", "var", "info", "[", "]", "keyInfo", "\n\n", "for", "_", ",", "store", ":=", "range", "keyStores", "{", "for", "keyID", ...
// Given a list of KeyStores in order of listing preference, pretty-prints the // root keys and then the signing keys.
[ "Given", "a", "list", "of", "KeyStores", "in", "order", "of", "listing", "preference", "pretty", "-", "prints", "the", "root", "keys", "and", "then", "the", "signing", "keys", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/prettyprint.go#L98-L132
train
theupdateframework/notary
cmd/notary/prettyprint.go
prettyPrintTargets
func prettyPrintTargets(ts []*client.TargetWithRole, writer io.Writer) { if len(ts) == 0 { writer.Write([]byte("\nNo targets present in this repository.\n\n")) return } sort.Stable(targetsSorter(ts)) tw := initTabWriter([]string{"NAME", "DIGEST", "SIZE (BYTES)", "ROLE"}, writer) for _, t := range ts { fmt...
go
func prettyPrintTargets(ts []*client.TargetWithRole, writer io.Writer) { if len(ts) == 0 { writer.Write([]byte("\nNo targets present in this repository.\n\n")) return } sort.Stable(targetsSorter(ts)) tw := initTabWriter([]string{"NAME", "DIGEST", "SIZE (BYTES)", "ROLE"}, writer) for _, t := range ts { fmt...
[ "func", "prettyPrintTargets", "(", "ts", "[", "]", "*", "client", ".", "TargetWithRole", ",", "writer", "io", ".", "Writer", ")", "{", "if", "len", "(", "ts", ")", "==", "0", "{", "writer", ".", "Write", "(", "[", "]", "byte", "(", "\"", "\\n", "...
// Pretty-prints the sorted list of TargetWithRoles.
[ "Pretty", "-", "prints", "the", "sorted", "list", "of", "TargetWithRoles", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/prettyprint.go#L155-L176
train
theupdateframework/notary
cmd/notary/prettyprint.go
prettyPrintRoles
func prettyPrintRoles(rs []data.Role, writer io.Writer, roleType string) { if len(rs) == 0 { writer.Write([]byte(fmt.Sprintf("\nNo %s present in this repository.\n\n", roleType))) return } // this sorter works for Role types sort.Stable(roleSorter(rs)) tw := initTabWriter([]string{"ROLE", "PATHS", "KEY IDS",...
go
func prettyPrintRoles(rs []data.Role, writer io.Writer, roleType string) { if len(rs) == 0 { writer.Write([]byte(fmt.Sprintf("\nNo %s present in this repository.\n\n", roleType))) return } // this sorter works for Role types sort.Stable(roleSorter(rs)) tw := initTabWriter([]string{"ROLE", "PATHS", "KEY IDS",...
[ "func", "prettyPrintRoles", "(", "rs", "[", "]", "data", ".", "Role", ",", "writer", "io", ".", "Writer", ",", "roleType", "string", ")", "{", "if", "len", "(", "rs", ")", "==", "0", "{", "writer", ".", "Write", "(", "[", "]", "byte", "(", "fmt",...
// Pretty-prints the list of provided Roles
[ "Pretty", "-", "prints", "the", "list", "of", "provided", "Roles" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/prettyprint.go#L179-L210
train
theupdateframework/notary
cmd/notary/prettyprint.go
prettyPaths
func prettyPaths(paths []string) []string { // sort paths first sort.Strings(paths) pp := make([]string, 0, len(paths)) for _, path := range paths { // manually escape "" and designate that it is all paths with an extra print <all paths> if path == "" { path = "\"\" <all paths>" } pp = append(pp, path) ...
go
func prettyPaths(paths []string) []string { // sort paths first sort.Strings(paths) pp := make([]string, 0, len(paths)) for _, path := range paths { // manually escape "" and designate that it is all paths with an extra print <all paths> if path == "" { path = "\"\" <all paths>" } pp = append(pp, path) ...
[ "func", "prettyPaths", "(", "paths", "[", "]", "string", ")", "[", "]", "string", "{", "// sort paths first", "sort", ".", "Strings", "(", "paths", ")", "\n", "pp", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "paths", ")", ")"...
// Pretty-formats a list of delegation paths, and ensures the empty string is printed as "" in the console
[ "Pretty", "-", "formats", "a", "list", "of", "delegation", "paths", "and", "ensures", "the", "empty", "string", "is", "printed", "as", "in", "the", "console" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/prettyprint.go#L239-L251
train
theupdateframework/notary
client/helpers.go
getRemoteStore
func getRemoteStore(baseURL string, gun data.GUN, rt http.RoundTripper) (store.RemoteStore, error) { s, err := store.NewHTTPStore( baseURL+"/v2/"+gun.String()+"/_trust/tuf/", "", "json", "key", rt, ) if err != nil { return store.OfflineStore{}, err } return s, nil }
go
func getRemoteStore(baseURL string, gun data.GUN, rt http.RoundTripper) (store.RemoteStore, error) { s, err := store.NewHTTPStore( baseURL+"/v2/"+gun.String()+"/_trust/tuf/", "", "json", "key", rt, ) if err != nil { return store.OfflineStore{}, err } return s, nil }
[ "func", "getRemoteStore", "(", "baseURL", "string", ",", "gun", "data", ".", "GUN", ",", "rt", "http", ".", "RoundTripper", ")", "(", "store", ".", "RemoteStore", ",", "error", ")", "{", "s", ",", "err", ":=", "store", ".", "NewHTTPStore", "(", "baseUR...
// Use this to initialize remote HTTPStores from the config settings
[ "Use", "this", "to", "initialize", "remote", "HTTPStores", "from", "the", "config", "settings" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/helpers.go#L19-L31
train
theupdateframework/notary
client/helpers.go
getRemoteKey
func getRemoteKey(role data.RoleName, remote store.RemoteStore) (data.PublicKey, error) { rawPubKey, err := remote.GetKey(role) if err != nil { return nil, err } pubKey, err := data.UnmarshalPublicKey(rawPubKey) if err != nil { return nil, err } return pubKey, nil }
go
func getRemoteKey(role data.RoleName, remote store.RemoteStore) (data.PublicKey, error) { rawPubKey, err := remote.GetKey(role) if err != nil { return nil, err } pubKey, err := data.UnmarshalPublicKey(rawPubKey) if err != nil { return nil, err } return pubKey, nil }
[ "func", "getRemoteKey", "(", "role", "data", ".", "RoleName", ",", "remote", "store", ".", "RemoteStore", ")", "(", "data", ".", "PublicKey", ",", "error", ")", "{", "rawPubKey", ",", "err", ":=", "remote", ".", "GetKey", "(", "role", ")", "\n", "if", ...
// Fetches a public key from a remote store, given a gun and role
[ "Fetches", "a", "public", "key", "from", "a", "remote", "store", "given", "a", "gun", "and", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/helpers.go#L222-L234
train
theupdateframework/notary
client/helpers.go
rotateRemoteKey
func rotateRemoteKey(role data.RoleName, remote store.RemoteStore) (data.PublicKey, error) { rawPubKey, err := remote.RotateKey(role) if err != nil { return nil, err } pubKey, err := data.UnmarshalPublicKey(rawPubKey) if err != nil { return nil, err } return pubKey, nil }
go
func rotateRemoteKey(role data.RoleName, remote store.RemoteStore) (data.PublicKey, error) { rawPubKey, err := remote.RotateKey(role) if err != nil { return nil, err } pubKey, err := data.UnmarshalPublicKey(rawPubKey) if err != nil { return nil, err } return pubKey, nil }
[ "func", "rotateRemoteKey", "(", "role", "data", ".", "RoleName", ",", "remote", "store", ".", "RemoteStore", ")", "(", "data", ".", "PublicKey", ",", "error", ")", "{", "rawPubKey", ",", "err", ":=", "remote", ".", "RotateKey", "(", "role", ")", "\n", ...
// Rotates a private key in a remote store and returns the public key component
[ "Rotates", "a", "private", "key", "in", "a", "remote", "store", "and", "returns", "the", "public", "key", "component" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/helpers.go#L237-L249
train
theupdateframework/notary
client/helpers.go
serializeCanonicalRole
func serializeCanonicalRole(tufRepo *tuf.Repo, role data.RoleName, extraSigningKeys data.KeyList) (out []byte, err error) { var s *data.Signed switch { case role == data.CanonicalRootRole: s, err = tufRepo.SignRoot(data.DefaultExpires(role), extraSigningKeys) case role == data.CanonicalSnapshotRole: s, err = tu...
go
func serializeCanonicalRole(tufRepo *tuf.Repo, role data.RoleName, extraSigningKeys data.KeyList) (out []byte, err error) { var s *data.Signed switch { case role == data.CanonicalRootRole: s, err = tufRepo.SignRoot(data.DefaultExpires(role), extraSigningKeys) case role == data.CanonicalSnapshotRole: s, err = tu...
[ "func", "serializeCanonicalRole", "(", "tufRepo", "*", "tuf", ".", "Repo", ",", "role", "data", ".", "RoleName", ",", "extraSigningKeys", "data", ".", "KeyList", ")", "(", "out", "[", "]", "byte", ",", "err", "error", ")", "{", "var", "s", "*", "data",...
// signs and serializes the metadata for a canonical role in a TUF repo to JSON
[ "signs", "and", "serializes", "the", "metadata", "for", "a", "canonical", "role", "in", "a", "TUF", "repo", "to", "JSON" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/helpers.go#L252-L271
train
theupdateframework/notary
server/handlers/changefeed.go
Changefeed
func Changefeed(ctx context.Context, w http.ResponseWriter, r *http.Request) error { var ( vars = mux.Vars(r) logger = ctxu.GetLogger(ctx) qs = r.URL.Query() gun = vars["gun"] changeID = qs.Get("change_id") store, records, err = checkC...
go
func Changefeed(ctx context.Context, w http.ResponseWriter, r *http.Request) error { var ( vars = mux.Vars(r) logger = ctxu.GetLogger(ctx) qs = r.URL.Query() gun = vars["gun"] changeID = qs.Get("change_id") store, records, err = checkC...
[ "func", "Changefeed", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "var", "(", "vars", "=", "mux", ".", "Vars", "(", "r", ")", "\n", "logger", "=", "ctxu",...
// Changefeed returns a list of changes according to the provided filters
[ "Changefeed", "returns", "a", "list", "of", "changes", "according", "to", "the", "provided", "filters" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/changefeed.go#L24-L42
train
theupdateframework/notary
storage/rethinkdb/bootstrap.go
SetupDB
func SetupDB(session *gorethink.Session, dbName string, tables []Table) error { if err := makeDB(session, dbName); err != nil { return fmt.Errorf("unable to create database: %s", err) } cursor, err := gorethink.DB("rethinkdb").Table("server_config").Count().Run(session) if err != nil { return fmt.Errorf("unabl...
go
func SetupDB(session *gorethink.Session, dbName string, tables []Table) error { if err := makeDB(session, dbName); err != nil { return fmt.Errorf("unable to create database: %s", err) } cursor, err := gorethink.DB("rethinkdb").Table("server_config").Count().Run(session) if err != nil { return fmt.Errorf("unabl...
[ "func", "SetupDB", "(", "session", "*", "gorethink", ".", "Session", ",", "dbName", "string", ",", "tables", "[", "]", "Table", ")", "error", "{", "if", "err", ":=", "makeDB", "(", "session", ",", "dbName", ")", ";", "err", "!=", "nil", "{", "return"...
// SetupDB handles creating the database and creating all tables and indexes.
[ "SetupDB", "handles", "creating", "the", "database", "and", "creating", "all", "tables", "and", "indexes", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/rethinkdb/bootstrap.go#L146-L168
train
theupdateframework/notary
storage/rethinkdb/bootstrap.go
CreateAndGrantDBUser
func CreateAndGrantDBUser(session *gorethink.Session, dbName, username, password string) error { var err error logrus.Debugf("creating user %s for db %s", username, dbName) // If the password is empty, pass false to the password parameter if password == "" { err = gorethink.DB("rethinkdb").Table("users").Insert(m...
go
func CreateAndGrantDBUser(session *gorethink.Session, dbName, username, password string) error { var err error logrus.Debugf("creating user %s for db %s", username, dbName) // If the password is empty, pass false to the password parameter if password == "" { err = gorethink.DB("rethinkdb").Table("users").Insert(m...
[ "func", "CreateAndGrantDBUser", "(", "session", "*", "gorethink", ".", "Session", ",", "dbName", ",", "username", ",", "password", "string", ")", "error", "{", "var", "err", "error", "\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "username", ",", "...
// CreateAndGrantDBUser handles creating a rethink user and granting it permissions to the provided db.
[ "CreateAndGrantDBUser", "handles", "creating", "a", "rethink", "user", "and", "granting", "it", "permissions", "to", "the", "provided", "db", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/rethinkdb/bootstrap.go#L171-L196
train
theupdateframework/notary
utils/configuration.go
GetPathRelativeToConfig
func GetPathRelativeToConfig(configuration *viper.Viper, key string) string { configFile := configuration.ConfigFileUsed() p := configuration.GetString(key) if p == "" || filepath.IsAbs(p) { return p } return filepath.Clean(filepath.Join(filepath.Dir(configFile), p)) }
go
func GetPathRelativeToConfig(configuration *viper.Viper, key string) string { configFile := configuration.ConfigFileUsed() p := configuration.GetString(key) if p == "" || filepath.IsAbs(p) { return p } return filepath.Clean(filepath.Join(filepath.Dir(configFile), p)) }
[ "func", "GetPathRelativeToConfig", "(", "configuration", "*", "viper", ".", "Viper", ",", "key", "string", ")", "string", "{", "configFile", ":=", "configuration", ".", "ConfigFileUsed", "(", ")", "\n", "p", ":=", "configuration", ".", "GetString", "(", "key",...
// GetPathRelativeToConfig gets a configuration key which is a path, and if // it is not empty or an absolute path, returns the absolute path relative // to the configuration file
[ "GetPathRelativeToConfig", "gets", "a", "configuration", "key", "which", "is", "a", "path", "and", "if", "it", "is", "not", "empty", "or", "an", "absolute", "path", "returns", "the", "absolute", "path", "relative", "to", "the", "configuration", "file" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/configuration.go#L43-L50
train
theupdateframework/notary
utils/configuration.go
ParseLogLevel
func ParseLogLevel(configuration *viper.Viper, defaultLevel logrus.Level) ( logrus.Level, error) { logStr := configuration.GetString("logging.level") if logStr == "" { return defaultLevel, nil } return logrus.ParseLevel(logStr) }
go
func ParseLogLevel(configuration *viper.Viper, defaultLevel logrus.Level) ( logrus.Level, error) { logStr := configuration.GetString("logging.level") if logStr == "" { return defaultLevel, nil } return logrus.ParseLevel(logStr) }
[ "func", "ParseLogLevel", "(", "configuration", "*", "viper", ".", "Viper", ",", "defaultLevel", "logrus", ".", "Level", ")", "(", "logrus", ".", "Level", ",", "error", ")", "{", "logStr", ":=", "configuration", ".", "GetString", "(", "\"", "\"", ")", "\n...
// ParseLogLevel tries to parse out a log level from a Viper. If there is no // configuration, defaults to the provided error level
[ "ParseLogLevel", "tries", "to", "parse", "out", "a", "log", "level", "from", "a", "Viper", ".", "If", "there", "is", "no", "configuration", "defaults", "to", "the", "provided", "error", "level" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/configuration.go#L84-L92
train
theupdateframework/notary
utils/configuration.go
ParseBugsnag
func ParseBugsnag(configuration *viper.Viper) (*bugsnag.Configuration, error) { // can't unmarshal because we can't add tags to the bugsnag.Configuration // struct bugconf := bugsnag.Configuration{ APIKey: configuration.GetString("reporting.bugsnag.api_key"), ReleaseStage: configuration.GetString("reportin...
go
func ParseBugsnag(configuration *viper.Viper) (*bugsnag.Configuration, error) { // can't unmarshal because we can't add tags to the bugsnag.Configuration // struct bugconf := bugsnag.Configuration{ APIKey: configuration.GetString("reporting.bugsnag.api_key"), ReleaseStage: configuration.GetString("reportin...
[ "func", "ParseBugsnag", "(", "configuration", "*", "viper", ".", "Viper", ")", "(", "*", "bugsnag", ".", "Configuration", ",", "error", ")", "{", "// can't unmarshal because we can't add tags to the bugsnag.Configuration", "// struct", "bugconf", ":=", "bugsnag", ".", ...
// ParseBugsnag tries to parse out a Bugsnag Configuration from a Viper. // If no values are provided, returns a nil pointer.
[ "ParseBugsnag", "tries", "to", "parse", "out", "a", "Bugsnag", "Configuration", "from", "a", "Viper", ".", "If", "no", "values", "are", "provided", "returns", "a", "nil", "pointer", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/configuration.go#L183-L198
train
theupdateframework/notary
utils/configuration.go
SetUpBugsnag
func SetUpBugsnag(config *bugsnag.Configuration) error { if config != nil { bugsnag.Configure(*config) hook, err := bugsnag_hook.NewBugsnagHook() if err != nil { return err } logrus.AddHook(hook) logrus.Debug("Adding logrus hook for Bugsnag") } return nil }
go
func SetUpBugsnag(config *bugsnag.Configuration) error { if config != nil { bugsnag.Configure(*config) hook, err := bugsnag_hook.NewBugsnagHook() if err != nil { return err } logrus.AddHook(hook) logrus.Debug("Adding logrus hook for Bugsnag") } return nil }
[ "func", "SetUpBugsnag", "(", "config", "*", "bugsnag", ".", "Configuration", ")", "error", "{", "if", "config", "!=", "nil", "{", "bugsnag", ".", "Configure", "(", "*", "config", ")", "\n", "hook", ",", "err", ":=", "bugsnag_hook", ".", "NewBugsnagHook", ...
// SetUpBugsnag configures bugsnag and sets up a logrus hook
[ "SetUpBugsnag", "configures", "bugsnag", "and", "sets", "up", "a", "logrus", "hook" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/configuration.go#L211-L222
train
theupdateframework/notary
utils/configuration.go
ParseViper
func ParseViper(v *viper.Viper, configFile string) error { filename := filepath.Base(configFile) ext := filepath.Ext(configFile) configPath := filepath.Dir(configFile) v.SetConfigType(strings.TrimPrefix(ext, ".")) v.SetConfigName(strings.TrimSuffix(filename, ext)) v.AddConfigPath(configPath) if err := v.ReadIn...
go
func ParseViper(v *viper.Viper, configFile string) error { filename := filepath.Base(configFile) ext := filepath.Ext(configFile) configPath := filepath.Dir(configFile) v.SetConfigType(strings.TrimPrefix(ext, ".")) v.SetConfigName(strings.TrimSuffix(filename, ext)) v.AddConfigPath(configPath) if err := v.ReadIn...
[ "func", "ParseViper", "(", "v", "*", "viper", ".", "Viper", ",", "configFile", "string", ")", "error", "{", "filename", ":=", "filepath", ".", "Base", "(", "configFile", ")", "\n", "ext", ":=", "filepath", ".", "Ext", "(", "configFile", ")", "\n", "con...
// ParseViper tries to parse out a Viper from a configuration file.
[ "ParseViper", "tries", "to", "parse", "out", "a", "Viper", "from", "a", "configuration", "file", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/configuration.go#L225-L238
train
theupdateframework/notary
tuf/data/root.go
isValidRootStructure
func isValidRootStructure(r Root) error { expectedType := TUFTypes[CanonicalRootRole] if r.Type != expectedType { return ErrInvalidMetadata{ role: CanonicalRootRole, msg: fmt.Sprintf("expected type %s, not %s", expectedType, r.Type)} } if r.Version < 1 { return ErrInvalidMetadata{ role: CanonicalRootRole...
go
func isValidRootStructure(r Root) error { expectedType := TUFTypes[CanonicalRootRole] if r.Type != expectedType { return ErrInvalidMetadata{ role: CanonicalRootRole, msg: fmt.Sprintf("expected type %s, not %s", expectedType, r.Type)} } if r.Version < 1 { return ErrInvalidMetadata{ role: CanonicalRootRole...
[ "func", "isValidRootStructure", "(", "r", "Root", ")", "error", "{", "expectedType", ":=", "TUFTypes", "[", "CanonicalRootRole", "]", "\n", "if", "r", ".", "Type", "!=", "expectedType", "{", "return", "ErrInvalidMetadata", "{", "role", ":", "CanonicalRootRole", ...
// isValidRootStructure returns an error, or nil, depending on whether the content of the struct // is valid for root metadata. This does not check signatures or expiry, just that // the metadata content is valid.
[ "isValidRootStructure", "returns", "an", "error", "or", "nil", "depending", "on", "whether", "the", "content", "of", "the", "struct", "is", "valid", "for", "root", "metadata", ".", "This", "does", "not", "check", "signatures", "or", "expiry", "just", "that", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/root.go#L27-L52
train
theupdateframework/notary
tuf/data/root.go
NewRoot
func NewRoot(keys map[string]PublicKey, roles map[RoleName]*RootRole, consistent bool) (*SignedRoot, error) { signedRoot := &SignedRoot{ Signatures: make([]Signature, 0), Signed: Root{ SignedCommon: SignedCommon{ Type: TUFTypes[CanonicalRootRole], Version: 0, Expires: DefaultExpires(CanonicalRoot...
go
func NewRoot(keys map[string]PublicKey, roles map[RoleName]*RootRole, consistent bool) (*SignedRoot, error) { signedRoot := &SignedRoot{ Signatures: make([]Signature, 0), Signed: Root{ SignedCommon: SignedCommon{ Type: TUFTypes[CanonicalRootRole], Version: 0, Expires: DefaultExpires(CanonicalRoot...
[ "func", "NewRoot", "(", "keys", "map", "[", "string", "]", "PublicKey", ",", "roles", "map", "[", "RoleName", "]", "*", "RootRole", ",", "consistent", "bool", ")", "(", "*", "SignedRoot", ",", "error", ")", "{", "signedRoot", ":=", "&", "SignedRoot", "...
// NewRoot initializes a new SignedRoot with a set of keys, roles, and the consistent flag
[ "NewRoot", "initializes", "a", "new", "SignedRoot", "with", "a", "set", "of", "keys", "roles", "and", "the", "consistent", "flag" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/root.go#L73-L90
train
theupdateframework/notary
tuf/data/root.go
BuildBaseRole
func (r SignedRoot) BuildBaseRole(roleName RoleName) (BaseRole, error) { roleData, ok := r.Signed.Roles[roleName] if !ok { return BaseRole{}, ErrInvalidRole{Role: roleName, Reason: "role not found in root file"} } // Get all public keys for the base role from TUF metadata keyIDs := roleData.KeyIDs pubKeys := ma...
go
func (r SignedRoot) BuildBaseRole(roleName RoleName) (BaseRole, error) { roleData, ok := r.Signed.Roles[roleName] if !ok { return BaseRole{}, ErrInvalidRole{Role: roleName, Reason: "role not found in root file"} } // Get all public keys for the base role from TUF metadata keyIDs := roleData.KeyIDs pubKeys := ma...
[ "func", "(", "r", "SignedRoot", ")", "BuildBaseRole", "(", "roleName", "RoleName", ")", "(", "BaseRole", ",", "error", ")", "{", "roleData", ",", "ok", ":=", "r", ".", "Signed", ".", "Roles", "[", "roleName", "]", "\n", "if", "!", "ok", "{", "return"...
// BuildBaseRole returns a copy of a BaseRole using the information in this SignedRoot for the specified role name. // Will error for invalid role name or key metadata within this SignedRoot
[ "BuildBaseRole", "returns", "a", "copy", "of", "a", "BaseRole", "using", "the", "information", "in", "this", "SignedRoot", "for", "the", "specified", "role", "name", ".", "Will", "error", "for", "invalid", "role", "name", "or", "key", "metadata", "within", "...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/root.go#L94-L118
train
theupdateframework/notary
tuf/data/root.go
MarshalJSON
func (r SignedRoot) MarshalJSON() ([]byte, error) { signed, err := r.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
go
func (r SignedRoot) MarshalJSON() ([]byte, error) { signed, err := r.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
[ "func", "(", "r", "SignedRoot", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "signed", ",", "err", ":=", "r", ".", "ToSigned", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}"...
// MarshalJSON returns the serialized form of SignedRoot as bytes
[ "MarshalJSON", "returns", "the", "serialized", "form", "of", "SignedRoot", "as", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/root.go#L141-L147
train
theupdateframework/notary
tuf/data/root.go
RootFromSigned
func RootFromSigned(s *Signed) (*SignedRoot, error) { r := Root{} if s.Signed == nil { return nil, ErrInvalidMetadata{ role: CanonicalRootRole, msg: "root file contained an empty payload", } } if err := defaultSerializer.Unmarshal(*s.Signed, &r); err != nil { return nil, err } if err := isValidRootSt...
go
func RootFromSigned(s *Signed) (*SignedRoot, error) { r := Root{} if s.Signed == nil { return nil, ErrInvalidMetadata{ role: CanonicalRootRole, msg: "root file contained an empty payload", } } if err := defaultSerializer.Unmarshal(*s.Signed, &r); err != nil { return nil, err } if err := isValidRootSt...
[ "func", "RootFromSigned", "(", "s", "*", "Signed", ")", "(", "*", "SignedRoot", ",", "error", ")", "{", "r", ":=", "Root", "{", "}", "\n", "if", "s", ".", "Signed", "==", "nil", "{", "return", "nil", ",", "ErrInvalidMetadata", "{", "role", ":", "Ca...
// RootFromSigned fully unpacks a Signed object into a SignedRoot and ensures // that it is a valid SignedRoot
[ "RootFromSigned", "fully", "unpacks", "a", "Signed", "object", "into", "a", "SignedRoot", "and", "ensures", "that", "it", "is", "a", "valid", "SignedRoot" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/root.go#L151-L171
train
theupdateframework/notary
signer/api/find_key.go
findKeyByID
func findKeyByID(cryptoServices signer.CryptoServiceIndex, keyID *pb.KeyID) (data.PrivateKey, data.RoleName, error) { for _, service := range cryptoServices { key, role, err := service.GetPrivateKey(keyID.ID) if err == nil { return key, role, nil } } return nil, "", trustmanager.ErrKeyNotFound{KeyID: keyID...
go
func findKeyByID(cryptoServices signer.CryptoServiceIndex, keyID *pb.KeyID) (data.PrivateKey, data.RoleName, error) { for _, service := range cryptoServices { key, role, err := service.GetPrivateKey(keyID.ID) if err == nil { return key, role, nil } } return nil, "", trustmanager.ErrKeyNotFound{KeyID: keyID...
[ "func", "findKeyByID", "(", "cryptoServices", "signer", ".", "CryptoServiceIndex", ",", "keyID", "*", "pb", ".", "KeyID", ")", "(", "data", ".", "PrivateKey", ",", "data", ".", "RoleName", ",", "error", ")", "{", "for", "_", ",", "service", ":=", "range"...
// findKeyByID looks for the key with the given ID in each of the // signing services in sigServices. It returns the first matching key it finds, // or ErrInvalidKeyID if the key is not found in any of the signing services.
[ "findKeyByID", "looks", "for", "the", "key", "with", "the", "given", "ID", "in", "each", "of", "the", "signing", "services", "in", "sigServices", ".", "It", "returns", "the", "first", "matching", "key", "it", "finds", "or", "ErrInvalidKeyID", "if", "the", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/api/find_key.go#L14-L23
train
theupdateframework/notary
tuf/data/snapshot.go
IsValidSnapshotStructure
func IsValidSnapshotStructure(s Snapshot) error { expectedType := TUFTypes[CanonicalSnapshotRole] if s.Type != expectedType { return ErrInvalidMetadata{ role: CanonicalSnapshotRole, msg: fmt.Sprintf("expected type %s, not %s", expectedType, s.Type)} } if s.Version < 1 { return ErrInvalidMetadata{ role: C...
go
func IsValidSnapshotStructure(s Snapshot) error { expectedType := TUFTypes[CanonicalSnapshotRole] if s.Type != expectedType { return ErrInvalidMetadata{ role: CanonicalSnapshotRole, msg: fmt.Sprintf("expected type %s, not %s", expectedType, s.Type)} } if s.Version < 1 { return ErrInvalidMetadata{ role: C...
[ "func", "IsValidSnapshotStructure", "(", "s", "Snapshot", ")", "error", "{", "expectedType", ":=", "TUFTypes", "[", "CanonicalSnapshotRole", "]", "\n", "if", "s", ".", "Type", "!=", "expectedType", "{", "return", "ErrInvalidMetadata", "{", "role", ":", "Canonica...
// IsValidSnapshotStructure returns an error, or nil, depending on whether the content of the // struct is valid for snapshot metadata. This does not check signatures or expiry, just that // the metadata content is valid.
[ "IsValidSnapshotStructure", "returns", "an", "error", "or", "nil", "depending", "on", "whether", "the", "content", "of", "the", "struct", "is", "valid", "for", "snapshot", "metadata", ".", "This", "does", "not", "check", "signatures", "or", "expiry", "just", "...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/snapshot.go#L28-L60
train
theupdateframework/notary
tuf/data/snapshot.go
NewSnapshot
func NewSnapshot(root *Signed, targets *Signed) (*SignedSnapshot, error) { logrus.Debug("generating new snapshot...") targetsJSON, err := json.Marshal(targets) if err != nil { logrus.Debug("Error Marshalling Targets") return nil, err } rootJSON, err := json.Marshal(root) if err != nil { logrus.Debug("Error ...
go
func NewSnapshot(root *Signed, targets *Signed) (*SignedSnapshot, error) { logrus.Debug("generating new snapshot...") targetsJSON, err := json.Marshal(targets) if err != nil { logrus.Debug("Error Marshalling Targets") return nil, err } rootJSON, err := json.Marshal(root) if err != nil { logrus.Debug("Error ...
[ "func", "NewSnapshot", "(", "root", "*", "Signed", ",", "targets", "*", "Signed", ")", "(", "*", "SignedSnapshot", ",", "error", ")", "{", "logrus", ".", "Debug", "(", "\"", "\"", ")", "\n", "targetsJSON", ",", "err", ":=", "json", ".", "Marshal", "(...
// NewSnapshot initializes a SignedSnapshot with a given top level root // and targets objects
[ "NewSnapshot", "initializes", "a", "SignedSnapshot", "with", "a", "given", "top", "level", "root", "and", "targets", "objects" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/snapshot.go#L64-L98
train
theupdateframework/notary
tuf/data/snapshot.go
AddMeta
func (sp *SignedSnapshot) AddMeta(role RoleName, meta FileMeta) { sp.Signed.Meta[role.String()] = meta sp.Dirty = true }
go
func (sp *SignedSnapshot) AddMeta(role RoleName, meta FileMeta) { sp.Signed.Meta[role.String()] = meta sp.Dirty = true }
[ "func", "(", "sp", "*", "SignedSnapshot", ")", "AddMeta", "(", "role", "RoleName", ",", "meta", "FileMeta", ")", "{", "sp", ".", "Signed", ".", "Meta", "[", "role", ".", "String", "(", ")", "]", "=", "meta", "\n", "sp", ".", "Dirty", "=", "true", ...
// AddMeta updates a role in the snapshot with new meta
[ "AddMeta", "updates", "a", "role", "in", "the", "snapshot", "with", "new", "meta" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/snapshot.go#L120-L123
train
theupdateframework/notary
tuf/data/snapshot.go
GetMeta
func (sp *SignedSnapshot) GetMeta(role RoleName) (*FileMeta, error) { if meta, ok := sp.Signed.Meta[role.String()]; ok { if _, ok := meta.Hashes["sha256"]; ok { return &meta, nil } } return nil, ErrMissingMeta{Role: role.String()} }
go
func (sp *SignedSnapshot) GetMeta(role RoleName) (*FileMeta, error) { if meta, ok := sp.Signed.Meta[role.String()]; ok { if _, ok := meta.Hashes["sha256"]; ok { return &meta, nil } } return nil, ErrMissingMeta{Role: role.String()} }
[ "func", "(", "sp", "*", "SignedSnapshot", ")", "GetMeta", "(", "role", "RoleName", ")", "(", "*", "FileMeta", ",", "error", ")", "{", "if", "meta", ",", "ok", ":=", "sp", ".", "Signed", ".", "Meta", "[", "role", ".", "String", "(", ")", "]", ";",...
// GetMeta gets the metadata for a particular role, returning an error if it's // not found
[ "GetMeta", "gets", "the", "metadata", "for", "a", "particular", "role", "returning", "an", "error", "if", "it", "s", "not", "found" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/snapshot.go#L127-L134
train
theupdateframework/notary
tuf/data/snapshot.go
DeleteMeta
func (sp *SignedSnapshot) DeleteMeta(role RoleName) { if _, ok := sp.Signed.Meta[role.String()]; ok { delete(sp.Signed.Meta, role.String()) sp.Dirty = true } }
go
func (sp *SignedSnapshot) DeleteMeta(role RoleName) { if _, ok := sp.Signed.Meta[role.String()]; ok { delete(sp.Signed.Meta, role.String()) sp.Dirty = true } }
[ "func", "(", "sp", "*", "SignedSnapshot", ")", "DeleteMeta", "(", "role", "RoleName", ")", "{", "if", "_", ",", "ok", ":=", "sp", ".", "Signed", ".", "Meta", "[", "role", ".", "String", "(", ")", "]", ";", "ok", "{", "delete", "(", "sp", ".", "...
// DeleteMeta removes a role from the snapshot. If the role doesn't // exist in the snapshot, it's a noop.
[ "DeleteMeta", "removes", "a", "role", "from", "the", "snapshot", ".", "If", "the", "role", "doesn", "t", "exist", "in", "the", "snapshot", "it", "s", "a", "noop", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/snapshot.go#L138-L143
train
theupdateframework/notary
tuf/data/snapshot.go
MarshalJSON
func (sp *SignedSnapshot) MarshalJSON() ([]byte, error) { signed, err := sp.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
go
func (sp *SignedSnapshot) MarshalJSON() ([]byte, error) { signed, err := sp.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
[ "func", "(", "sp", "*", "SignedSnapshot", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "signed", ",", "err", ":=", "sp", ".", "ToSigned", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", ...
// MarshalJSON returns the serialized form of SignedSnapshot as bytes
[ "MarshalJSON", "returns", "the", "serialized", "form", "of", "SignedSnapshot", "as", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/snapshot.go#L146-L152
train
theupdateframework/notary
tuf/data/snapshot.go
SnapshotFromSigned
func SnapshotFromSigned(s *Signed) (*SignedSnapshot, error) { sp := Snapshot{} if err := defaultSerializer.Unmarshal(*s.Signed, &sp); err != nil { return nil, err } if err := IsValidSnapshotStructure(sp); err != nil { return nil, err } sigs := make([]Signature, len(s.Signatures)) copy(sigs, s.Signatures) re...
go
func SnapshotFromSigned(s *Signed) (*SignedSnapshot, error) { sp := Snapshot{} if err := defaultSerializer.Unmarshal(*s.Signed, &sp); err != nil { return nil, err } if err := IsValidSnapshotStructure(sp); err != nil { return nil, err } sigs := make([]Signature, len(s.Signatures)) copy(sigs, s.Signatures) re...
[ "func", "SnapshotFromSigned", "(", "s", "*", "Signed", ")", "(", "*", "SignedSnapshot", ",", "error", ")", "{", "sp", ":=", "Snapshot", "{", "}", "\n", "if", "err", ":=", "defaultSerializer", ".", "Unmarshal", "(", "*", "s", ".", "Signed", ",", "&", ...
// SnapshotFromSigned fully unpacks a Signed object into a SignedSnapshot
[ "SnapshotFromSigned", "fully", "unpacks", "a", "Signed", "object", "into", "a", "SignedSnapshot" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/snapshot.go#L155-L169
train
theupdateframework/notary
tuf/data/roles.go
ValidRole
func ValidRole(name RoleName) bool { if IsDelegation(name) { return true } for _, v := range BaseRoles { if name == v { return true } } return false }
go
func ValidRole(name RoleName) bool { if IsDelegation(name) { return true } for _, v := range BaseRoles { if name == v { return true } } return false }
[ "func", "ValidRole", "(", "name", "RoleName", ")", "bool", "{", "if", "IsDelegation", "(", "name", ")", "{", "return", "true", "\n", "}", "\n\n", "for", "_", ",", "v", ":=", "range", "BaseRoles", "{", "if", "name", "==", "v", "{", "return", "true", ...
// ValidRole only determines the name is semantically // correct. For target delegated roles, it does NOT check // the the appropriate parent roles exist.
[ "ValidRole", "only", "determines", "the", "name", "is", "semantically", "correct", ".", "For", "target", "delegated", "roles", "it", "does", "NOT", "check", "the", "the", "appropriate", "parent", "roles", "exist", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L59-L70
train
theupdateframework/notary
tuf/data/roles.go
IsDelegation
func IsDelegation(role RoleName) bool { strRole := role.String() targetsBase := CanonicalTargetsRole + "/" whitelistedChars := delegationRegexp.MatchString(strRole) // Limit size of full role string to 255 chars for db column size limit correctLength := len(role) < 256 // Removes ., .., extra slashes, and trai...
go
func IsDelegation(role RoleName) bool { strRole := role.String() targetsBase := CanonicalTargetsRole + "/" whitelistedChars := delegationRegexp.MatchString(strRole) // Limit size of full role string to 255 chars for db column size limit correctLength := len(role) < 256 // Removes ., .., extra slashes, and trai...
[ "func", "IsDelegation", "(", "role", "RoleName", ")", "bool", "{", "strRole", ":=", "role", ".", "String", "(", ")", "\n", "targetsBase", ":=", "CanonicalTargetsRole", "+", "\"", "\"", "\n\n", "whitelistedChars", ":=", "delegationRegexp", ".", "MatchString", "...
// IsDelegation checks if the role is a delegation or a root role
[ "IsDelegation", "checks", "if", "the", "role", "is", "a", "delegation", "or", "a", "root", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L73-L88
train
theupdateframework/notary
tuf/data/roles.go
IsBaseRole
func IsBaseRole(role RoleName) bool { for _, baseRole := range BaseRoles { if role == baseRole { return true } } return false }
go
func IsBaseRole(role RoleName) bool { for _, baseRole := range BaseRoles { if role == baseRole { return true } } return false }
[ "func", "IsBaseRole", "(", "role", "RoleName", ")", "bool", "{", "for", "_", ",", "baseRole", ":=", "range", "BaseRoles", "{", "if", "role", "==", "baseRole", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsBaseRole checks if the role is a base role
[ "IsBaseRole", "checks", "if", "the", "role", "is", "a", "base", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L91-L98
train
theupdateframework/notary
tuf/data/roles.go
NewBaseRole
func NewBaseRole(name RoleName, threshold int, keys ...PublicKey) BaseRole { r := BaseRole{ Name: name, Threshold: threshold, Keys: make(map[string]PublicKey), } for _, k := range keys { r.Keys[k.ID()] = k } return r }
go
func NewBaseRole(name RoleName, threshold int, keys ...PublicKey) BaseRole { r := BaseRole{ Name: name, Threshold: threshold, Keys: make(map[string]PublicKey), } for _, k := range keys { r.Keys[k.ID()] = k } return r }
[ "func", "NewBaseRole", "(", "name", "RoleName", ",", "threshold", "int", ",", "keys", "...", "PublicKey", ")", "BaseRole", "{", "r", ":=", "BaseRole", "{", "Name", ":", "name", ",", "Threshold", ":", "threshold", ",", "Keys", ":", "make", "(", "map", "...
// NewBaseRole creates a new BaseRole object with the provided parameters
[ "NewBaseRole", "creates", "a", "new", "BaseRole", "object", "with", "the", "provided", "parameters" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L123-L133
train
theupdateframework/notary
tuf/data/roles.go
Equals
func (b BaseRole) Equals(o BaseRole) bool { if b.Threshold != o.Threshold || b.Name != o.Name || len(b.Keys) != len(o.Keys) { return false } for keyID, key := range b.Keys { oKey, ok := o.Keys[keyID] if !ok || key.ID() != oKey.ID() { return false } } return true }
go
func (b BaseRole) Equals(o BaseRole) bool { if b.Threshold != o.Threshold || b.Name != o.Name || len(b.Keys) != len(o.Keys) { return false } for keyID, key := range b.Keys { oKey, ok := o.Keys[keyID] if !ok || key.ID() != oKey.ID() { return false } } return true }
[ "func", "(", "b", "BaseRole", ")", "Equals", "(", "o", "BaseRole", ")", "bool", "{", "if", "b", ".", "Threshold", "!=", "o", ".", "Threshold", "||", "b", ".", "Name", "!=", "o", ".", "Name", "||", "len", "(", "b", ".", "Keys", ")", "!=", "len",...
// Equals returns whether this BaseRole equals another BaseRole
[ "Equals", "returns", "whether", "this", "BaseRole", "equals", "another", "BaseRole" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L146-L159
train
theupdateframework/notary
tuf/data/roles.go
Restrict
func (d DelegationRole) Restrict(child DelegationRole) (DelegationRole, error) { if !d.IsParentOf(child) { return DelegationRole{}, fmt.Errorf("%s is not a parent of %s", d.Name, child.Name) } return DelegationRole{ BaseRole: BaseRole{ Keys: child.Keys, Name: child.Name, Threshold: child.Thres...
go
func (d DelegationRole) Restrict(child DelegationRole) (DelegationRole, error) { if !d.IsParentOf(child) { return DelegationRole{}, fmt.Errorf("%s is not a parent of %s", d.Name, child.Name) } return DelegationRole{ BaseRole: BaseRole{ Keys: child.Keys, Name: child.Name, Threshold: child.Thres...
[ "func", "(", "d", "DelegationRole", ")", "Restrict", "(", "child", "DelegationRole", ")", "(", "DelegationRole", ",", "error", ")", "{", "if", "!", "d", ".", "IsParentOf", "(", "child", ")", "{", "return", "DelegationRole", "{", "}", ",", "fmt", ".", "...
// Restrict restricts the paths and path hash prefixes for the passed in delegation role, // returning a copy of the role with validated paths as if it was a direct child
[ "Restrict", "restricts", "the", "paths", "and", "path", "hash", "prefixes", "for", "the", "passed", "in", "delegation", "role", "returning", "a", "copy", "of", "the", "role", "with", "validated", "paths", "as", "if", "it", "was", "a", "direct", "child" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L185-L197
train
theupdateframework/notary
tuf/data/roles.go
RestrictDelegationPathPrefixes
func RestrictDelegationPathPrefixes(parentPaths, delegationPaths []string) []string { validPaths := []string{} if len(delegationPaths) == 0 { return validPaths } // Validate each individual delegation path for _, delgPath := range delegationPaths { isPrefixed := false for _, parentPath := range parentPaths ...
go
func RestrictDelegationPathPrefixes(parentPaths, delegationPaths []string) []string { validPaths := []string{} if len(delegationPaths) == 0 { return validPaths } // Validate each individual delegation path for _, delgPath := range delegationPaths { isPrefixed := false for _, parentPath := range parentPaths ...
[ "func", "RestrictDelegationPathPrefixes", "(", "parentPaths", ",", "delegationPaths", "[", "]", "string", ")", "[", "]", "string", "{", "validPaths", ":=", "[", "]", "string", "{", "}", "\n", "if", "len", "(", "delegationPaths", ")", "==", "0", "{", "retur...
// RestrictDelegationPathPrefixes returns the list of valid delegationPaths that are prefixed by parentPaths
[ "RestrictDelegationPathPrefixes", "returns", "the", "list", "of", "valid", "delegationPaths", "that", "are", "prefixed", "by", "parentPaths" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L221-L242
train
theupdateframework/notary
tuf/data/roles.go
NewRole
func NewRole(name RoleName, threshold int, keyIDs, paths []string) (*Role, error) { if IsDelegation(name) { if len(paths) == 0 { logrus.Debugf("role %s with no Paths will never be able to publish content until one or more are added", name) } } if threshold < 1 { return nil, ErrInvalidRole{Role: name} } if...
go
func NewRole(name RoleName, threshold int, keyIDs, paths []string) (*Role, error) { if IsDelegation(name) { if len(paths) == 0 { logrus.Debugf("role %s with no Paths will never be able to publish content until one or more are added", name) } } if threshold < 1 { return nil, ErrInvalidRole{Role: name} } if...
[ "func", "NewRole", "(", "name", "RoleName", ",", "threshold", "int", ",", "keyIDs", ",", "paths", "[", "]", "string", ")", "(", "*", "Role", ",", "error", ")", "{", "if", "IsDelegation", "(", "name", ")", "{", "if", "len", "(", "paths", ")", "==", ...
// NewRole creates a new Role object from the given parameters
[ "NewRole", "creates", "a", "new", "Role", "object", "from", "the", "given", "parameters" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L260-L281
train
theupdateframework/notary
tuf/data/roles.go
AddKeys
func (r *Role) AddKeys(ids []string) { r.KeyIDs = mergeStrSlices(r.KeyIDs, ids) }
go
func (r *Role) AddKeys(ids []string) { r.KeyIDs = mergeStrSlices(r.KeyIDs, ids) }
[ "func", "(", "r", "*", "Role", ")", "AddKeys", "(", "ids", "[", "]", "string", ")", "{", "r", ".", "KeyIDs", "=", "mergeStrSlices", "(", "r", ".", "KeyIDs", ",", "ids", ")", "\n", "}" ]
// AddKeys merges the ids into the current list of role key ids
[ "AddKeys", "merges", "the", "ids", "into", "the", "current", "list", "of", "role", "key", "ids" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L289-L291
train
theupdateframework/notary
tuf/data/roles.go
AddPaths
func (r *Role) AddPaths(paths []string) error { if len(paths) == 0 { return nil } r.Paths = mergeStrSlices(r.Paths, paths) return nil }
go
func (r *Role) AddPaths(paths []string) error { if len(paths) == 0 { return nil } r.Paths = mergeStrSlices(r.Paths, paths) return nil }
[ "func", "(", "r", "*", "Role", ")", "AddPaths", "(", "paths", "[", "]", "string", ")", "error", "{", "if", "len", "(", "paths", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "r", ".", "Paths", "=", "mergeStrSlices", "(", "r", ".", "Pat...
// AddPaths merges the paths into the current list of role paths
[ "AddPaths", "merges", "the", "paths", "into", "the", "current", "list", "of", "role", "paths" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L294-L300
train
theupdateframework/notary
tuf/data/roles.go
RemoveKeys
func (r *Role) RemoveKeys(ids []string) { r.KeyIDs = subtractStrSlices(r.KeyIDs, ids) }
go
func (r *Role) RemoveKeys(ids []string) { r.KeyIDs = subtractStrSlices(r.KeyIDs, ids) }
[ "func", "(", "r", "*", "Role", ")", "RemoveKeys", "(", "ids", "[", "]", "string", ")", "{", "r", ".", "KeyIDs", "=", "subtractStrSlices", "(", "r", ".", "KeyIDs", ",", "ids", ")", "\n", "}" ]
// RemoveKeys removes the ids from the current list of key ids
[ "RemoveKeys", "removes", "the", "ids", "from", "the", "current", "list", "of", "key", "ids" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L303-L305
train
theupdateframework/notary
tuf/data/roles.go
RemovePaths
func (r *Role) RemovePaths(paths []string) { r.Paths = subtractStrSlices(r.Paths, paths) }
go
func (r *Role) RemovePaths(paths []string) { r.Paths = subtractStrSlices(r.Paths, paths) }
[ "func", "(", "r", "*", "Role", ")", "RemovePaths", "(", "paths", "[", "]", "string", ")", "{", "r", ".", "Paths", "=", "subtractStrSlices", "(", "r", ".", "Paths", ",", "paths", ")", "\n", "}" ]
// RemovePaths removes the paths from the current list of role paths
[ "RemovePaths", "removes", "the", "paths", "from", "the", "current", "list", "of", "role", "paths" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/roles.go#L308-L310
train
theupdateframework/notary
server/storage/memory.go
NewMemStorage
func NewMemStorage() *MemStorage { return &MemStorage{ tufMeta: make(map[string]verList), keys: make(map[string]map[string]*key), checksums: make(map[string]map[string]ver), } }
go
func NewMemStorage() *MemStorage { return &MemStorage{ tufMeta: make(map[string]verList), keys: make(map[string]map[string]*key), checksums: make(map[string]map[string]ver), } }
[ "func", "NewMemStorage", "(", ")", "*", "MemStorage", "{", "return", "&", "MemStorage", "{", "tufMeta", ":", "make", "(", "map", "[", "string", "]", "verList", ")", ",", "keys", ":", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", ...
// NewMemStorage instantiates a memStorage instance
[ "NewMemStorage", "instantiates", "a", "memStorage", "instance" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/memory.go#L48-L54
train
theupdateframework/notary
server/storage/memory.go
UpdateCurrent
func (st *MemStorage) UpdateCurrent(gun data.GUN, update MetaUpdate) error { id := entryKey(gun, update.Role) st.lock.Lock() defer st.lock.Unlock() if space, ok := st.tufMeta[id]; ok { for _, v := range space { if v.version >= update.Version { return ErrOldVersion{} } } } version := ver{version: upd...
go
func (st *MemStorage) UpdateCurrent(gun data.GUN, update MetaUpdate) error { id := entryKey(gun, update.Role) st.lock.Lock() defer st.lock.Unlock() if space, ok := st.tufMeta[id]; ok { for _, v := range space { if v.version >= update.Version { return ErrOldVersion{} } } } version := ver{version: upd...
[ "func", "(", "st", "*", "MemStorage", ")", "UpdateCurrent", "(", "gun", "data", ".", "GUN", ",", "update", "MetaUpdate", ")", "error", "{", "id", ":=", "entryKey", "(", "gun", ",", "update", ".", "Role", ")", "\n", "st", ".", "lock", ".", "Lock", "...
// UpdateCurrent updates the meta data for a specific role
[ "UpdateCurrent", "updates", "the", "meta", "data", "for", "a", "specific", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/memory.go#L57-L82
train
theupdateframework/notary
server/storage/memory.go
writeChange
func (st *MemStorage) writeChange(gun data.GUN, version int, checksum string) { c := Change{ ID: strconv.Itoa(len(st.changes) + 1), GUN: gun.String(), Version: version, SHA256: checksum, CreatedAt: time.Now(), Category: changeCategoryUpdate, } st.changes = append(st.changes, c) }
go
func (st *MemStorage) writeChange(gun data.GUN, version int, checksum string) { c := Change{ ID: strconv.Itoa(len(st.changes) + 1), GUN: gun.String(), Version: version, SHA256: checksum, CreatedAt: time.Now(), Category: changeCategoryUpdate, } st.changes = append(st.changes, c) }
[ "func", "(", "st", "*", "MemStorage", ")", "writeChange", "(", "gun", "data", ".", "GUN", ",", "version", "int", ",", "checksum", "string", ")", "{", "c", ":=", "Change", "{", "ID", ":", "strconv", ".", "Itoa", "(", "len", "(", "st", ".", "changes"...
// writeChange must only be called by a function already holding a lock on // the MemStorage. Behaviour is undefined otherwise
[ "writeChange", "must", "only", "be", "called", "by", "a", "function", "already", "holding", "a", "lock", "on", "the", "MemStorage", ".", "Behaviour", "is", "undefined", "otherwise" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/memory.go#L86-L96
train
theupdateframework/notary
server/storage/memory.go
UpdateMany
func (st *MemStorage) UpdateMany(gun data.GUN, updates []MetaUpdate) error { st.lock.Lock() defer st.lock.Unlock() versioner := make(map[string]map[int]struct{}) constant := struct{}{} // ensure that we only update in one transaction for _, u := range updates { id := entryKey(gun, u.Role) // prevent duplic...
go
func (st *MemStorage) UpdateMany(gun data.GUN, updates []MetaUpdate) error { st.lock.Lock() defer st.lock.Unlock() versioner := make(map[string]map[int]struct{}) constant := struct{}{} // ensure that we only update in one transaction for _, u := range updates { id := entryKey(gun, u.Role) // prevent duplic...
[ "func", "(", "st", "*", "MemStorage", ")", "UpdateMany", "(", "gun", "data", ".", "GUN", ",", "updates", "[", "]", "MetaUpdate", ")", "error", "{", "st", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "lock", ".", "Unlock", "(", ")...
// UpdateMany updates multiple TUF records
[ "UpdateMany", "updates", "multiple", "TUF", "records" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/memory.go#L99-L147
train
theupdateframework/notary
server/storage/memory.go
GetCurrent
func (st *MemStorage) GetCurrent(gun data.GUN, role data.RoleName) (*time.Time, []byte, error) { id := entryKey(gun, role) st.lock.Lock() defer st.lock.Unlock() space, ok := st.tufMeta[id] if !ok || len(space) == 0 { return nil, nil, ErrNotFound{} } return &(space[len(space)-1].createupdate), space[len(space)-...
go
func (st *MemStorage) GetCurrent(gun data.GUN, role data.RoleName) (*time.Time, []byte, error) { id := entryKey(gun, role) st.lock.Lock() defer st.lock.Unlock() space, ok := st.tufMeta[id] if !ok || len(space) == 0 { return nil, nil, ErrNotFound{} } return &(space[len(space)-1].createupdate), space[len(space)-...
[ "func", "(", "st", "*", "MemStorage", ")", "GetCurrent", "(", "gun", "data", ".", "GUN", ",", "role", "data", ".", "RoleName", ")", "(", "*", "time", ".", "Time", ",", "[", "]", "byte", ",", "error", ")", "{", "id", ":=", "entryKey", "(", "gun", ...
// GetCurrent returns the createupdate date metadata for a given role, under a GUN.
[ "GetCurrent", "returns", "the", "createupdate", "date", "metadata", "for", "a", "given", "role", "under", "a", "GUN", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/memory.go#L150-L159
train
theupdateframework/notary
server/storage/memory.go
GetChecksum
func (st *MemStorage) GetChecksum(gun data.GUN, role data.RoleName, checksum string) (*time.Time, []byte, error) { st.lock.Lock() defer st.lock.Unlock() space, ok := st.checksums[gun.String()][checksum] if !ok || len(space.data) == 0 { return nil, nil, ErrNotFound{} } return &(space.createupdate), space.data, n...
go
func (st *MemStorage) GetChecksum(gun data.GUN, role data.RoleName, checksum string) (*time.Time, []byte, error) { st.lock.Lock() defer st.lock.Unlock() space, ok := st.checksums[gun.String()][checksum] if !ok || len(space.data) == 0 { return nil, nil, ErrNotFound{} } return &(space.createupdate), space.data, n...
[ "func", "(", "st", "*", "MemStorage", ")", "GetChecksum", "(", "gun", "data", ".", "GUN", ",", "role", "data", ".", "RoleName", ",", "checksum", "string", ")", "(", "*", "time", ".", "Time", ",", "[", "]", "byte", ",", "error", ")", "{", "st", "....
// GetChecksum returns the createupdate date and metadata for a given role, under a GUN.
[ "GetChecksum", "returns", "the", "createupdate", "date", "and", "metadata", "for", "a", "given", "role", "under", "a", "GUN", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/memory.go#L162-L170
train
theupdateframework/notary
server/storage/memory.go
Delete
func (st *MemStorage) Delete(gun data.GUN) error { st.lock.Lock() defer st.lock.Unlock() l := len(st.tufMeta) for k := range st.tufMeta { if strings.HasPrefix(k, gun.String()) { delete(st.tufMeta, k) } } if l == len(st.tufMeta) { // we didn't delete anything, don't write change. return nil } delete(s...
go
func (st *MemStorage) Delete(gun data.GUN) error { st.lock.Lock() defer st.lock.Unlock() l := len(st.tufMeta) for k := range st.tufMeta { if strings.HasPrefix(k, gun.String()) { delete(st.tufMeta, k) } } if l == len(st.tufMeta) { // we didn't delete anything, don't write change. return nil } delete(s...
[ "func", "(", "st", "*", "MemStorage", ")", "Delete", "(", "gun", "data", ".", "GUN", ")", "error", "{", "st", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "st", ".", "lock", ".", "Unlock", "(", ")", "\n", "l", ":=", "len", "(", "st", "....
// Delete deletes all the metadata for a given GUN
[ "Delete", "deletes", "all", "the", "metadata", "for", "a", "given", "GUN" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/memory.go#L188-L210
train
theupdateframework/notary
passphrase/passphrase.go
PromptRetriever
func PromptRetriever() notary.PassRetriever { if !terminal.IsTerminal(int(os.Stdin.Fd())) { return func(string, string, bool, int) (string, bool, error) { return "", false, ErrNoInput } } return PromptRetrieverWithInOut(os.Stdin, os.Stdout, nil) }
go
func PromptRetriever() notary.PassRetriever { if !terminal.IsTerminal(int(os.Stdin.Fd())) { return func(string, string, bool, int) (string, bool, error) { return "", false, ErrNoInput } } return PromptRetrieverWithInOut(os.Stdin, os.Stdout, nil) }
[ "func", "PromptRetriever", "(", ")", "notary", ".", "PassRetriever", "{", "if", "!", "terminal", ".", "IsTerminal", "(", "int", "(", "os", ".", "Stdin", ".", "Fd", "(", ")", ")", ")", "{", "return", "func", "(", "string", ",", "string", ",", "bool", ...
// PromptRetriever returns a new Retriever which will provide a prompt on stdin // and stdout to retrieve a passphrase. stdin will be checked if it is a terminal, // else the PromptRetriever will error when attempting to retrieve a passphrase. // Upon successful passphrase retrievals, the passphrase will be cached such...
[ "PromptRetriever", "returns", "a", "new", "Retriever", "which", "will", "provide", "a", "prompt", "on", "stdin", "and", "stdout", "to", "retrieve", "a", "passphrase", ".", "stdin", "will", "be", "checked", "if", "it", "is", "a", "terminal", "else", "the", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/passphrase/passphrase.go#L51-L58
train
theupdateframework/notary
passphrase/passphrase.go
PromptRetrieverWithInOut
func PromptRetrieverWithInOut(in io.Reader, out io.Writer, aliasMap map[string]string) notary.PassRetriever { bound := &boundRetriever{ in: in, out: out, aliasMap: aliasMap, passphraseCache: make(map[string]string), } return bound.getPassphrase }
go
func PromptRetrieverWithInOut(in io.Reader, out io.Writer, aliasMap map[string]string) notary.PassRetriever { bound := &boundRetriever{ in: in, out: out, aliasMap: aliasMap, passphraseCache: make(map[string]string), } return bound.getPassphrase }
[ "func", "PromptRetrieverWithInOut", "(", "in", "io", ".", "Reader", ",", "out", "io", ".", "Writer", ",", "aliasMap", "map", "[", "string", "]", "string", ")", "notary", ".", "PassRetriever", "{", "bound", ":=", "&", "boundRetriever", "{", "in", ":", "in...
// PromptRetrieverWithInOut returns a new Retriever which will provide a // prompt using the given in and out readers. The passphrase will be cached // such that subsequent prompts will produce the same passphrase. // aliasMap can be used to specify display names for TUF key aliases. If aliasMap // is nil, a sensible d...
[ "PromptRetrieverWithInOut", "returns", "a", "new", "Retriever", "which", "will", "provide", "a", "prompt", "using", "the", "given", "in", "and", "out", "readers", ".", "The", "passphrase", "will", "be", "cached", "such", "that", "subsequent", "prompts", "will", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/passphrase/passphrase.go#L176-L185
train
theupdateframework/notary
passphrase/passphrase.go
ConstantRetriever
func ConstantRetriever(constantPassphrase string) notary.PassRetriever { return func(k, a string, c bool, n int) (string, bool, error) { return constantPassphrase, false, nil } }
go
func ConstantRetriever(constantPassphrase string) notary.PassRetriever { return func(k, a string, c bool, n int) (string, bool, error) { return constantPassphrase, false, nil } }
[ "func", "ConstantRetriever", "(", "constantPassphrase", "string", ")", "notary", ".", "PassRetriever", "{", "return", "func", "(", "k", ",", "a", "string", ",", "c", "bool", ",", "n", "int", ")", "(", "string", ",", "bool", ",", "error", ")", "{", "ret...
// ConstantRetriever returns a new Retriever which will return a constant string // as a passphrase.
[ "ConstantRetriever", "returns", "a", "new", "Retriever", "which", "will", "return", "a", "constant", "string", "as", "a", "passphrase", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/passphrase/passphrase.go#L189-L193
train
theupdateframework/notary
passphrase/passphrase.go
GetPassphrase
func GetPassphrase(in *bufio.Reader) ([]byte, error) { var ( passphrase []byte err error ) if terminal.IsTerminal(int(os.Stdin.Fd())) { passphrase, err = terminal.ReadPassword(int(os.Stdin.Fd())) } else { passphrase, err = in.ReadBytes('\n') } return passphrase, err }
go
func GetPassphrase(in *bufio.Reader) ([]byte, error) { var ( passphrase []byte err error ) if terminal.IsTerminal(int(os.Stdin.Fd())) { passphrase, err = terminal.ReadPassword(int(os.Stdin.Fd())) } else { passphrase, err = in.ReadBytes('\n') } return passphrase, err }
[ "func", "GetPassphrase", "(", "in", "*", "bufio", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "(", "passphrase", "[", "]", "byte", "\n", "err", "error", "\n", ")", "\n\n", "if", "terminal", ".", "IsTerminal", "(", "int...
// GetPassphrase get the passphrase from bufio.Reader or from terminal. // If typing on the terminal, we disable terminal to echo the passphrase.
[ "GetPassphrase", "get", "the", "passphrase", "from", "bufio", ".", "Reader", "or", "from", "terminal", ".", "If", "typing", "on", "the", "terminal", "we", "disable", "terminal", "to", "echo", "the", "passphrase", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/passphrase/passphrase.go#L197-L210
train
theupdateframework/notary
tuf/validation/errors.go
UnmarshalJSON
func (s *SerializableError) UnmarshalJSON(text []byte) (err error) { var x struct{ Name string } err = json.Unmarshal(text, &x) if err != nil { return } var theError error switch x.Name { case "ErrValidation": var e struct{ Error ErrValidation } err = json.Unmarshal(text, &e) theError = e.Error case "Er...
go
func (s *SerializableError) UnmarshalJSON(text []byte) (err error) { var x struct{ Name string } err = json.Unmarshal(text, &x) if err != nil { return } var theError error switch x.Name { case "ErrValidation": var e struct{ Error ErrValidation } err = json.Unmarshal(text, &e) theError = e.Error case "Er...
[ "func", "(", "s", "*", "SerializableError", ")", "UnmarshalJSON", "(", "text", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "var", "x", "struct", "{", "Name", "string", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "text", ",", "&"...
// UnmarshalJSON attempts to unmarshal the error into the right type
[ "UnmarshalJSON", "attempts", "to", "unmarshal", "the", "error", "into", "the", "right", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/validation/errors.go#L67-L105
train
theupdateframework/notary
tuf/validation/errors.go
NewSerializableError
func NewSerializableError(err error) (*SerializableError, error) { // make sure it's one of our errors var name string switch err.(type) { case ErrValidation: name = "ErrValidation" case ErrBadHierarchy: name = "ErrBadHierarchy" case ErrBadRoot: name = "ErrBadRoot" case ErrBadTargets: name = "ErrBadTarge...
go
func NewSerializableError(err error) (*SerializableError, error) { // make sure it's one of our errors var name string switch err.(type) { case ErrValidation: name = "ErrValidation" case ErrBadHierarchy: name = "ErrBadHierarchy" case ErrBadRoot: name = "ErrBadRoot" case ErrBadTargets: name = "ErrBadTarge...
[ "func", "NewSerializableError", "(", "err", "error", ")", "(", "*", "SerializableError", ",", "error", ")", "{", "// make sure it's one of our errors", "var", "name", "string", "\n", "switch", "err", ".", "(", "type", ")", "{", "case", "ErrValidation", ":", "n...
// NewSerializableError serializes one of the above errors into JSON
[ "NewSerializableError", "serializes", "one", "of", "the", "above", "errors", "into", "JSON" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/validation/errors.go#L108-L126
train
theupdateframework/notary
cmd/notary/util.go
getPayload
func getPayload(t *tufCommander) ([]byte, error) { // Reads from the given file if t.input != "" { // Please note that ReadFile will cut off the size if it was over 1e9. // Thus, if the size of the file exceeds 1GB, the over part will not be // loaded into the buffer. payload, err := ioutil.ReadFile(t.input)...
go
func getPayload(t *tufCommander) ([]byte, error) { // Reads from the given file if t.input != "" { // Please note that ReadFile will cut off the size if it was over 1e9. // Thus, if the size of the file exceeds 1GB, the over part will not be // loaded into the buffer. payload, err := ioutil.ReadFile(t.input)...
[ "func", "getPayload", "(", "t", "*", "tufCommander", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Reads from the given file", "if", "t", ".", "input", "!=", "\"", "\"", "{", "// Please note that ReadFile will cut off the size if it was over 1e9.", "// Thu...
// getPayload is a helper function to get the content used to be verified // either from an existing file or STDIN.
[ "getPayload", "is", "a", "helper", "function", "to", "get", "the", "content", "used", "to", "be", "verified", "either", "from", "an", "existing", "file", "or", "STDIN", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/util.go#L17-L37
train
theupdateframework/notary
cmd/notary/util.go
feedback
func feedback(t *tufCommander, payload []byte) error { // We only get here when everything goes well, since the flag "quiet" was // provided, we output nothing but just return. if t.quiet { return nil } // Flag "quiet" was not "true", that's why we get here. if t.output != "" { return ioutil.WriteFile(t.outp...
go
func feedback(t *tufCommander, payload []byte) error { // We only get here when everything goes well, since the flag "quiet" was // provided, we output nothing but just return. if t.quiet { return nil } // Flag "quiet" was not "true", that's why we get here. if t.output != "" { return ioutil.WriteFile(t.outp...
[ "func", "feedback", "(", "t", "*", "tufCommander", ",", "payload", "[", "]", "byte", ")", "error", "{", "// We only get here when everything goes well, since the flag \"quiet\" was", "// provided, we output nothing but just return.", "if", "t", ".", "quiet", "{", "return", ...
// feedback is a helper function to print the payload to a file or STDOUT or keep quiet // due to the value of flag "quiet" and "output".
[ "feedback", "is", "a", "helper", "function", "to", "print", "the", "payload", "to", "a", "file", "or", "STDOUT", "or", "keep", "quiet", "due", "to", "the", "value", "of", "flag", "quiet", "and", "output", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/util.go#L41-L55
train
theupdateframework/notary
cmd/notary/util.go
homeExpand
func homeExpand(homeDir, path string) string { if path == "" || path[0] != '~' || (len(path) > 1 && path[1] != os.PathSeparator) { return path } return filepath.Join(homeDir, path[1:]) }
go
func homeExpand(homeDir, path string) string { if path == "" || path[0] != '~' || (len(path) > 1 && path[1] != os.PathSeparator) { return path } return filepath.Join(homeDir, path[1:]) }
[ "func", "homeExpand", "(", "homeDir", ",", "path", "string", ")", "string", "{", "if", "path", "==", "\"", "\"", "||", "path", "[", "0", "]", "!=", "'~'", "||", "(", "len", "(", "path", ")", ">", "1", "&&", "path", "[", "1", "]", "!=", "os", ...
// homeExpand will expand an initial ~ to the user home directory. This is supported for // config files where the shell will not have expanded paths.
[ "homeExpand", "will", "expand", "an", "initial", "~", "to", "the", "user", "home", "directory", ".", "This", "is", "supported", "for", "config", "files", "where", "the", "shell", "will", "not", "have", "expanded", "paths", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/util.go#L59-L64
train
theupdateframework/notary
server/handlers/default.go
MainHandler
func MainHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { // For now it only supports `GET` if r.Method != "GET" { return errors.ErrGenericNotFound.WithDetail(nil) } if _, err := w.Write([]byte("{}")); err != nil { return errors.ErrUnknown.WithDetail(err) } return nil }
go
func MainHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { // For now it only supports `GET` if r.Method != "GET" { return errors.ErrGenericNotFound.WithDetail(nil) } if _, err := w.Write([]byte("{}")); err != nil { return errors.ErrUnknown.WithDetail(err) } return nil }
[ "func", "MainHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "// For now it only supports `GET`", "if", "r", ".", "Method", "!=", "\"", "\"", "{", "return",...
// MainHandler is the default handler for the server
[ "MainHandler", "is", "the", "default", "handler", "for", "the", "server" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L28-L38
train
theupdateframework/notary
server/handlers/default.go
AtomicUpdateHandler
func AtomicUpdateHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return atomicUpdateHandler(ctx, w, r, vars) }
go
func AtomicUpdateHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return atomicUpdateHandler(ctx, w, r, vars) }
[ "func", "AtomicUpdateHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "defer", "r", ".", "Body", ".", "Close", "(", ")", "\n", "vars", ":=", "mux", "."...
// AtomicUpdateHandler will accept multiple TUF files and ensure that the storage // backend is atomically updated with all the new records.
[ "AtomicUpdateHandler", "will", "accept", "multiple", "TUF", "files", "and", "ensure", "that", "the", "storage", "backend", "is", "atomically", "updated", "with", "all", "the", "new", "records", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L42-L46
train
theupdateframework/notary
server/handlers/default.go
logTS
func logTS(logger ctxu.Logger, gun string, updates []storage.MetaUpdate) { for _, update := range updates { if update.Role == data.CanonicalTimestampRole { checksumBin := sha256.Sum256(update.Data) checksum := hex.EncodeToString(checksumBin[:]) logger.Infof("updated %s to timestamp version %d, checksum %s",...
go
func logTS(logger ctxu.Logger, gun string, updates []storage.MetaUpdate) { for _, update := range updates { if update.Role == data.CanonicalTimestampRole { checksumBin := sha256.Sum256(update.Data) checksum := hex.EncodeToString(checksumBin[:]) logger.Infof("updated %s to timestamp version %d, checksum %s",...
[ "func", "logTS", "(", "logger", "ctxu", ".", "Logger", ",", "gun", "string", ",", "updates", "[", "]", "storage", ".", "MetaUpdate", ")", "{", "for", "_", ",", "update", ":=", "range", "updates", "{", "if", "update", ".", "Role", "==", "data", ".", ...
// logTS logs the timestamp update at Info level
[ "logTS", "logs", "the", "timestamp", "update", "at", "Info", "level" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L126-L135
train
theupdateframework/notary
server/handlers/default.go
GetHandler
func GetHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return getHandler(ctx, w, r, vars) }
go
func GetHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return getHandler(ctx, w, r, vars) }
[ "func", "GetHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "defer", "r", ".", "Body", ".", "Close", "(", ")", "\n", "vars", ":=", "mux", ".", "Vars...
// GetHandler returns the json for a specified role and GUN.
[ "GetHandler", "returns", "the", "json", "for", "a", "specified", "role", "and", "GUN", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L138-L142
train
theupdateframework/notary
server/handlers/default.go
DeleteHandler
func DeleteHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) gun := data.GUN(vars["gun"]) logger := ctxu.GetLoggerWithField(ctx, gun, "gun") s := ctx.Value(notary.CtxKeyMetaStore) store, ok := s.(storage.MetaStore) if !ok { logger.Error("500 DELETE repository: no s...
go
func DeleteHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) gun := data.GUN(vars["gun"]) logger := ctxu.GetLoggerWithField(ctx, gun, "gun") s := ctx.Value(notary.CtxKeyMetaStore) store, ok := s.(storage.MetaStore) if !ok { logger.Error("500 DELETE repository: no s...
[ "func", "DeleteHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "vars", ":=", "mux", ".", "Vars", "(", "r", ")", "\n", "gun", ":=", "data", ".", "GUN...
// DeleteHandler deletes all data for a GUN. A 200 responses indicates success.
[ "DeleteHandler", "deletes", "all", "data", "for", "a", "GUN", ".", "A", "200", "responses", "indicates", "success", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L179-L196
train
theupdateframework/notary
server/handlers/default.go
GetKeyHandler
func GetKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return getKeyHandler(ctx, w, r, vars) }
go
func GetKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return getKeyHandler(ctx, w, r, vars) }
[ "func", "GetKeyHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "defer", "r", ".", "Body", ".", "Close", "(", ")", "\n", "vars", ":=", "mux", ".", "V...
// GetKeyHandler returns a public key for the specified role, creating a new key-pair // it if it doesn't yet exist
[ "GetKeyHandler", "returns", "a", "public", "key", "for", "the", "specified", "role", "creating", "a", "new", "key", "-", "pair", "it", "if", "it", "doesn", "t", "yet", "exist" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L200-L204
train
theupdateframework/notary
server/handlers/default.go
RotateKeyHandler
func RotateKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return rotateKeyHandler(ctx, w, r, vars) }
go
func RotateKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { defer r.Body.Close() vars := mux.Vars(r) return rotateKeyHandler(ctx, w, r, vars) }
[ "func", "RotateKeyHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "defer", "r", ".", "Body", ".", "Close", "(", ")", "\n", "vars", ":=", "mux", ".", ...
// RotateKeyHandler rotates the remote key for the specified role, returning the public key
[ "RotateKeyHandler", "rotates", "the", "remote", "key", "for", "the", "specified", "role", "returning", "the", "public", "key" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L238-L242
train
theupdateframework/notary
server/handlers/default.go
setupKeyHandler
func setupKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string, actionVerb string) (data.RoleName, data.GUN, string, storage.MetaStore, signed.CryptoService, error) { gun := data.GUN(vars["gun"]) logger := ctxu.GetLoggerWithField(ctx, gun, "gun") if gun == "" { logger.Info...
go
func setupKeyHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string, actionVerb string) (data.RoleName, data.GUN, string, storage.MetaStore, signed.CryptoService, error) { gun := data.GUN(vars["gun"]) logger := ctxu.GetLoggerWithField(ctx, gun, "gun") if gun == "" { logger.Info...
[ "func", "setupKeyHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "vars", "map", "[", "string", "]", "string", ",", "actionVerb", "string", ")", "(", "data", ".", "Rol...
// To be called before getKeyHandler or rotateKeyHandler
[ "To", "be", "called", "before", "getKeyHandler", "or", "rotateKeyHandler" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L276-L310
train
theupdateframework/notary
server/handlers/default.go
NotFoundHandler
func NotFoundHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { return errors.ErrMetadataNotFound.WithDetail(nil) }
go
func NotFoundHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error { return errors.ErrMetadataNotFound.WithDetail(nil) }
[ "func", "NotFoundHandler", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "return", "errors", ".", "ErrMetadataNotFound", ".", "WithDetail", "(", "nil", ")", "\n", ...
// NotFoundHandler is used as a generic catch all handler to return the ErrMetadataNotFound // 404 response
[ "NotFoundHandler", "is", "used", "as", "a", "generic", "catch", "all", "handler", "to", "return", "the", "ErrMetadataNotFound", "404", "response" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/handlers/default.go#L314-L316
train
theupdateframework/notary
server/storage/sqldb.go
NewSQLStorage
func NewSQLStorage(dialect string, args ...interface{}) (*SQLStorage, error) { gormDB, err := gorm.Open(dialect, args...) if err != nil { return nil, err } return &SQLStorage{ DB: *gormDB, }, nil }
go
func NewSQLStorage(dialect string, args ...interface{}) (*SQLStorage, error) { gormDB, err := gorm.Open(dialect, args...) if err != nil { return nil, err } return &SQLStorage{ DB: *gormDB, }, nil }
[ "func", "NewSQLStorage", "(", "dialect", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "*", "SQLStorage", ",", "error", ")", "{", "gormDB", ",", "err", ":=", "gorm", ".", "Open", "(", "dialect", ",", "args", "...", ")", "\n", "if", ...
// NewSQLStorage is a convenience method to create a SQLStorage
[ "NewSQLStorage", "is", "a", "convenience", "method", "to", "create", "a", "SQLStorage" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L23-L31
train
theupdateframework/notary
server/storage/sqldb.go
translateOldVersionError
func translateOldVersionError(err error) error { switch err := err.(type) { case *mysql.MySQLError: // https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html // 1022 = Can't write; duplicate key in table '%s' // 1062 = Duplicate entry '%s' for key %d if err.Number == 1022 || err.Number == 1062 { ...
go
func translateOldVersionError(err error) error { switch err := err.(type) { case *mysql.MySQLError: // https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html // 1022 = Can't write; duplicate key in table '%s' // 1062 = Duplicate entry '%s' for key %d if err.Number == 1022 || err.Number == 1062 { ...
[ "func", "translateOldVersionError", "(", "err", "error", ")", "error", "{", "switch", "err", ":=", "err", ".", "(", "type", ")", "{", "case", "*", "mysql", ".", "MySQLError", ":", "// https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html", "// 1022 = Can'...
// translateOldVersionError captures DB errors, and attempts to translate // duplicate entry - currently only supports MySQL and Sqlite3
[ "translateOldVersionError", "captures", "DB", "errors", "and", "attempts", "to", "translate", "duplicate", "entry", "-", "currently", "only", "supports", "MySQL", "and", "Sqlite3" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L35-L46
train
theupdateframework/notary
server/storage/sqldb.go
UpdateCurrent
func (db *SQLStorage) UpdateCurrent(gun data.GUN, update MetaUpdate) error { // ensure we're not inserting an immediately old version - can't use the // struct, because that only works with non-zero values, and Version // can be 0. exists := db.Where("gun = ? and role = ? and version >= ?", gun.String(), update.R...
go
func (db *SQLStorage) UpdateCurrent(gun data.GUN, update MetaUpdate) error { // ensure we're not inserting an immediately old version - can't use the // struct, because that only works with non-zero values, and Version // can be 0. exists := db.Where("gun = ? and role = ? and version >= ?", gun.String(), update.R...
[ "func", "(", "db", "*", "SQLStorage", ")", "UpdateCurrent", "(", "gun", "data", ".", "GUN", ",", "update", "MetaUpdate", ")", "error", "{", "// ensure we're not inserting an immediately old version - can't use the", "// struct, because that only works with non-zero values, and ...
// UpdateCurrent updates a single TUF.
[ "UpdateCurrent", "updates", "a", "single", "TUF", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L49-L93
train
theupdateframework/notary
server/storage/sqldb.go
UpdateMany
func (db *SQLStorage) UpdateMany(gun data.GUN, updates []MetaUpdate) error { tx, rb, err := db.getTransaction() if err != nil { return err } var ( query *gorm.DB added = make(map[uint]bool) ) if err := func() error { for _, update := range updates { // This looks like the same logic as UpdateCurrent, b...
go
func (db *SQLStorage) UpdateMany(gun data.GUN, updates []MetaUpdate) error { tx, rb, err := db.getTransaction() if err != nil { return err } var ( query *gorm.DB added = make(map[uint]bool) ) if err := func() error { for _, update := range updates { // This looks like the same logic as UpdateCurrent, b...
[ "func", "(", "db", "*", "SQLStorage", ")", "UpdateMany", "(", "gun", "data", ".", "GUN", ",", "updates", "[", "]", "MetaUpdate", ")", "error", "{", "tx", ",", "rb", ",", "err", ":=", "db", ".", "getTransaction", "(", ")", "\n", "if", "err", "!=", ...
// UpdateMany atomically updates many TUF records in a single transaction
[ "UpdateMany", "atomically", "updates", "many", "TUF", "records", "in", "a", "single", "transaction" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L115-L166
train
theupdateframework/notary
server/storage/sqldb.go
GetCurrent
func (db *SQLStorage) GetCurrent(gun data.GUN, tufRole data.RoleName) (*time.Time, []byte, error) { var row TUFFile q := db.Select("updated_at, data").Where( &TUFFile{Gun: gun.String(), Role: tufRole.String()}).Order("version desc").Limit(1).First(&row) if err := isReadErr(q, row); err != nil { return nil, nil, ...
go
func (db *SQLStorage) GetCurrent(gun data.GUN, tufRole data.RoleName) (*time.Time, []byte, error) { var row TUFFile q := db.Select("updated_at, data").Where( &TUFFile{Gun: gun.String(), Role: tufRole.String()}).Order("version desc").Limit(1).First(&row) if err := isReadErr(q, row); err != nil { return nil, nil, ...
[ "func", "(", "db", "*", "SQLStorage", ")", "GetCurrent", "(", "gun", "data", ".", "GUN", ",", "tufRole", "data", ".", "RoleName", ")", "(", "*", "time", ".", "Time", ",", "[", "]", "byte", ",", "error", ")", "{", "var", "row", "TUFFile", "\n", "q...
// GetCurrent gets a specific TUF record
[ "GetCurrent", "gets", "a", "specific", "TUF", "record" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L179-L187
train
theupdateframework/notary
server/storage/sqldb.go
GetChecksum
func (db *SQLStorage) GetChecksum(gun data.GUN, tufRole data.RoleName, checksum string) (*time.Time, []byte, error) { var row TUFFile q := db.Select("created_at, data").Where( &TUFFile{ Gun: gun.String(), Role: tufRole.String(), SHA256: checksum, }, ).First(&row) if err := isReadErr(q, row); err !...
go
func (db *SQLStorage) GetChecksum(gun data.GUN, tufRole data.RoleName, checksum string) (*time.Time, []byte, error) { var row TUFFile q := db.Select("created_at, data").Where( &TUFFile{ Gun: gun.String(), Role: tufRole.String(), SHA256: checksum, }, ).First(&row) if err := isReadErr(q, row); err !...
[ "func", "(", "db", "*", "SQLStorage", ")", "GetChecksum", "(", "gun", "data", ".", "GUN", ",", "tufRole", "data", ".", "RoleName", ",", "checksum", "string", ")", "(", "*", "time", ".", "Time", ",", "[", "]", "byte", ",", "error", ")", "{", "var", ...
// GetChecksum gets a specific TUF record by its hex checksum
[ "GetChecksum", "gets", "a", "specific", "TUF", "record", "by", "its", "hex", "checksum" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L190-L203
train
theupdateframework/notary
server/storage/sqldb.go
Delete
func (db *SQLStorage) Delete(gun data.GUN) error { tx, rb, err := db.getTransaction() if err != nil { return err } if err := func() error { res := tx.Unscoped().Where(&TUFFile{Gun: gun.String()}).Delete(TUFFile{}) if err := res.Error; err != nil { return err } // if there weren't actually any records f...
go
func (db *SQLStorage) Delete(gun data.GUN) error { tx, rb, err := db.getTransaction() if err != nil { return err } if err := func() error { res := tx.Unscoped().Where(&TUFFile{Gun: gun.String()}).Delete(TUFFile{}) if err := res.Error; err != nil { return err } // if there weren't actually any records f...
[ "func", "(", "db", "*", "SQLStorage", ")", "Delete", "(", "gun", "data", ".", "GUN", ")", "error", "{", "tx", ",", "rb", ",", "err", ":=", "db", ".", "getTransaction", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "...
// Delete deletes all the records for a specific GUN - we have to do a hard delete using Unscoped // otherwise we can't insert for that GUN again
[ "Delete", "deletes", "all", "the", "records", "for", "a", "specific", "GUN", "-", "we", "have", "to", "do", "a", "hard", "delete", "using", "Unscoped", "otherwise", "we", "can", "t", "insert", "for", "that", "GUN", "again" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L232-L256
train
theupdateframework/notary
server/storage/sqldb.go
CheckHealth
func (db *SQLStorage) CheckHealth() error { tableOk := db.HasTable(&TUFFile{}) if db.Error != nil { return db.Error } if !tableOk { return fmt.Errorf( "Cannot access table: %s", TUFFile{}.TableName()) } return nil }
go
func (db *SQLStorage) CheckHealth() error { tableOk := db.HasTable(&TUFFile{}) if db.Error != nil { return db.Error } if !tableOk { return fmt.Errorf( "Cannot access table: %s", TUFFile{}.TableName()) } return nil }
[ "func", "(", "db", "*", "SQLStorage", ")", "CheckHealth", "(", ")", "error", "{", "tableOk", ":=", "db", ".", "HasTable", "(", "&", "TUFFile", "{", "}", ")", "\n", "if", "db", ".", "Error", "!=", "nil", "{", "return", "db", ".", "Error", "\n", "}...
// CheckHealth asserts that the tuf_files table is present
[ "CheckHealth", "asserts", "that", "the", "tuf_files", "table", "is", "present" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L259-L269
train
theupdateframework/notary
server/storage/sqldb.go
GetChanges
func (db *SQLStorage) GetChanges(changeID string, records int, filterName string) ([]Change, error) { var ( changes []Change query = &db.DB id int64 err error ) if changeID == "" { id = 0 } else { id, err = strconv.ParseInt(changeID, 10, 32) if err != nil { return nil, ErrBadQuery{msg: f...
go
func (db *SQLStorage) GetChanges(changeID string, records int, filterName string) ([]Change, error) { var ( changes []Change query = &db.DB id int64 err error ) if changeID == "" { id = 0 } else { id, err = strconv.ParseInt(changeID, 10, 32) if err != nil { return nil, ErrBadQuery{msg: f...
[ "func", "(", "db", "*", "SQLStorage", ")", "GetChanges", "(", "changeID", "string", ",", "records", "int", ",", "filterName", "string", ")", "(", "[", "]", "Change", ",", "error", ")", "{", "var", "(", "changes", "[", "]", "Change", "\n", "query", "=...
// GetChanges returns up to pageSize changes starting from changeID.
[ "GetChanges", "returns", "up", "to", "pageSize", "changes", "starting", "from", "changeID", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sqldb.go#L272-L322
train
theupdateframework/notary
cmd/notary-signer/config.go
setUpCryptoservices
func setUpCryptoservices(configuration *viper.Viper, allowedBackends []string, doBootstrap bool) ( signer.CryptoServiceIndex, error) { backend := configuration.GetString("storage.backend") if !tufutils.StrSliceContains(allowedBackends, backend) { return nil, fmt.Errorf("%s is not an allowed backend, must be one o...
go
func setUpCryptoservices(configuration *viper.Viper, allowedBackends []string, doBootstrap bool) ( signer.CryptoServiceIndex, error) { backend := configuration.GetString("storage.backend") if !tufutils.StrSliceContains(allowedBackends, backend) { return nil, fmt.Errorf("%s is not an allowed backend, must be one o...
[ "func", "setUpCryptoservices", "(", "configuration", "*", "viper", ".", "Viper", ",", "allowedBackends", "[", "]", "string", ",", "doBootstrap", "bool", ")", "(", "signer", ".", "CryptoServiceIndex", ",", "error", ")", "{", "backend", ":=", "configuration", "....
// Reads the configuration file for storage setup, and sets up the cryptoservice // mapping
[ "Reads", "the", "configuration", "file", "for", "storage", "setup", "and", "sets", "up", "the", "cryptoservice", "mapping" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-signer/config.go#L103-L180
train
theupdateframework/notary
cmd/notary-signer/config.go
setupGRPCServer
func setupGRPCServer(signerConfig signer.Config) (*grpc.Server, net.Listener, error) { //RPC server setup kms := &api.KeyManagementServer{ CryptoServices: signerConfig.CryptoServices, } ss := &api.SignerServer{ CryptoServices: signerConfig.CryptoServices, } hs := ghealth.NewServer() lis, err := net.Listen(...
go
func setupGRPCServer(signerConfig signer.Config) (*grpc.Server, net.Listener, error) { //RPC server setup kms := &api.KeyManagementServer{ CryptoServices: signerConfig.CryptoServices, } ss := &api.SignerServer{ CryptoServices: signerConfig.CryptoServices, } hs := ghealth.NewServer() lis, err := net.Listen(...
[ "func", "setupGRPCServer", "(", "signerConfig", "signer", ".", "Config", ")", "(", "*", "grpc", ".", "Server", ",", "net", ".", "Listener", ",", "error", ")", "{", "//RPC server setup", "kms", ":=", "&", "api", ".", "KeyManagementServer", "{", "CryptoService...
// set up the GRPC server
[ "set", "up", "the", "GRPC", "server" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-signer/config.go#L197-L229
train
theupdateframework/notary
trustpinning/certs.go
validRootIntCerts
func validRootIntCerts(allIntCerts map[string][]*x509.Certificate) map[string][]*x509.Certificate { validIntCerts := make(map[string][]*x509.Certificate) // Go through every leaf cert ID, and build its valid intermediate certificate list for leafID, intCertList := range allIntCerts { for _, intCert := range intCe...
go
func validRootIntCerts(allIntCerts map[string][]*x509.Certificate) map[string][]*x509.Certificate { validIntCerts := make(map[string][]*x509.Certificate) // Go through every leaf cert ID, and build its valid intermediate certificate list for leafID, intCertList := range allIntCerts { for _, intCert := range intCe...
[ "func", "validRootIntCerts", "(", "allIntCerts", "map", "[", "string", "]", "[", "]", "*", "x509", ".", "Certificate", ")", "map", "[", "string", "]", "[", "]", "*", "x509", ".", "Certificate", "{", "validIntCerts", ":=", "make", "(", "map", "[", "stri...
// validRootIntCerts filters the passed in structure of intermediate certificates to only include non-expired, non-sha1 certificates // Note that this "validity" alone does not imply any measure of trust.
[ "validRootIntCerts", "filters", "the", "passed", "in", "structure", "of", "intermediate", "certificates", "to", "only", "include", "non", "-", "expired", "non", "-", "sha1", "certificates", "Note", "that", "this", "validity", "alone", "does", "not", "imply", "an...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustpinning/certs.go#L227-L241
train
theupdateframework/notary
trustpinning/certs.go
parseAllCerts
func parseAllCerts(signedRoot *data.SignedRoot) (map[string]*x509.Certificate, map[string][]*x509.Certificate) { if signedRoot == nil { return nil, nil } leafCerts := make(map[string]*x509.Certificate) intCerts := make(map[string][]*x509.Certificate) // Before we loop through all root keys available, make sure...
go
func parseAllCerts(signedRoot *data.SignedRoot) (map[string]*x509.Certificate, map[string][]*x509.Certificate) { if signedRoot == nil { return nil, nil } leafCerts := make(map[string]*x509.Certificate) intCerts := make(map[string][]*x509.Certificate) // Before we loop through all root keys available, make sure...
[ "func", "parseAllCerts", "(", "signedRoot", "*", "data", ".", "SignedRoot", ")", "(", "map", "[", "string", "]", "*", "x509", ".", "Certificate", ",", "map", "[", "string", "]", "[", "]", "*", "x509", ".", "Certificate", ")", "{", "if", "signedRoot", ...
// parseAllCerts returns two maps, one with all of the leafCertificates and one // with all the intermediate certificates found in signedRoot
[ "parseAllCerts", "returns", "two", "maps", "one", "with", "all", "of", "the", "leafCertificates", "and", "one", "with", "all", "the", "intermediate", "certificates", "found", "in", "signedRoot" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustpinning/certs.go#L245-L304
train
theupdateframework/notary
storage/memorystore.go
NewMemoryStore
func NewMemoryStore(seed map[data.RoleName][]byte) *MemoryStore { var ( consistent = make(map[string][]byte) initial = make(map[string][]byte) ) // add all seed meta to consistent for name, d := range seed { checksum := sha256.Sum256(d) path := utils.ConsistentName(name.String(), checksum[:]) initial[n...
go
func NewMemoryStore(seed map[data.RoleName][]byte) *MemoryStore { var ( consistent = make(map[string][]byte) initial = make(map[string][]byte) ) // add all seed meta to consistent for name, d := range seed { checksum := sha256.Sum256(d) path := utils.ConsistentName(name.String(), checksum[:]) initial[n...
[ "func", "NewMemoryStore", "(", "seed", "map", "[", "data", ".", "RoleName", "]", "[", "]", "byte", ")", "*", "MemoryStore", "{", "var", "(", "consistent", "=", "make", "(", "map", "[", "string", "]", "[", "]", "byte", ")", "\n", "initial", "=", "ma...
// NewMemoryStore returns a MetadataStore that operates entirely in memory. // Very useful for testing
[ "NewMemoryStore", "returns", "a", "MetadataStore", "that", "operates", "entirely", "in", "memory", ".", "Very", "useful", "for", "testing" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/memorystore.go#L15-L32
train
theupdateframework/notary
storage/memorystore.go
GetSized
func (m MemoryStore) GetSized(name string, size int64) ([]byte, error) { d, ok := m.data[name] if ok { if size == NoSizeLimit { size = notary.MaxDownloadSize } if int64(len(d)) < size { return d, nil } return d[:size], nil } d, ok = m.consistent[name] if ok { if int64(len(d)) < size { return d...
go
func (m MemoryStore) GetSized(name string, size int64) ([]byte, error) { d, ok := m.data[name] if ok { if size == NoSizeLimit { size = notary.MaxDownloadSize } if int64(len(d)) < size { return d, nil } return d[:size], nil } d, ok = m.consistent[name] if ok { if int64(len(d)) < size { return d...
[ "func", "(", "m", "MemoryStore", ")", "GetSized", "(", "name", "string", ",", "size", "int64", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "d", ",", "ok", ":=", "m", ".", "data", "[", "name", "]", "\n", "if", "ok", "{", "if", "size", ...
// GetSized returns up to size bytes of data references by name. // If size is "NoSizeLimit", this corresponds to "infinite," but we cut off at a // predefined threshold "notary.MaxDownloadSize", as we will always know the // size for everything but a timestamp and sometimes a root, // neither of which should be except...
[ "GetSized", "returns", "up", "to", "size", "bytes", "of", "data", "references", "by", "name", ".", "If", "size", "is", "NoSizeLimit", "this", "corresponds", "to", "infinite", "but", "we", "cut", "off", "at", "a", "predefined", "threshold", "notary", ".", "...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/memorystore.go#L46-L65
train
theupdateframework/notary
storage/memorystore.go
Get
func (m MemoryStore) Get(name string) ([]byte, error) { if d, ok := m.data[name]; ok { return d, nil } if d, ok := m.consistent[name]; ok { return d, nil } return nil, ErrMetaNotFound{Resource: name} }
go
func (m MemoryStore) Get(name string) ([]byte, error) { if d, ok := m.data[name]; ok { return d, nil } if d, ok := m.consistent[name]; ok { return d, nil } return nil, ErrMetaNotFound{Resource: name} }
[ "func", "(", "m", "MemoryStore", ")", "Get", "(", "name", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "d", ",", "ok", ":=", "m", ".", "data", "[", "name", "]", ";", "ok", "{", "return", "d", ",", "nil", "\n", "}", "\...
// Get returns the data associated with name
[ "Get", "returns", "the", "data", "associated", "with", "name" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/memorystore.go#L68-L76
train
theupdateframework/notary
storage/memorystore.go
Set
func (m *MemoryStore) Set(name string, meta []byte) error { m.data[name] = meta parsedMeta := &data.SignedMeta{} err := json.Unmarshal(meta, parsedMeta) if err == nil { // no parse error means this is metadata and not a key, so store by version version := parsedMeta.Signed.Version versionedName := fmt.Sprint...
go
func (m *MemoryStore) Set(name string, meta []byte) error { m.data[name] = meta parsedMeta := &data.SignedMeta{} err := json.Unmarshal(meta, parsedMeta) if err == nil { // no parse error means this is metadata and not a key, so store by version version := parsedMeta.Signed.Version versionedName := fmt.Sprint...
[ "func", "(", "m", "*", "MemoryStore", ")", "Set", "(", "name", "string", ",", "meta", "[", "]", "byte", ")", "error", "{", "m", ".", "data", "[", "name", "]", "=", "meta", "\n\n", "parsedMeta", ":=", "&", "data", ".", "SignedMeta", "{", "}", "\n"...
// Set sets the metadata value for the given name
[ "Set", "sets", "the", "metadata", "value", "for", "the", "given", "name" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/memorystore.go#L79-L95
train
theupdateframework/notary
storage/memorystore.go
SetMulti
func (m *MemoryStore) SetMulti(metas map[string][]byte) error { for role, blob := range metas { m.Set(role, blob) } return nil }
go
func (m *MemoryStore) SetMulti(metas map[string][]byte) error { for role, blob := range metas { m.Set(role, blob) } return nil }
[ "func", "(", "m", "*", "MemoryStore", ")", "SetMulti", "(", "metas", "map", "[", "string", "]", "[", "]", "byte", ")", "error", "{", "for", "role", ",", "blob", ":=", "range", "metas", "{", "m", ".", "Set", "(", "role", ",", "blob", ")", "\n", ...
// SetMulti sets multiple pieces of metadata for multiple names // in a single operation.
[ "SetMulti", "sets", "multiple", "pieces", "of", "metadata", "for", "multiple", "names", "in", "a", "single", "operation", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/memorystore.go#L99-L104
train
theupdateframework/notary
storage/memorystore.go
ListFiles
func (m *MemoryStore) ListFiles() []string { names := make([]string, 0, len(m.data)) for n := range m.data { names = append(names, n) } return names }
go
func (m *MemoryStore) ListFiles() []string { names := make([]string, 0, len(m.data)) for n := range m.data { names = append(names, n) } return names }
[ "func", "(", "m", "*", "MemoryStore", ")", "ListFiles", "(", ")", "[", "]", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "m", ".", "data", ")", ")", "\n", "for", "n", ":=", "range", "m", ".", "data...
// ListFiles returns a list of all files. The names returned should be // usable with Get directly, with no modification.
[ "ListFiles", "returns", "a", "list", "of", "all", "files", ".", "The", "names", "returned", "should", "be", "usable", "with", "Get", "directly", "with", "no", "modification", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/storage/memorystore.go#L131-L137
train
theupdateframework/notary
server/storage/tuf_store.go
NewTUFMetaStorage
func NewTUFMetaStorage(m MetaStore) *TUFMetaStorage { return &TUFMetaStorage{ MetaStore: m, cachedMeta: make(map[string]*storedMeta), } }
go
func NewTUFMetaStorage(m MetaStore) *TUFMetaStorage { return &TUFMetaStorage{ MetaStore: m, cachedMeta: make(map[string]*storedMeta), } }
[ "func", "NewTUFMetaStorage", "(", "m", "MetaStore", ")", "*", "TUFMetaStorage", "{", "return", "&", "TUFMetaStorage", "{", "MetaStore", ":", "m", ",", "cachedMeta", ":", "make", "(", "map", "[", "string", "]", "*", "storedMeta", ")", ",", "}", "\n", "}" ...
// NewTUFMetaStorage instantiates a TUFMetaStorage instance
[ "NewTUFMetaStorage", "instantiates", "a", "TUFMetaStorage", "instance" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/tuf_store.go#L23-L28
train
theupdateframework/notary
server/storage/tuf_store.go
GetCurrent
func (tms TUFMetaStorage) GetCurrent(gun data.GUN, tufRole data.RoleName) (*time.Time, []byte, error) { timestampTime, timestampJSON, err := tms.MetaStore.GetCurrent(gun, data.CanonicalTimestampRole) if err != nil { return nil, nil, err } // If we wanted data for the timestamp role, we're done here if tufRole ==...
go
func (tms TUFMetaStorage) GetCurrent(gun data.GUN, tufRole data.RoleName) (*time.Time, []byte, error) { timestampTime, timestampJSON, err := tms.MetaStore.GetCurrent(gun, data.CanonicalTimestampRole) if err != nil { return nil, nil, err } // If we wanted data for the timestamp role, we're done here if tufRole ==...
[ "func", "(", "tms", "TUFMetaStorage", ")", "GetCurrent", "(", "gun", "data", ".", "GUN", ",", "tufRole", "data", ".", "RoleName", ")", "(", "*", "time", ".", "Time", ",", "[", "]", "byte", ",", "error", ")", "{", "timestampTime", ",", "timestampJSON", ...
// GetCurrent gets a specific TUF record, by walking from the current Timestamp to other metadata by checksum
[ "GetCurrent", "gets", "a", "specific", "TUF", "record", "by", "walking", "from", "the", "current", "Timestamp", "to", "other", "metadata", "by", "checksum" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/tuf_store.go#L36-L107
train
theupdateframework/notary
server/storage/tuf_store.go
GetChecksum
func (tms TUFMetaStorage) GetChecksum(gun data.GUN, tufRole data.RoleName, checksum string) (*time.Time, []byte, error) { if cachedRoleData, ok := tms.cachedMeta[checksum]; ok { return cachedRoleData.createupdate, cachedRoleData.data, nil } roleTime, roleJSON, err := tms.MetaStore.GetChecksum(gun, tufRole, checksu...
go
func (tms TUFMetaStorage) GetChecksum(gun data.GUN, tufRole data.RoleName, checksum string) (*time.Time, []byte, error) { if cachedRoleData, ok := tms.cachedMeta[checksum]; ok { return cachedRoleData.createupdate, cachedRoleData.data, nil } roleTime, roleJSON, err := tms.MetaStore.GetChecksum(gun, tufRole, checksu...
[ "func", "(", "tms", "TUFMetaStorage", ")", "GetChecksum", "(", "gun", "data", ".", "GUN", ",", "tufRole", "data", ".", "RoleName", ",", "checksum", "string", ")", "(", "*", "time", ".", "Time", ",", "[", "]", "byte", ",", "error", ")", "{", "if", "...
// GetChecksum gets a specific TUF record by checksum, also checking the internal cache
[ "GetChecksum", "gets", "a", "specific", "TUF", "record", "by", "checksum", "also", "checking", "the", "internal", "cache" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/tuf_store.go#L110-L121
train
theupdateframework/notary
server/storage/tuf_store.go
Bootstrap
func (tms TUFMetaStorage) Bootstrap() error { if s, ok := tms.MetaStore.(storage.Bootstrapper); ok { return s.Bootstrap() } return fmt.Errorf("store does not support bootstrapping") }
go
func (tms TUFMetaStorage) Bootstrap() error { if s, ok := tms.MetaStore.(storage.Bootstrapper); ok { return s.Bootstrap() } return fmt.Errorf("store does not support bootstrapping") }
[ "func", "(", "tms", "TUFMetaStorage", ")", "Bootstrap", "(", ")", "error", "{", "if", "s", ",", "ok", ":=", "tms", ".", "MetaStore", ".", "(", "storage", ".", "Bootstrapper", ")", ";", "ok", "{", "return", "s", ".", "Bootstrap", "(", ")", "\n", "}"...
// Bootstrap the store with tables if possible
[ "Bootstrap", "the", "store", "with", "tables", "if", "possible" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/tuf_store.go#L124-L129
train