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
+4 -4
View File
@@ -42,11 +42,11 @@ describe('api', () => {
const setupHandlers = () => {
server.use(
rest.get(`${mockBaseUrl}/v1/secrets`, (req, res, ctx) => {
const path = req.url.searchParams.get('path');
if (path === 'test/success') {
rest.get(`${mockBaseUrl}/v1/secrets/:path`, (req, res, ctx) => {
const { path } = req.params;
if (path === 'test%2Fsuccess') {
return res(ctx.json(mockSecretsResult));
} else if (path === 'test/error') {
} else if (path === 'test%2Ferror') {
return res(ctx.json([]));
}
return res(ctx.status(400));
+7 -3
View File
@@ -56,9 +56,13 @@ export class VaultClient implements VaultApi {
}
async listSecrets(secretPath: string): Promise<VaultSecret[]> {
const result = await this.callApi<VaultSecret[]>('v1/secrets', {
path: secretPath,
});
if (secretPath === '') {
return [];
}
const result = await this.callApi<VaultSecret[]>(
`v1/secrets/${encodeURIComponent(secretPath)}`,
{},
);
if (!result) {
return [];
}
@@ -83,11 +83,11 @@ describe('EntityVautTable', () => {
const setupHandlers = () => {
server.use(
rest.get(`${mockBaseUrl}/v1/secrets`, (req, res, ctx) => {
const path = req.url.searchParams.get('path');
if (path === 'test/success') {
rest.get(`${mockBaseUrl}/v1/secrets/:path`, (req, res, ctx) => {
const { path } = req.params;
if (path === 'test%2Fsuccess') {
return res(ctx.json(mockSecretsResult));
} else if (path === 'test/error') {
} else if (path === 'test%2Ferror') {
return res(ctx.json([]));
}
return res(ctx.status(400));