-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,6 +238,16 @@ export abstract class BaseExternalAccountClient extends AuthClient { | |
/** The service account email to be impersonated, if available. */ | ||
getServiceAccountEmail(): string | null { | ||
if (this.serviceAccountImpersonationUrl) { | ||
if (this.serviceAccountImpersonationUrl.length > 256) { | ||
/** | ||
* Prevents DOS attacks. | ||
* @see {@link https://github.com/googleapis/google-auth-library-nodejs/security/code-scanning/84} | ||
**/ | ||
throw new RangeError( | ||
`URL is too long: ${this.serviceAccountImpersonationUrl}` | ||
); | ||
} | ||
|
||
// Parse email from URL. The formal looks as follows: | ||
// https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken | ||
const re = /serviceAccounts\/(?<email>[^:]+):generateAccessToken$/; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters