-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🚀 Release 0.216.1 * fix(core): Do not allow arbitrary path traversal in the credential-translation endpoint (#5522) * fix(core): Do not allow arbitrary path traversal in BinaryDataManager (#5523) * fix(core): User update endpoint should only allow updating email, firstName, and lastName (#5526) * fix(core): Do not explicitly bypass auth on urls containing `.svg` (#5525) * 📚 Update CHANGELOG.md --------- Co-authored-by: janober <janober@users.noreply.github.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
- Loading branch information
1 parent
fe782c8
commit 7400c35
Showing
24 changed files
with
272 additions
and
138 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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { Request } from 'express'; | ||
import { ICredentialTypes } from 'n8n-workflow'; | ||
import { join } from 'path'; | ||
import { access } from 'fs/promises'; | ||
import { Get, RestController } from '@/decorators'; | ||
import { BadRequestError, InternalServerError } from '@/ResponseHelper'; | ||
import { Config } from '@/config'; | ||
import { NODES_BASE_DIR } from '@/constants'; | ||
|
||
export const CREDENTIAL_TRANSLATIONS_DIR = 'n8n-nodes-base/dist/credentials/translations'; | ||
export const NODE_HEADERS_PATH = join(NODES_BASE_DIR, 'dist/nodes/headers'); | ||
|
||
export declare namespace TranslationRequest { | ||
export type Credential = Request<{}, {}, {}, { credentialType: string }>; | ||
} | ||
|
||
@RestController('/') | ||
export class TranslationController { | ||
constructor(private config: Config, private credentialTypes: ICredentialTypes) {} | ||
|
||
@Get('/credential-translation') | ||
async getCredentialTranslation(req: TranslationRequest.Credential) { | ||
const { credentialType } = req.query; | ||
|
||
if (!this.credentialTypes.recognizes(credentialType)) | ||
throw new BadRequestError(`Invalid Credential type: "${credentialType}"`); | ||
|
||
const defaultLocale = this.config.getEnv('defaultLocale'); | ||
const translationPath = join( | ||
CREDENTIAL_TRANSLATIONS_DIR, | ||
defaultLocale, | ||
`${credentialType}.json`, | ||
); | ||
|
||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return require(translationPath); | ||
} catch (error) { | ||
return null; | ||
} | ||
} | ||
|
||
@Get('/node-translation-headers') | ||
async getNodeTranslationHeaders() { | ||
try { | ||
await access(`${NODE_HEADERS_PATH}.js`); | ||
} catch (_) { | ||
return; // no headers available | ||
} | ||
|
||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return require(NODE_HEADERS_PATH); | ||
} catch (error) { | ||
throw new InternalServerError('Failed to load headers file'); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.