Fix codeQL error using URL params as part of the URL & remove commit added by mistake

Signed-off-by: ivgo <ivgo@spreadgroup.com>
This commit is contained in:
ivgo
2022-06-07 08:39:55 +02:00
parent 97c34999de
commit 655a8d46d8
6 changed files with 28 additions and 23 deletions
@@ -152,8 +152,8 @@ export class VaultBuilder {
res.json({ status: 'ok' });
});
router.get('/v1/secrets', async (req, res) => {
const path = req.query.path;
router.get('/v1/secrets/:path', async (req, res) => {
const { path } = req.params;
if (typeof path !== 'string') {
throw new InputError(`Invalid path: ${path}`);
}
+10 -9
View File
@@ -85,16 +85,17 @@ export class VaultClient implements VaultApi {
query: { [key in string]: any },
method: string = 'GET',
): Promise<T | undefined> {
const url = `${this.vaultConfig.baseUrl}/${path}?${new URLSearchParams(
query,
).toString()}`;
const response = await fetch(url, {
method,
headers: {
Accept: 'application/json',
'X-Vault-Token': this.vaultConfig.token,
const url = new URL(path, this.vaultConfig.baseUrl);
const response = await fetch(
`${url.toString()}?${new URLSearchParams(query).toString()}`,
{
method,
headers: {
Accept: 'application/json',
'X-Vault-Token': this.vaultConfig.token,
},
},
});
);
if (response.status === 200) {
return (await response.json()) as T;
}