MCPcopy Index your code
hub / github.com/apache/devlake / typeIs

Method typeIs

backend/plugins/github/models/connection.go:259–282  ·  view source on GitHub ↗
(token string)

Source from the content-addressed store, hash-verified

257}
258
259func (conn *GithubConn) typeIs(token string) string {
260 // classical tokens:
261 // ghp_ for Personal Access Tokens
262 // gho_ for OAuth Access tokens
263 // ghu_ for GitHub App user-to-server tokens
264 // ghs_ for GitHub App server-to-server tokens
265 // ghr_ for GitHub App refresh tokens
266 // total len is 40, {prefix}{showPrefix}{secret}{showSuffix}
267 // fine-grained tokens
268 // github_pat_{82_characters}
269 classicalTokenClassicalPrefixes := []string{"ghp_", "gho_", "ghs_", "ghr_", "ghu_"}
270 classicalTokenFindGrainedPrefixes := []string{"github_pat_"}
271 for _, prefix := range classicalTokenClassicalPrefixes {
272 if strings.HasPrefix(token, prefix) {
273 return GithubTokenTypeClassical
274 }
275 }
276 for _, prefix := range classicalTokenFindGrainedPrefixes {
277 if strings.HasPrefix(token, prefix) {
278 return GithubTokenTypeFineGrained
279 }
280 }
281 return GithubTokenTypeUnknown
282}
283
284func (connection GithubConnection) Sanitize() GithubConnection {
285 connection.GithubConn = connection.GithubConn.Sanitize()

Callers 2

SanitizeTokenMethod · 0.95

Calls

no outgoing calls

Tested by 1