| 1 | package credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/ |
| 2 | |
| 3 | import ( |
| 4 | "netscip-go gomod github.com/golang/go/src go1.25.0 net/" |
| 5 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 6 | "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/" |
| 7 | "runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/" |
| 8 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 9 | "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/" |
| 10 | |
| 11 | "github.com/git-lfs/git-lfs/v3/configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/" |
| 12 | "github.com/git-lfs/go-netrc/netrcscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/" |
| 13 | "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/" |
| 14 | ) |
| 15 | |
| 16 | type NetrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NetrcFinder# interface { |
| 17 | FindMachinescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NetrcFinder#FindMachine.(string, string) *netrcscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/.Machinescip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine# |
| 18 | } |
| 19 | |
| 20 | const netrcBasenamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcBasename. = ".netrc" |
| 21 | const netrcAltBasenamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcAltBasename. = "_netrc" |
| 22 | |
| 23 | func ParseNetrcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/ParseNetrc().(osEnv configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#) (NetrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NetrcFinder#, string, error) { |
| 24 | home, _ := osEnv.Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Get.("HOME") |
| 25 | if len(home) == 0 { |
| 26 | return &noFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/noFinder#{}, "", nil |
| 27 | } |
| 28 | |
| 29 | nrcfilename := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(home, netrcBasenamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcBasename.) |
| 30 | if _, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Statscip-go gomod github.com/golang/go/src go1.25.0 os/Stat().(nrcfilename); err != nil { |
| 31 | // If on Windows, try _netrc instead |
| 32 | if runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.25.0 runtime/GOOS. == "windows" { |
| 33 | altFilename := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(home, netrcAltBasenamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcAltBasename.) |
| 34 | if _, errAlt := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Statscip-go gomod github.com/golang/go/src go1.25.0 os/Stat().(altFilename); errAlt != nil { |
| 35 | return &noFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/noFinder#{}, altFilename, nil |
| 36 | } |
| 37 | nrcfilename = altFilename |
| 38 | } else { |
| 39 | return &noFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/noFinder#{}, nrcfilename, nil |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | f, err := netrcscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/.ParseFilescip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/ParseFile().(nrcfilename) |
| 44 | return f, nrcfilename, err |
| 45 | } |
| 46 | |
| 47 | type noFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/noFinder# struct{} |
| 48 | |
| 49 | func (f *noFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/noFinder#) FindMachinescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/noFinder#FindMachine().(host string, loginName string) *netrcscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/.Machinescip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine# { |
| 50 | return nil |
| 51 | } |
| 52 | |
| 53 | // NetrcCredentialHelper retrieves credentials from a .netrc file |
| 54 | type netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper# struct { |
| 55 | netrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#netrcFinder. NetrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NetrcFinder# |
| 56 | muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#mu. syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.Mutexscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex# |
| 57 | skipscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#skip. map[string]bool |
| 58 | } |
| 59 | |
| 60 | var defaultNetrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/defaultNetrcFinder. = &noFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/noFinder#{} |
| 61 | |
| 62 | // NewNetrcCredentialHelper creates a new netrc credential helper using a |
| 63 | // .netrc file gleaned from the OS environment |
| 64 | func newNetrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/newNetrcCredentialHelper().(osEnv configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#) *netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper# { |
| 65 | netrcFinder, netrcfile, err := ParseNetrcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/ParseNetrc().(osEnv) |
| 66 | if err != nil { |
| 67 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("bad netrc file %s: %s", netrcfile, err) |
| 68 | return nil |
| 69 | } |
| 70 | |
| 71 | if netrcFinder == nil { |
| 72 | netrcFinder = defaultNetrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/defaultNetrcFinder. |
| 73 | } |
| 74 | |
| 75 | return &netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#{netrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#netrcFinder.: netrcFinder, skipscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#skip.: make(map[string]bool)} |
| 76 | } |
| 77 | |
| 78 | func (c *netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#) Fillscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#Fill().(what Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#) (Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#, error) { |
| 79 | host, err := getNetrcHostnamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/getNetrcHostname().(FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "host")) |
| 80 | if err != nil { |
| 81 | return nil, credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. |
| 82 | } |
| 83 | c.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#mu..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().() |
| 84 | defer c.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#mu..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().() |
| 85 | if c.skipscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#skip.[host] { |
| 86 | return nil, credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. |
| 87 | } |
| 88 | if machine := c.netrcFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#netrcFinder..FindMachinescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NetrcFinder#FindMachine.(host, FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "username")); machine != nil { |
| 89 | creds := make(Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#) |
| 90 | creds["username"] = []string{machine.Loginscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine#Login.} |
| 91 | creds["password"] = []string{machine.Passwordscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine#Password.} |
| 92 | creds["protocol"] = what["protocol"] |
| 93 | creds["host"] = what["host"] |
| 94 | creds["scheme"] = what["scheme"] |
| 95 | creds["path"] = what["path"] |
| 96 | creds["source"] = []string{"netrc"} |
| 97 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("netrc: git credential fill (%q, %q, %q, %q)", |
| 98 | FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "protocol"), |
| 99 | FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "host"), machine.Loginscip-go gomod github.com/git-lfs/go-netrc ba0029b43d11 `github.com/git-lfs/go-netrc/netrc`/Machine#Login., |
| 100 | FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "path")) |
| 101 | return creds, nil |
| 102 | } |
| 103 | |
| 104 | return nil, credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. |
| 105 | } |
| 106 | |
| 107 | func getNetrcHostnamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/getNetrcHostname().(hostname string) (string, error) { |
| 108 | if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.25.0 strings/Contains().(hostname, ":") { |
| 109 | host, _, err := netscip-go gomod github.com/golang/go/src go1.25.0 net/.SplitHostPortscip-go gomod github.com/golang/go/src go1.25.0 net/SplitHostPort().(hostname) |
| 110 | if err != nil { |
| 111 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("netrc: error parsing %q: %s", hostname, err) |
| 112 | return "", err |
| 113 | } |
| 114 | return host, nil |
| 115 | } |
| 116 | |
| 117 | return hostname, nil |
| 118 | } |
| 119 | |
| 120 | func (c *netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#) Approvescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#Approve().(what Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#) error { |
| 121 | if FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "source") == "netrc" { |
| 122 | host, err := getNetrcHostnamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/getNetrcHostname().(FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "host")) |
| 123 | if err != nil { |
| 124 | return credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. |
| 125 | } |
| 126 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("netrc: git credential approve (%q, %q, %q)", |
| 127 | FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "protocol"), |
| 128 | FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "host"), |
| 129 | FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "path")) |
| 130 | c.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#mu..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().() |
| 131 | c.skipscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#skip.[host] = false |
| 132 | c.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#mu..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().() |
| 133 | return nil |
| 134 | } |
| 135 | return credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. |
| 136 | } |
| 137 | |
| 138 | func (c *netrcCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#) Rejectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#Reject().(what Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#) error { |
| 139 | if FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(what, "source") == "netrc" { |
| 140 | host, err := getNetrcHostnamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/getNetrcHostname().(what["host"][0]) |
| 141 | if err != nil { |
| 142 | return credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. |
| 143 | } |
| 144 | |
| 145 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("netrc: git credential reject (%q, %q, %q)", |
| 146 | what["protocol"], what["host"], what["path"]) |
| 147 | c.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#mu..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().() |
| 148 | c.skipscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#skip.[host] = true |
| 149 | c.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/netrcCredentialHelper#mu..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().() |
| 150 | return nil |
| 151 | } |
| 152 | return credHelperNoOpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/credHelperNoOp. |
| 153 | } |