_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q24100 | NewImplicitRole | train | func NewImplicitRole() Role {
return &RoleV3{
Kind: KindRole,
Version: V3,
Metadata: Metadata{
Name: teleport.DefaultImplicitRole,
Namespace: defaults.Namespace,
},
Spec: RoleSpecV3{
Options: RoleOptions{
MaxSessionTTL: MaxDuration(),
},
Allow: RoleConditions{
Namespaces: []str... | go | {
"resource": ""
} |
q24101 | RoleForUser | train | func RoleForUser(u User) Role {
return &RoleV3{
Kind: KindRole,
Version: V3,
Metadata: Metadata{
Name: RoleNameForUser(u.GetName()),
Namespace: defaults.Namespace,
},
Spec: RoleSpecV3{
Options: RoleOptions{
CertificateFormat: teleport.CertificateFormatStandard,
MaxSessionTTL: New... | go | {
"resource": ""
} |
q24102 | RoleForCertAuthority | train | func RoleForCertAuthority(ca CertAuthority) Role {
return &RoleV3{
Kind: KindRole,
Version: V3,
Metadata: Metadata{
Name: RoleNameForCertAuthority(ca.GetClusterName()),
Namespace: defaults.Namespace,
},
Spec: RoleSpecV3{
Options: RoleOptions{
MaxSessionTTL: NewDuration(defaults.MaxCertDu... | go | {
"resource": ""
} |
q24103 | ConvertV1CertAuthority | train | func ConvertV1CertAuthority(v1 *CertAuthorityV1) (CertAuthority, Role) {
ca := v1.V2()
role := RoleForCertAuthority(ca)
role.SetLogins(Allow, v1.AllowedLogins)
ca.AddRole(role.GetName())
return ca, role
} | go | {
"resource": ""
} |
q24104 | applyValueTraits | train | func applyValueTraits(val string, traits map[string][]string) ([]string, error) {
// Extract the variablePrefix and variableName from the role variable.
variablePrefix, variableName, err := parse.IsRoleVariable(val)
if err != nil {
if !trace.IsNotFound(err) {
return nil, trace.Wrap(err)
}
return []string{v... | go | {
"resource": ""
} |
q24105 | Equals | train | func (r *RoleV3) Equals(other Role) bool {
if !r.GetOptions().Equals(other.GetOptions()) {
return false
}
for _, condition := range []RoleConditionType{Allow, Deny} {
if !utils.StringSlicesEqual(r.GetLogins(condition), other.GetLogins(condition)) {
return false
}
if !utils.StringSlicesEqual(r.GetNamespac... | go | {
"resource": ""
} |
q24106 | GetLogins | train | func (r *RoleV3) GetLogins(rct RoleConditionType) []string {
if rct == Allow {
return r.Spec.Allow.Logins
}
return r.Spec.Deny.Logins
} | go | {
"resource": ""
} |
q24107 | SetLogins | train | func (r *RoleV3) SetLogins(rct RoleConditionType, logins []string) {
lcopy := utils.CopyStrings(logins)
if rct == Allow {
r.Spec.Allow.Logins = lcopy
} else {
r.Spec.Deny.Logins = lcopy
}
} | go | {
"resource": ""
} |
q24108 | GetKubeGroups | train | func (r *RoleV3) GetKubeGroups(rct RoleConditionType) []string {
if rct == Allow {
return r.Spec.Allow.KubeGroups
}
return r.Spec.Deny.KubeGroups
} | go | {
"resource": ""
} |
q24109 | SetKubeGroups | train | func (r *RoleV3) SetKubeGroups(rct RoleConditionType, groups []string) {
lcopy := utils.CopyStrings(groups)
if rct == Allow {
r.Spec.Allow.KubeGroups = lcopy
} else {
r.Spec.Deny.KubeGroups = lcopy
}
} | go | {
"resource": ""
} |
q24110 | GetNamespaces | train | func (r *RoleV3) GetNamespaces(rct RoleConditionType) []string {
if rct == Allow {
return r.Spec.Allow.Namespaces
}
return r.Spec.Deny.Namespaces
} | go | {
"resource": ""
} |
q24111 | SetNamespaces | train | func (r *RoleV3) SetNamespaces(rct RoleConditionType, namespaces []string) {
ncopy := utils.CopyStrings(namespaces)
if rct == Allow {
r.Spec.Allow.Namespaces = ncopy
} else {
r.Spec.Deny.Namespaces = ncopy
}
} | go | {
"resource": ""
} |
q24112 | GetNodeLabels | train | func (r *RoleV3) GetNodeLabels(rct RoleConditionType) Labels {
if rct == Allow {
return r.Spec.Allow.NodeLabels
}
return r.Spec.Deny.NodeLabels
} | go | {
"resource": ""
} |
q24113 | SetNodeLabels | train | func (r *RoleV3) SetNodeLabels(rct RoleConditionType, labels Labels) {
if rct == Allow {
r.Spec.Allow.NodeLabels = labels.Clone()
} else {
r.Spec.Deny.NodeLabels = labels.Clone()
}
} | go | {
"resource": ""
} |
q24114 | GetRules | train | func (r *RoleV3) GetRules(rct RoleConditionType) []Rule {
if rct == Allow {
return r.Spec.Allow.Rules
}
return r.Spec.Deny.Rules
} | go | {
"resource": ""
} |
q24115 | SetRules | train | func (r *RoleV3) SetRules(rct RoleConditionType, in []Rule) {
rcopy := CopyRulesSlice(in)
if rct == Allow {
r.Spec.Allow.Rules = rcopy
} else {
r.Spec.Deny.Rules = rcopy
}
} | go | {
"resource": ""
} |
q24116 | String | train | func (r *RoleV3) String() string {
return fmt.Sprintf("Role(Name=%v,Options=%v,Allow=%+v,Deny=%+v)",
r.GetName(), r.Spec.Options, r.Spec.Allow, r.Spec.Deny)
} | go | {
"resource": ""
} |
q24117 | NewRule | train | func NewRule(resource string, verbs []string) Rule {
return Rule{
Resources: []string{resource},
Verbs: verbs,
}
} | go | {
"resource": ""
} |
q24118 | CheckAndSetDefaults | train | func (r *Rule) CheckAndSetDefaults() error {
if len(r.Resources) == 0 {
return trace.BadParameter("missing resources to match")
}
if len(r.Verbs) == 0 {
return trace.BadParameter("missing verbs")
}
if len(r.Where) != 0 {
parser, err := GetWhereParserFn()(&Context{})
if err != nil {
return trace.Wrap(err... | go | {
"resource": ""
} |
q24119 | score | train | func (r *Rule) score() int {
score := 0
// wilcard rules are less specific
if utils.SliceContainsStr(r.Resources, Wildcard) {
score -= 4
} else if len(r.Resources) == 1 {
// rules that match specific resource are more specific than
// fields that match several resources
score += 2
}
// rules that have wil... | go | {
"resource": ""
} |
q24120 | MatchesWhere | train | func (r *Rule) MatchesWhere(parser predicate.Parser) (bool, error) {
if r.Where == "" {
return true, nil
}
ifn, err := parser.Parse(r.Where)
if err != nil {
return false, trace.Wrap(err)
}
fn, ok := ifn.(predicate.BoolPredicate)
if !ok {
return false, trace.BadParameter("unsupported type: %T", ifn)
}
ret... | go | {
"resource": ""
} |
q24121 | ProcessActions | train | func (r *Rule) ProcessActions(parser predicate.Parser) error {
for _, action := range r.Actions {
ifn, err := parser.Parse(action)
if err != nil {
return trace.Wrap(err)
}
fn, ok := ifn.(predicate.BoolPredicate)
if !ok {
return trace.BadParameter("unsupported type: %T", ifn)
}
fn()
}
return nil
} | go | {
"resource": ""
} |
q24122 | HasResource | train | func (r *Rule) HasResource(resource string) bool {
for _, r := range r.Resources {
if r == resource {
return true
}
}
return false
} | go | {
"resource": ""
} |
q24123 | HasVerb | train | func (r *Rule) HasVerb(verb string) bool {
for _, v := range r.Verbs {
// readnosecrets can be satisfied by having readnosecrets or read
if verb == VerbReadNoSecrets {
if v == VerbReadNoSecrets || v == VerbRead {
return true
}
continue
}
if v == verb {
return true
}
}
return false
} | go | {
"resource": ""
} |
q24124 | Equals | train | func (r *Rule) Equals(other Rule) bool {
if !utils.StringSlicesEqual(r.Resources, other.Resources) {
return false
}
if !utils.StringSlicesEqual(r.Verbs, other.Verbs) {
return false
}
if !utils.StringSlicesEqual(r.Actions, other.Actions) {
return false
}
if r.Where != other.Where {
return false
}
return... | go | {
"resource": ""
} |
q24125 | Slice | train | func (set RuleSet) Slice() []Rule {
var out []Rule
for _, rules := range set {
out = append(out, rules...)
}
return out
} | go | {
"resource": ""
} |
q24126 | MakeRuleSet | train | func MakeRuleSet(rules []Rule) RuleSet {
set := make(RuleSet)
for _, rule := range rules {
for _, resource := range rule.Resources {
rules, ok := set[resource]
if !ok {
set[resource] = []Rule{rule}
} else {
rules = append(rules, rule)
set[resource] = rules
}
}
}
for resource := range set... | go | {
"resource": ""
} |
q24127 | CopyRulesSlice | train | func CopyRulesSlice(in []Rule) []Rule {
out := make([]Rule, len(in))
copy(out, in)
return out
} | go | {
"resource": ""
} |
q24128 | RuleSlicesEqual | train | func RuleSlicesEqual(a, b []Rule) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if !a[i].Equals(b[i]) {
return false
}
}
return true
} | go | {
"resource": ""
} |
q24129 | Equals | train | func (r *RoleV2) Equals(other Role) bool {
return r.V3().Equals(other)
} | go | {
"resource": ""
} |
q24130 | SetResource | train | func (r *RoleV2) SetResource(kind string, actions []string) {
if r.Spec.Resources == nil {
r.Spec.Resources = make(map[string][]string)
}
r.Spec.Resources[kind] = actions
} | go | {
"resource": ""
} |
q24131 | RemoveResource | train | func (r *RoleV2) RemoveResource(kind string) {
delete(r.Spec.Resources, kind)
} | go | {
"resource": ""
} |
q24132 | SetNodeLabels | train | func (r *RoleV2) SetNodeLabels(labels map[string]string) {
r.Spec.NodeLabels = labels
} | go | {
"resource": ""
} |
q24133 | SetMaxSessionTTL | train | func (r *RoleV2) SetMaxSessionTTL(duration time.Duration) {
r.Spec.MaxSessionTTL = Duration(duration)
} | go | {
"resource": ""
} |
q24134 | FromSpec | train | func FromSpec(name string, spec RoleSpecV3) (RoleSet, error) {
role, err := NewRole(name, spec)
if err != nil {
return nil, trace.Wrap(err)
}
return NewRoleSet(role), nil
} | go | {
"resource": ""
} |
q24135 | NewRole | train | func NewRole(name string, spec RoleSpecV3) (Role, error) {
role := RoleV3{
Kind: KindRole,
Version: V3,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := role.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
return &role, nil
} | go | {
"resource": ""
} |
q24136 | FetchRoles | train | func FetchRoles(roleNames []string, access RoleGetter, traits map[string][]string) (RoleSet, error) {
var roles []Role
for _, roleName := range roleNames {
role, err := access.GetRole(roleName)
if err != nil {
return nil, trace.Wrap(err)
}
roles = append(roles, role.ApplyTraits(traits))
}
return NewRol... | go | {
"resource": ""
} |
q24137 | NewRoleSet | train | func NewRoleSet(roles ...Role) RoleSet {
// unauthenticated Nop role should not have any privileges
// by default, otherwise it is too permissive
if len(roles) == 1 && roles[0].GetName() == string(teleport.RoleNop) {
return roles
}
return append(roles, NewImplicitRole())
} | go | {
"resource": ""
} |
q24138 | MatchNamespace | train | func MatchNamespace(selectors []string, namespace string) (bool, string) {
for _, n := range selectors {
if n == namespace || n == Wildcard {
return true, "matched"
}
}
return false, fmt.Sprintf("no match, role selectors %v, server namespace: %v", selectors, namespace)
} | go | {
"resource": ""
} |
q24139 | MatchLogin | train | func MatchLogin(selectors []string, login string) (bool, string) {
for _, l := range selectors {
if l == login {
return true, "matched"
}
}
return false, fmt.Sprintf("no match, role selectors %v, login: %v", selectors, login)
} | go | {
"resource": ""
} |
q24140 | MatchLabels | train | func MatchLabels(selector Labels, target map[string]string) (bool, string, error) {
// Empty selector matches nothing.
if len(selector) == 0 {
return false, "no match, empty selector", nil
}
// *: * matches everything even empty target set.
selectorValues := selector[Wildcard]
if len(selectorValues) == 1 && se... | go | {
"resource": ""
} |
q24141 | RoleNames | train | func (set RoleSet) RoleNames() []string {
out := make([]string, len(set))
for i, r := range set {
out[i] = r.GetName()
}
return out
} | go | {
"resource": ""
} |
q24142 | HasRole | train | func (set RoleSet) HasRole(role string) bool {
for _, r := range set {
if r.GetName() == role {
return true
}
}
return false
} | go | {
"resource": ""
} |
q24143 | AdjustSessionTTL | train | func (set RoleSet) AdjustSessionTTL(ttl time.Duration) time.Duration {
for _, role := range set {
maxSessionTTL := role.GetOptions().MaxSessionTTL.Value()
if maxSessionTTL != 0 && ttl > maxSessionTTL {
ttl = maxSessionTTL
}
}
return ttl
} | go | {
"resource": ""
} |
q24144 | AdjustClientIdleTimeout | train | func (set RoleSet) AdjustClientIdleTimeout(timeout time.Duration) time.Duration {
if timeout < 0 {
timeout = 0
}
for _, role := range set {
roleTimeout := role.GetOptions().ClientIdleTimeout
// 0 means not set, so it can't be most restrictive, disregard it too
if roleTimeout.Duration() <= 0 {
continue
}... | go | {
"resource": ""
} |
q24145 | AdjustDisconnectExpiredCert | train | func (set RoleSet) AdjustDisconnectExpiredCert(disconnect bool) bool {
for _, role := range set {
if role.GetOptions().DisconnectExpiredCert.Value() {
disconnect = true
}
}
return disconnect
} | go | {
"resource": ""
} |
q24146 | CheckKubeGroups | train | func (set RoleSet) CheckKubeGroups(ttl time.Duration) ([]string, error) {
groups := make(map[string]bool)
var matchedTTL bool
for _, role := range set {
maxSessionTTL := role.GetOptions().MaxSessionTTL.Value()
if ttl <= maxSessionTTL && maxSessionTTL != 0 {
matchedTTL = true
for _, group := range role.GetK... | go | {
"resource": ""
} |
q24147 | CheckLoginDuration | train | func (set RoleSet) CheckLoginDuration(ttl time.Duration) ([]string, error) {
logins := make(map[string]bool)
var matchedTTL bool
for _, role := range set {
maxSessionTTL := role.GetOptions().MaxSessionTTL.Value()
if ttl <= maxSessionTTL && maxSessionTTL != 0 {
matchedTTL = true
for _, login := range role.... | go | {
"resource": ""
} |
q24148 | CanForwardAgents | train | func (set RoleSet) CanForwardAgents() bool {
for _, role := range set {
if role.GetOptions().ForwardAgent.Value() {
return true
}
}
return false
} | go | {
"resource": ""
} |
q24149 | CanPortForward | train | func (set RoleSet) CanPortForward() bool {
for _, role := range set {
if BoolDefaultTrue(role.GetOptions().PortForwarding) {
return true
}
}
return false
} | go | {
"resource": ""
} |
q24150 | CertificateFormat | train | func (set RoleSet) CertificateFormat() string {
var formats []string
for _, role := range set {
// get the certificate format for each individual role. if a role does not
// have a certificate format (like implicit roles) skip over it
certificateFormat := role.GetOptions().CertificateFormat
if certificateFor... | go | {
"resource": ""
} |
q24151 | CheckAgentForward | train | func (set RoleSet) CheckAgentForward(login string) error {
// check if we have permission to login and forward agent. we don't check
// for deny rules because if you can't forward an agent if you can't login
// in the first place.
for _, role := range set {
for _, l := range role.GetLogins(Allow) {
if role.Get... | go | {
"resource": ""
} |
q24152 | Clone | train | func (l Labels) Clone() Labels {
if l == nil {
return nil
}
out := make(Labels, len(l))
for key, vals := range l {
cvals := make([]string, len(vals))
copy(cvals, vals)
out[key] = cvals
}
return out
} | go | {
"resource": ""
} |
q24153 | Equals | train | func (l Labels) Equals(o Labels) bool {
if len(l) != len(o) {
return false
}
for key := range l {
if !utils.StringSlicesEqual(l[key], o[key]) {
return false
}
}
return true
} | go | {
"resource": ""
} |
q24154 | MarshalTo | train | func (b BoolOption) MarshalTo(data []byte) (int, error) {
return b.protoType().MarshalTo(data)
} | go | {
"resource": ""
} |
q24155 | UnmarshalJSON | train | func (d *Duration) UnmarshalJSON(data []byte) error {
if len(data) == 0 {
return nil
}
var stringVar string
if err := json.Unmarshal(data, &stringVar); err != nil {
return trace.Wrap(err)
}
if stringVar == teleport.DurationNever {
*d = Duration(0)
} else {
out, err := time.ParseDuration(stringVar)
if e... | go | {
"resource": ""
} |
q24156 | GetRoleSchema | train | func GetRoleSchema(version string, extensionSchema string) string {
schemaDefinitions := "," + RoleSpecV3SchemaDefinitions
if version == V2 {
schemaDefinitions = DefaultDefinitions
}
schemaTemplate := RoleSpecV3SchemaTemplate
if version == V2 {
schemaTemplate = RoleSpecV2SchemaTemplate
}
schema := fmt.Spri... | go | {
"resource": ""
} |
q24157 | UnmarshalRole | train | func UnmarshalRole(data []byte, opts ...MarshalOption) (*RoleV3, error) {
var h ResourceHeader
err := json.Unmarshal(data, &h)
if err != nil {
h.Version = V2
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch h.Version {
case V2:
var role RoleV2
if err := utils.Un... | go | {
"resource": ""
} |
q24158 | UnmarshalRole | train | func (*TeleportRoleMarshaler) UnmarshalRole(bytes []byte, opts ...MarshalOption) (Role, error) {
return UnmarshalRole(bytes, opts...)
} | go | {
"resource": ""
} |
q24159 | MarshalRole | train | func (*TeleportRoleMarshaler) MarshalRole(r Role, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch role := r.(type) {
case *RoleV3:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected da... | go | {
"resource": ""
} |
q24160 | Initialize | train | func (g *ResourceCommand) Initialize(app *kingpin.Application, config *service.Config) {
g.CreateHandlers = map[ResourceKind]ResourceCreateHandler{
services.KindUser: g.createUser,
services.KindTrustedCluster: g.createTrustedCluster,
services.KindGithubConnector: g.createGithubConnector,
services.K... | go | {
"resource": ""
} |
q24161 | IsDeleteSubcommand | train | func (g *ResourceCommand) IsDeleteSubcommand(cmd string) bool {
return cmd == g.deleteCmd.FullCommand()
} | go | {
"resource": ""
} |
q24162 | Get | train | func (g *ResourceCommand) Get(client auth.ClientI) error {
collection, err := g.getCollection(client)
if err != nil {
return trace.Wrap(err)
}
// Note that only YAML is officially supported. Support for text and JSON
// is experimental.
switch g.format {
case teleport.YAML:
return collection.writeYAML(os.St... | go | {
"resource": ""
} |
q24163 | Create | train | func (u *ResourceCommand) Create(client auth.ClientI) error {
reader, err := utils.OpenFile(u.filename)
if err != nil {
return trace.Wrap(err)
}
decoder := kyaml.NewYAMLOrJSONDecoder(reader, 32*1024)
count := 0
for {
var raw services.UnknownResource
err := decoder.Decode(&raw)
if err != nil {
if err ==... | go | {
"resource": ""
} |
q24164 | createTrustedCluster | train | func (u *ResourceCommand) createTrustedCluster(client auth.ClientI, raw services.UnknownResource) error {
tc, err := services.GetTrustedClusterMarshaler().Unmarshal(raw.Raw)
if err != nil {
return trace.Wrap(err)
}
// check if such cluster already exists:
name := tc.GetName()
_, err = client.GetTrustedCluster(... | go | {
"resource": ""
} |
q24165 | createCertAuthority | train | func (u *ResourceCommand) createCertAuthority(client auth.ClientI, raw services.UnknownResource) error {
certAuthority, err := services.GetCertAuthorityMarshaler().UnmarshalCertAuthority(raw.Raw)
if err != nil {
return trace.Wrap(err)
}
if err := client.UpsertCertAuthority(certAuthority); err != nil {
return tr... | go | {
"resource": ""
} |
q24166 | createUser | train | func (u *ResourceCommand) createUser(client auth.ClientI, raw services.UnknownResource) error {
user, err := services.GetUserMarshaler().UnmarshalUser(raw.Raw)
if err != nil {
return trace.Wrap(err)
}
userName := user.GetName()
if err := client.UpsertUser(user); err != nil {
return trace.Wrap(err)
}
fmt.Prin... | go | {
"resource": ""
} |
q24167 | Delete | train | func (d *ResourceCommand) Delete(client auth.ClientI) (err error) {
if d.ref.Kind == "" || d.ref.Name == "" {
return trace.BadParameter("provide a full resource name to delete, for example:\n$ tctl rm cluster/east\n")
}
switch d.ref.Kind {
case services.KindNode:
if err = client.DeleteNode(defaults.Namespace, ... | go | {
"resource": ""
} |
q24168 | NewHostCertificateCache | train | func NewHostCertificateCache(keygen sshca.Authority, authClient auth.ClientI) (*certificateCache, error) {
cache, err := ttlmap.New(defaults.HostCertCacheSize)
if err != nil {
return nil, trace.Wrap(err)
}
return &certificateCache{
keygen: keygen,
cache: cache,
authClient: authClient,
}, nil
} | go | {
"resource": ""
} |
q24169 | GetHostCertificate | train | func (c *certificateCache) GetHostCertificate(addr string, additionalPrincipals []string) (ssh.Signer, error) {
var certificate ssh.Signer
var err error
var ok bool
var principals []string
principals = append(principals, addr)
principals = append(principals, additionalPrincipals...)
certificate, ok = c.get(str... | go | {
"resource": ""
} |
q24170 | get | train | func (c *certificateCache) get(addr string) (ssh.Signer, bool) {
c.mu.Lock()
defer c.mu.Unlock()
certificate, ok := c.cache.Get(addr)
if !ok {
return nil, false
}
certificateSigner, ok := certificate.(ssh.Signer)
if !ok {
return nil, false
}
return certificateSigner, true
} | go | {
"resource": ""
} |
q24171 | set | train | func (c *certificateCache) set(addr string, certificate ssh.Signer, ttl time.Duration) error {
c.mu.Lock()
defer c.mu.Unlock()
err := c.cache.Set(addr, certificate, ttl)
if err != nil {
return trace.Wrap(err)
}
return nil
} | go | {
"resource": ""
} |
q24172 | generateHostCert | train | func (c *certificateCache) generateHostCert(principals []string) (ssh.Signer, error) {
if len(principals) == 0 {
return nil, trace.BadParameter("at least one principal must be provided")
}
// Generate public/private keypair.
privBytes, pubBytes, err := c.keygen.GetNewKeyPairFromPool()
if err != nil {
return n... | go | {
"resource": ""
} |
q24173 | NewMonitor | train | func NewMonitor(cfg MonitorConfig) (*Monitor, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
return &Monitor{
MonitorConfig: cfg,
}, nil
} | go | {
"resource": ""
} |
q24174 | OnStart | train | func OnStart(config *service.Config) error {
return service.Run(context.TODO(), *config, nil)
} | go | {
"resource": ""
} |
q24175 | onStatus | train | func onStatus() error {
sshClient := os.Getenv("SSH_CLIENT")
systemUser := os.Getenv("USER")
teleportUser := os.Getenv(teleport.SSHTeleportUser)
proxyHost := os.Getenv(teleport.SSHSessionWebproxyAddr)
clusterName := os.Getenv(teleport.SSHTeleportClusterName)
hostUUID := os.Getenv(teleport.SSHTeleportHostUUID)
si... | go | {
"resource": ""
} |
q24176 | CopyByteSlice | train | func CopyByteSlice(in []byte) []byte {
if in == nil {
return nil
}
out := make([]byte, len(in))
copy(out, in)
return out
} | go | {
"resource": ""
} |
q24177 | CopyByteSlices | train | func CopyByteSlices(in [][]byte) [][]byte {
if in == nil {
return nil
}
out := make([][]byte, len(in))
for i := range in {
out[i] = CopyByteSlice(in[i])
}
return out
} | go | {
"resource": ""
} |
q24178 | JoinStringSlices | train | func JoinStringSlices(a []string, b []string) []string {
if len(a)+len(b) == 0 {
return nil
}
out := make([]string, 0, len(a)+len(b))
out = append(out, a...)
out = append(out, b...)
return out
} | go | {
"resource": ""
} |
q24179 | CopyStrings | train | func CopyStrings(in []string) []string {
if in == nil {
return nil
}
out := make([]string, len(in))
copy(out, in)
return out
} | go | {
"resource": ""
} |
q24180 | ReplaceInSlice | train | func ReplaceInSlice(s []string, old string, new string) []string {
out := make([]string, 0, len(s))
for _, x := range s {
if x == old {
out = append(out, new)
} else {
out = append(out, x)
}
}
return out
} | go | {
"resource": ""
} |
q24181 | reconnectToAuthService | train | func (process *TeleportProcess) reconnectToAuthService(role teleport.Role) (*Connector, error) {
retryTime := defaults.HighResPollingPeriod
for {
connector, err := process.connectToAuthService(role)
if err == nil {
// if connected and client is present, make sure the connector's
// client works, by using ca... | go | {
"resource": ""
} |
q24182 | connectToAuthService | train | func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Connector, error) {
connector, err := process.connect(role)
if err != nil {
return nil, trace.Wrap(err)
}
process.Debugf("Connected client: %v", connector.ClientIdentity)
process.Debugf("Connected server: %v", connector.ServerIdentity)
p... | go | {
"resource": ""
} |
q24183 | newWatcher | train | func (process *TeleportProcess) newWatcher(conn *Connector, watch services.Watch) (services.Watcher, error) {
if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth {
return process.localAuth.NewWatcher(process.ExitContext(), watch)
}
return conn.Client.NewWatcher(... | go | {
"resource": ""
} |
q24184 | getCertAuthority | train | func (process *TeleportProcess) getCertAuthority(conn *Connector, id services.CertAuthID, loadPrivateKeys bool) (services.CertAuthority, error) {
if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth {
return process.localAuth.GetCertAuthority(id, loadPrivateKeys)
... | go | {
"resource": ""
} |
q24185 | reRegister | train | func (process *TeleportProcess) reRegister(conn *Connector, additionalPrincipals []string, dnsNames []string, rotation services.Rotation) (*auth.Identity, error) {
if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth {
return auth.GenerateIdentity(process.localAuth... | go | {
"resource": ""
} |
q24186 | periodicSyncRotationState | train | func (process *TeleportProcess) periodicSyncRotationState() error {
// start rotation only after teleport process has started
eventC := make(chan Event, 1)
process.WaitForEvent(process.ExitContext(), TeleportReadyEvent, eventC)
select {
case <-eventC:
process.Infof("The new service has started successfully. Star... | go | {
"resource": ""
} |
q24187 | syncRotationStateAndBroadcast | train | func (process *TeleportProcess) syncRotationStateAndBroadcast(conn *Connector) (*rotationStatus, error) {
status, err := process.syncRotationState(conn)
if err != nil {
process.BroadcastEvent(Event{Name: TeleportDegradedEvent, Payload: nil})
if trace.IsConnectionProblem(err) {
process.Warningf("Connection prob... | go | {
"resource": ""
} |
q24188 | syncRotationState | train | func (process *TeleportProcess) syncRotationState(conn *Connector) (*rotationStatus, error) {
connectors := process.getConnectors()
ca, err := process.getCertAuthority(conn, services.CertAuthID{
DomainName: conn.ClientIdentity.ClusterName,
Type: services.HostCA,
}, false)
if err != nil {
return nil, tra... | go | {
"resource": ""
} |
q24189 | newClient | train | func (process *TeleportProcess) newClient(authServers []utils.NetAddr, identity *auth.Identity) (*auth.Client, bool, error) {
directClient, err := process.newClientDirect(authServers, identity)
if err != nil {
return nil, false, trace.Wrap(err)
}
// Try and connect to the Auth Server. If the request fails, try a... | go | {
"resource": ""
} |
q24190 | findReverseTunnel | train | func (process *TeleportProcess) findReverseTunnel(addrs []utils.NetAddr) (string, error) {
var errs []error
for _, addr := range addrs {
// In insecure mode, any certificate is accepted. In secure mode the hosts
// CAs are used to validate the certificate on the proxy.
clt, err := client.NewCredentialsClient(
... | go | {
"resource": ""
} |
q24191 | CalculateSPKI | train | func CalculateSPKI(cert *x509.Certificate) string {
sum := sha256.Sum256(cert.RawSubjectPublicKeyInfo)
return "sha256:" + hex.EncodeToString(sum[:])
} | go | {
"resource": ""
} |
q24192 | CheckSPKI | train | func CheckSPKI(pin string, cert *x509.Certificate) error {
// Check that the format of the pin is valid.
parts := strings.Split(pin, ":")
if len(parts) != 2 {
return trace.BadParameter("invalid format for certificate pin, expected algorithm:pin")
}
if parts[0] != "sha256" {
return trace.BadParameter("sha256 on... | go | {
"resource": ""
} |
q24193 | MakeHandler | train | func MakeHandler(fn HandlerFunc) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
// ensure that neither proxies nor browsers cache http traffic
SetNoCacheHeaders(w.Header())
out, err := fn(w, r, p)
if err != nil {
trace.WriteError(w, err)
return
}
if ou... | go | {
"resource": ""
} |
q24194 | MakeStdHandler | train | func MakeStdHandler(fn StdHandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// ensure that neither proxies nor browsers cache http traffic
SetNoCacheHeaders(w.Header())
out, err := fn(w, r)
if err != nil {
trace.WriteError(w, err)
return
}
if out != nil {
round... | go | {
"resource": ""
} |
q24195 | WithCSRFProtection | train | func WithCSRFProtection(fn HandlerFunc) httprouter.Handle {
hanlderFn := MakeHandler(fn)
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
err := csrf.VerifyHTTPHeader(r)
if err != nil {
log.Warningf("unable to validate CSRF token %v", err)
trace.WriteError(w, trace.AccessDenied("ac... | go | {
"resource": ""
} |
q24196 | ConvertResponse | train | func ConvertResponse(re *roundtrip.Response, err error) (*roundtrip.Response, error) {
if err != nil {
if uerr, ok := err.(*url.Error); ok && uerr != nil && uerr.Err != nil {
return nil, trace.ConnectionProblem(uerr.Err, uerr.Error())
}
return nil, trace.ConvertSystemError(err)
}
return re, trace.ReadError(... | go | {
"resource": ""
} |
q24197 | ParseBool | train | func ParseBool(q url.Values, name string) (bool, bool, error) {
stringVal := q.Get(name)
if stringVal == "" {
return false, false, nil
}
val, err := strconv.ParseBool(stringVal)
if err != nil {
return false, false, trace.BadParameter(
"'%v': expected 'true' or 'false', got %v", name, stringVal)
}
return ... | go | {
"resource": ""
} |
q24198 | Rewrite | train | func Rewrite(in, out string) RewritePair {
return RewritePair{
Expr: regexp.MustCompile(in),
Replacement: out,
}
} | go | {
"resource": ""
} |
q24199 | RewritePaths | train | func RewritePaths(next http.Handler, rewrites ...RewritePair) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
for _, rewrite := range rewrites {
req.URL.Path = rewrite.Expr.ReplaceAllString(req.URL.Path, rewrite.Replacement)
}
next.ServeHTTP(w, req)
})
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.