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:
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user