Skip to content

Commit

Permalink
Custom Branding: Relative URL should be allowed (#5572) (#5624)
Browse files Browse the repository at this point in the history
When enabling the advanced setting `courier:ignoreFilterIfFieldNotInIndex`
Custom OpenSearch Query DSL filters could technically be applied to index
patterns that map to indices that are not exactly the same. Since the
custom query filter is a user input then users can really type anything
that they need. Or any field that they know is present but we do not know
for sure.

Therefore, we can check if the id which is the index pattern title to check
if we should apply the filter or not.

Issue resolved:
https://github.com/opensearch-project/dashboards-visualizations/issues/281

Issue could be closed:
#5423

---------







(cherry picked from commit d8cbc17)

Signed-off-by: Alankarsharma <[email protected]>
Signed-off-by: Kawika Avilla <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: Kawika Avilla <[email protected]>
Co-authored-by: Qingyang(Abby) Hu <[email protected]>
  • Loading branch information
4 people authored Dec 19, 2023
1 parent 44f53fc commit 63bde3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/server/rendering/rendering_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ describe('RenderingService', () => {
const result = await service.isUrlValid('/', 'config');
expect(result).toEqual(false);
});

it('checks relative URL returns true', async () => {
const result = await service.isUrlValid('/demo/opensearch_mark_default.png', 'config');
expect(result).toEqual(true);
});
});

describe('isTitleValid()', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/core/server/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ export class RenderingService {
this.logger.get('branding').error(`${configName} config is invalid. Using default branding.`);
return false;
}
if (url.startsWith('/')) {
return true;
}
return await Axios.get(url, {
httpsAgent: this.httpsAgent,
adapter: AxiosHttpAdapter,
Expand Down

0 comments on commit 63bde3c

Please sign in to comment.